MKDOC=mkdoc --xsltroot=/usr/share/sgml/logilab-xml/stylesheet
MKXMLOPTS=--doctype book --target docbook
MKHTMLOPTS=--param toc.section.depth=2 --stylesheet single-file  --target html
MKPDFOPTS=--param toc.section.depth=2 --stylesheet standard --target pdf

TXTFILES:= $(wildcard *.txt)
XMLFILES:= $(wildcard *.xml)
HTMLTARGET := $(TXTFILES:.txt=.html)
PDFTARGET := $(TXTFILES:.txt=.pdf)



all: ${HTMLTARGET} ${PDFTARGET} SUB
html: ${HTMLTARGET}
pdf: ${PDFTARGET}


%.xml: %.txt
	${MKDOC} ${MKXMLOPTS} $<
	sed -i "s/<book>/<book lang='en'>/" $@

%.html: %.xml
	${MKDOC} ${MKHTMLOPTS} $<

%.pdf: %.xml
	${MKDOC} ${MKPDFOPTS} $<

SUB:
	cd technical_manual/ ; make
	cd programmer_handbook/ ; make


clean:
	rm -f *.pdf *.html `ls *.xml | grep -v legal_notice.en.xml`
	cd technical_manual/ ; make clean
	cd programmer_handbook/ ; make clean
