# PDF by (free) FOP.

CONVERT=/home/hussein/src/11xxe/bin/xxeconvert 

VALIDATE=/home/hussein/src/ditac/bin/ditac -validate -dryrun IGNORED.pdf  

COMMON_OPTIONS=-p extended-toc both -p use-note-icon yes

PRINT_OPTIONS=-fop -p pdf-outline yes -p title-color "rgb(57,73,134)" \
	$(COMMON_OPTIONS)

SCREEN_OPTIONS=-p mark-external-links yes \
	$(COMMON_OPTIONS)

OFFICE_OPTIONS=-p title-color "rgb(57,73,134)" \
	$(COMMON_OPTIONS)

# ----------------------------------------------------------------------------

all: validate html pdf pdf2 epub webhelp zip

validate:
	$(VALIDATE) tutorial.ditamap 

html:
	$(CONVERT) $(SCREEN_OPTIONS) dita.toXHTML1 tutorial.ditamap \
		-u ../index.html

pdf:
	$(CONVERT) $(PRINT_OPTIONS) dita.toPSFile tutorial.ditamap \
		-s pdf -u ../DITA.pdf

pdf2:
	$(CONVERT) $(PRINT_OPTIONS) -t ditac-xsl:fo/fo_indent.xsl \
		-p two-sided yes \
		dita.toPSFile tutorial-book.ditamap \
		-s pdf -u ../DITA-book.pdf

epub:
	$(CONVERT) $(SCREEN_OPTIONS) -p cover-image DITA-cover.png \
		dita.toEPUB tutorial.ditamap \
		-u ../DITA.epub
# -f = fatal errors only
	epubcheck ../DITA.epub

webhelp:
	$(CONVERT) $(SCREEN_OPTIONS) -p wh-favicon webhelp_icon.png \
		dita.toWebHelp tutorial-book.ditamap \
		-u ../webhelp
	cp ../webhelp/tutorial-book.html ../webhelp/index.html

zip:
	(cd ..; zip -r tutorial_src.zip src)

### ---
office: rtf wml docx odt

rtf:
	$(CONVERT) $(OFFICE_OPTIONS) dita.toRTF tutorial.ditamap \
		-s rtf -s Cp1252 -u ../DITA.rtf

wml:
	$(CONVERT) $(OFFICE_OPTIONS) dita.toRTF tutorial.ditamap \
		-s wml -s UTF-8 -u ../DITA.wml

docx:
	$(CONVERT) $(OFFICE_OPTIONS) dita.toRTF tutorial.ditamap \
		-s docx -s UTF-8 -u ../DITA.docx

odt:
	$(CONVERT) $(OFFICE_OPTIONS) dita.toRTF tutorial.ditamap \
		-s odt -s UTF-8 -u ../DITA.odt

# ----------------------------------------------------------------------------
clean:
	rm -f *~

distclean: clean

realclean: distclean
	rm -rf ../index.html ../resources ../images
	rm -f ../*.pdf
	rm -f ../*.epub
	rm -f ../*.zip
	rm -rf ../webhelp
	rm -f ../*.rtf ../*.wml ../*.docx ../*.odt
