## Build the documentation from the DocBook XML source.
##
## needs:  xsltproc docbook-xsl docbook-xml libxml2-utils   (for HTML)
##         dblatex                                          (for PDF)
##
## Outputs are first built in temporary files/directories, so that the
## old ones are not lost if something fails.

SRC = debdelta_suite.xml
XSL_HTML = http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl

all: html pdf

html: html/index.html

pdf: debdelta_suite.pdf

check: $(SRC)
	xmllint --noout --nonet --valid $(SRC)

html/index.html: $(SRC) check
	rm -rf html.new
	mkdir html.new
	xsltproc --nonet --stringparam base.dir html.new/ $(XSL_HTML) $(SRC)
	rm -rf html
	mv html.new html

debdelta_suite.pdf: $(SRC) check
	rm -f tmp_debdelta_suite.pdf
	dblatex --quiet -o tmp_debdelta_suite.pdf $(SRC)
	mv tmp_debdelta_suite.pdf debdelta_suite.pdf

clean:
	rm -rf html.new tmp_debdelta_suite.pdf

.PHONY: all html pdf check clean
