dongsheng@626: # dongsheng@626: # Makefile for the hgbook, top-level dongsheng@626: # songdongsheng@657: include Makefile.vars dongsheng@626: dongsheng@661: FORMATS=html html-single pdf epub dongsheng@626: dongsheng@626: PO_LANGUAGES := zh dongsheng@880: DBK_LANGUAGES := en it dongsheng@626: LANGUAGES := $(DBK_LANGUAGES) $(PO_LANGUAGES) dongsheng@626: songdongsheng@657: UPDATEPO = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-updatepo -M UTF-8 \ dongsheng@661: -f docbook -o doctype=docbook -o includeexternal \ dongsheng@661: -o nodefault=" " \ dongsheng@661: -o untranslated=" " songdongsheng@657: TRANSLATE = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-translate -M UTF-8 \ songdongsheng@668: -f docbook -o doctype=docbook -o includeexternal \ songdongsheng@668: -o nodefault=" " \ songdongsheng@668: -o untranslated=" " \ dongsheng@626: -k 0 dongsheng@626: dongsheng@626: #rev_id = $(shell hg parents --template '{node|short} ({date|isodate})') dongsheng@626: rev_id = $(shell hg parents --template '{node|short} ({date|shortdate})') dongsheng@626: dongsheng@885: images-dot := $(wildcard en/figs/*.dot) dongsheng@885: dongsheng@885: images-svg := $(wildcard en/figs/*.svg) dongsheng@885: images-svg :=$(filter-out %-tmp.svg, $(images-svg)) dongsheng@885: images-svg -= $(images-dot:dot=svg) dongsheng@885: dongsheng@885: images-dst := $(wildcard en/figs/*.png) dongsheng@885: images-dst += $(images-dot:dot=png) dongsheng@885: images-dst += $(images-svg:svg=png) dongsheng@885: dongsheng@885: images-gen := $(images-dot:dot=png) dongsheng@885: images-gen += $(images-svg:svg=png) dongsheng@885: images-gen += $(wildcard en/figs/*-tmp.svg) dongsheng@626: dongsheng@626: help: dongsheng@880: @echo " make epub [LINGUA=en|it|zh|...]" dongsheng@880: @echo " make html [LINGUA=en|it|zh|...]" dongsheng@880: @echo " make html-single [LINGUA=en|it|zh|...]" dongsheng@880: @echo " make pdf [LINGUA=en|it|zh|...]" dongsheng@880: @echo " make validate [LINGUA=en|it|zh|...] # always before commit!" dongsheng@626: @echo " make tidypo [LINGUA=zh|...] # always before commit!" dongsheng@626: @echo " make updatepo [LINGUA=zh|...] # update po files." dongsheng@880: @echo " make all [LINGUA=en|it|zh|...]" dongsheng@626: @echo " make stat # print statistics about po files." dongsheng@626: @echo " make clean # Remove the build files." dongsheng@626: dongsheng@626: clean: dongsheng@885: @rm -fr build hello po/*.mo /tmp/REV*-hello en/examples/results dongsheng@880: dongsheng@880: @(for l in $(DBK_LANGUAGES); do \ dongsheng@885: rm -fr $(subst en/figs/, $$l/figs/, $(images-gen)) $$l/examples/.run;\ dongsheng@880: done) dongsheng@626: dongsheng@626: all: dongsheng@626: ifdef LINGUA dongsheng@626: for f in $(FORMATS); do \ dongsheng@626: $(MAKE) LINGUA=$(LINGUA) $$f; \ dongsheng@626: done dongsheng@626: else dongsheng@626: for l in $(LANGUAGES); do \ dongsheng@626: for f in $(FORMATS); do \ dongsheng@626: $(MAKE) LINGUA=$$l $$f; \ dongsheng@626: done; \ dongsheng@626: done dongsheng@626: endif dongsheng@626: dongsheng@626: stat: dongsheng@626: @( \ dongsheng@626: LANG=C; export LANG; cd po; \ dongsheng@626: for f in *.po; do \ dongsheng@626: printf "%s\t" $$f; \ dongsheng@626: msgfmt --statistics -c $$f; \ dongsheng@626: done; \ dongsheng@626: ) dongsheng@626: dongsheng@626: tidypo: dongsheng@626: ifdef LINGUA dongsheng@882: ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" "" dongsheng@626: msgcat --sort-by-file --width=80 po/$(LINGUA).po > po/$(LINGUA).tmp && \ dongsheng@626: mv po/$(LINGUA).tmp po/$(LINGUA).po; dongsheng@882: endif dongsheng@626: else dongsheng@626: for po in $(wildcard po/*.po); do \ dongsheng@626: msgcat --sort-by-file --width=80 $$po > $$po.tmp && mv $$po.tmp $$po; \ dongsheng@626: done dongsheng@626: endif dongsheng@626: dongsheng@626: ifndef LINGUA dongsheng@626: updatepo: dongsheng@626: for l in $(PO_LANGUAGES); do \ dongsheng@626: $(MAKE) $@ LINGUA=$$l; \ dongsheng@626: done dongsheng@626: else dongsheng@881: po/$(LINGUA).po: $(wildcard en/*.xml) dongsheng@881: ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" "" dongsheng@661: (cd po; \ dongsheng@661: $(UPDATEPO) -m ../en/00book.xml -p $(LINGUA).po; \ dongsheng@661: ) dongsheng@626: $(MAKE) tidypo LINGUA=$(LINGUA) dongsheng@881: endif dongsheng@881: dongsheng@881: updatepo: po/$(LINGUA).po dongsheng@626: endif dongsheng@626: dongsheng@626: ifndef LINGUA dongsheng@626: validate: dongsheng@626: for l in $(LANGUAGES); do \ dongsheng@626: $(MAKE) $@ LINGUA=$$l; \ dongsheng@626: done dongsheng@626: else dongsheng@626: validate: build/$(LINGUA)/source/hgbook.xml dongsheng@626: xmllint --nonet --noout --postvalid --xinclude $< dongsheng@626: dongsheng@882: ifneq "$(findstring $(LINGUA),$(DBK_LANGUAGES))" "" dongsheng@654: $(LINGUA)/examples/.run: dongsheng@880: if test -x $(LINGUA)/examples/run-example; then \ dongsheng@885: (cd $(LINGUA)/examples; ./run-example -a); \ dongsheng@880: else \ dongsheng@880: touch $@; \ dongsheng@880: fi dongsheng@880: dongsheng@880: build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(subst en/figs/, $(LINGUA)/figs/, $(images-dst)) $(LINGUA)/examples/.run dongsheng@654: mkdir -p build/$(LINGUA)/source/figs dongsheng@654: cp $(LINGUA)/figs/*.png build/$(LINGUA)/source/figs dongsheng@661: cp stylesheets/hgbook.css build/$(LINGUA)/source dongsheng@654: (cd $(LINGUA); xmllint --nonet --noent --xinclude --postvalid --output ../$@.tmp 00book.xml) dongsheng@626: cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@ dongsheng@882: else dongsheng@654: en/examples/.run: dongsheng@885: (cd en/examples; ./run-example -a) dongsheng@654: dongsheng@654: build/en/source/hgbook.xml: dongsheng@654: ${MAKE} LINGUA=en $@ dongsheng@654: dongsheng@885: build/$(LINGUA)/source/hgbook.xml: $(wildcard en/*.xml) po/$(LINGUA).po $(images-dst) en/examples/.run dongsheng@654: mkdir -p build/$(LINGUA)/source/figs songdongsheng@657: cp en/figs/*.png build/$(LINGUA)/source/figs dongsheng@661: cp stylesheets/hgbook.css build/$(LINGUA)/source songdongsheng@668: $(TRANSLATE) -m en/00book.xml -p po/$(LINGUA).po -l en/hgbook.xml.$(LINGUA) songdongsheng@668: xmllint --nonet --noent --xinclude --postvalid --output $@.tmp en/hgbook.xml.$(LINGUA) dongsheng@626: cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@ songdongsheng@668: mv en/hgbook.xml.$(LINGUA) build/$(LINGUA)/source dongsheng@882: endif dongsheng@626: dongsheng@626: endif dongsheng@626: dongsheng@626: ifndef LINGUA dongsheng@661: epub: dongsheng@661: for l in $(LANGUAGES); do \ dongsheng@661: $(MAKE) $@ LINGUA=$$l; \ dongsheng@661: done dongsheng@661: else dongsheng@661: epub: build/$(LINGUA)/epub/hgbook.epub dongsheng@661: dongsheng@661: build/$(LINGUA)/epub/hgbook.epub: build/$(LINGUA)/source/hgbook.xml dongsheng@661: mkdir -p build/$(LINGUA)/epub dongsheng@661: (cd build/$(LINGUA)/source; $(DB2EPUB) -c hgbook.css -v hgbook.xml; mv hgbook.epub ../epub) dongsheng@661: endif dongsheng@661: dongsheng@661: ifndef LINGUA dongsheng@626: html: dongsheng@626: for l in $(LANGUAGES); do \ dongsheng@626: $(MAKE) $@ LINGUA=$$l; \ dongsheng@626: done dongsheng@626: else dongsheng@626: html: build/$(LINGUA)/html/index.html dongsheng@626: dongsheng@629: build/$(LINGUA)/html/index.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html.xsl stylesheets/$(LINGUA)/html.xsl dongsheng@654: mkdir -p build/$(LINGUA)/html/figs dongsheng@654: cp en/figs/*.png build/$(LINGUA)/html/figs dongsheng@629: cp stylesheets/hgbook.css build/$(LINGUA)/html dongsheng@626: xsltproc --output build/$(LINGUA)/html/ \ dongsheng@629: stylesheets/$(LINGUA)/html.xsl build/$(LINGUA)/source/hgbook.xml dongsheng@626: endif dongsheng@626: dongsheng@626: ifndef LINGUA dongsheng@626: html-single: dongsheng@626: for l in $(LANGUAGES); do \ dongsheng@626: $(MAKE) $@ LINGUA=$$l; \ dongsheng@626: done dongsheng@626: else dongsheng@626: html-single: build/$(LINGUA)/html-single/hgbook.html dongsheng@626: dongsheng@629: build/$(LINGUA)/html-single/hgbook.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html-single.xsl stylesheets/$(LINGUA)/html-single.xsl dongsheng@654: mkdir -p build/$(LINGUA)/html-single/figs dongsheng@654: cp en/figs/*.png build/$(LINGUA)/html-single/figs dongsheng@629: cp stylesheets/hgbook.css build/$(LINGUA)/html-single dongsheng@626: xsltproc --output build/$(LINGUA)/html-single/hgbook.html \ dongsheng@629: stylesheets/$(LINGUA)/html-single.xsl build/$(LINGUA)/source/hgbook.xml dongsheng@626: endif dongsheng@626: dongsheng@626: ifndef LINGUA dongsheng@626: pdf: dongsheng@626: for l in $(LANGUAGES); do \ dongsheng@626: $(MAKE) $@ LINGUA=$$l; \ dongsheng@626: done dongsheng@626: else dongsheng@626: pdf: build/$(LINGUA)/pdf/hgbook.pdf dongsheng@626: dongsheng@629: build/$(LINGUA)/pdf/hgbook.pdf: build/$(LINGUA)/source/hgbook.xml stylesheets/fo.xsl stylesheets/$(LINGUA)/fo.xsl dongsheng@626: mkdir -p build/$(LINGUA)/pdf songdongsheng@668: java -classpath $(JAVA_LIB)/saxon65.jar:$(JAVA_LIB)/saxon65-dbxsl.jar:$(JAVA_LIB)/xml-commons-resolver-1.2.jar:$(JAVA_LIB) \ dongsheng@626: com.icl.saxon.StyleSheet \ dongsheng@626: -x org.apache.xml.resolver.tools.ResolvingXMLReader \ dongsheng@626: -y org.apache.xml.resolver.tools.ResolvingXMLReader \ dongsheng@626: -r org.apache.xml.resolver.tools.CatalogResolver \ dongsheng@626: -o build/$(LINGUA)/source/hgbook.fo \ dongsheng@626: build/$(LINGUA)/source/hgbook.xml \ dongsheng@629: stylesheets/$(LINGUA)/fo.xsl \ dongsheng@626: fop1.extensions=1 dongsheng@626: dongsheng@659: (cd build/$(LINGUA)/source && $(FOP_HOME)/fop.sh -c $(FOP_HOME)/conf/userconfig.xml hgbook.fo ../pdf/hgbook.pdf) dongsheng@626: endif dongsheng@626: dongsheng@880: $(LINGUA)/figs/%.png: $(LINGUA)/figs/%.svg dongsheng@880: if test -x $(LINGUA)/fixsvg; then \ dongsheng@880: $(LINGUA)/fixsvg $<; \ dongsheng@880: inkscape -D -d 120 -e $@ $<-tmp.svg; \ dongsheng@880: else \ dongsheng@880: inkscape -D -d 120 -e $@ $<; \ dongsheng@880: fi dongsheng@880: dongsheng@880: $(LINGUA)/figs/%.svg: $(LINGUA)/figs/%.dot dongsheng@880: dot -Tsvg -o $@ $< dongsheng@880: dongsheng@654: en/figs/%.png: en/figs/%.svg en/fixsvg dongsheng@633: en/fixsvg $< dongsheng@633: inkscape -D -d 120 -e $@ $<-tmp.svg dongsheng@626: dongsheng@654: en/figs/%.svg: en/figs/%.dot dongsheng@626: dot -Tsvg -o $@ $<