# I deleted my first working makefile, but it should be fast to create
# a new one here.  The targets currently implemented are html,
# html_onefile, text, pdf, ps, sgml.gz, html.tar.gz
# If there are more formats that I've forgotten, please let me know
# The default target is all, which creates all possible output
# formats.  As of this moment, this makefile acts on all files in the
# current directory.  If you know a way of getting around that, please
# let me know.
#`echo *.sgml | sed "s/\.sgml//g" `

# list the files you want processes here, minus the .xml extension
# You only need to include the "main file" here if you're including
# sub-files in it.
files = webtools-howto

# List the path to the XSL stylesheets here
stylesheets = /usr/share/sgml/docbook/xsl-stylesheets/

all: html html_onefile text pdf ps xml.gz html.tar.gz

html: 
	(for i in $(files); do \
		mkdir $$i; \
		cd $$i; \
		xsltproc --catalogs $(stylesheets)/html/chunk.xsl ../$$i.xml; \
		cd ..; \
	done;)

html_onefile: 
	(for i in $(files); do \
		xsltproc --catalogs --output 00_$$i.html \
		$(stylesheets)/html/docbook.xsl $$i.xml; \
	done; )

text: html_onefile
	(for i in $(files); do \
		lynx -dump 00_$$i.html > $$i.txt; \
	done; )

pdf: html_onefile
	(for i in $(files); do \
		htmldoc --size universal -t pdf -f $$i.pdf 00_$$i.html; \
	done; )

ps: html_onefile
	(for i in $(files); do \
		htmldoc --size universal -t pdf -f $$i.ps 00_$$i.html; \
	done; )

xml.gz: 
	(for i in $(files); do \
		cp $$i.xml ldp_mk_tmp; \
		gzip -f ldp_mk_tmp; \
		mv -f ldp_mk_tmp.gz $$i.xml.gz;\
	done; )

html.tar.gz: html
	(for i in $(files); do \
		tar -cf $$i.tar $$i; \
		gzip -f $$i.tar; \
	done; )