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@626: DBK_LANGUAGES := en 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@626: images := \ dongsheng@654: en/figs/feature-branches.png \ dongsheng@654: en/figs/filelog.png \ dongsheng@654: en/figs/metadata.png \ dongsheng@654: en/figs/mq-stack.png \ dongsheng@654: en/figs/revlog.png \ dongsheng@654: en/figs/snapshot.png \ dongsheng@654: en/figs/tour-history.png \ dongsheng@654: en/figs/tour-merge-conflict.png \ dongsheng@654: en/figs/tour-merge-merge.png \ dongsheng@654: en/figs/tour-merge-pull.png \ dongsheng@654: en/figs/tour-merge-sep-repos.png \ dongsheng@654: en/figs/undo-manual-merge.png \ dongsheng@654: en/figs/undo-manual.png \ dongsheng@654: en/figs/undo-non-tip.png \ dongsheng@654: en/figs/undo-simple.png \ dongsheng@654: en/figs/wdir-after-commit.png \ dongsheng@654: en/figs/wdir-branch.png \ dongsheng@654: en/figs/wdir-merge.png \ dongsheng@654: en/figs/wdir.png \ dongsheng@654: en/figs/wdir-pre-branch.png dongsheng@626: dongsheng@626: help: dongsheng@661: @echo " make epub [LINGUA=en|zh|...]" dongsheng@626: @echo " make html [LINGUA=en|zh|...]" dongsheng@626: @echo " make html-single [LINGUA=en|zh|...]" dongsheng@626: @echo " make pdf [LINGUA=en|zh|...]" dongsheng@626: @echo " make validate [LINGUA=en|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@626: @echo " make all [LINGUA=en|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@654: @rm -fr build po/*.mo hello en/hello en/html en/.validated-00book.xml en/examples/.run en/examples/results \ dongsheng@654: stylesheets/system-xsl en/figs/*-tmp.svg \ dongsheng@654: en/figs/feature-branches.png \ dongsheng@654: en/figs/filelog.png \ dongsheng@654: en/figs/feature-branches.png \ dongsheng@654: en/figs/filelog.png \ dongsheng@654: en/figs/metadata.png \ dongsheng@654: en/figs/mq-stack.png \ dongsheng@654: en/figs/revlog.png \ dongsheng@654: en/figs/snapshot.png \ dongsheng@654: en/figs/tour-history.png \ dongsheng@654: en/figs/tour-merge-conflict.png \ dongsheng@654: en/figs/tour-merge-merge.png \ dongsheng@654: en/figs/tour-merge-pull.png \ dongsheng@654: en/figs/tour-merge-sep-repos.png \ dongsheng@654: en/figs/undo-manual-merge.png \ dongsheng@654: en/figs/undo-manual.png \ dongsheng@654: en/figs/undo-non-tip.png \ dongsheng@654: en/figs/undo-simple.png \ dongsheng@654: en/figs/wdir-after-commit.png \ dongsheng@654: en/figs/wdir-branch.png \ dongsheng@654: en/figs/wdir-merge.png \ dongsheng@654: en/figs/wdir-pre-branch.png \ dongsheng@654: en/figs/wdir.png 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@626: msgcat --sort-by-file --width=80 po/$(LINGUA).po > po/$(LINGUA).tmp && \ dongsheng@626: mv po/$(LINGUA).tmp po/$(LINGUA).po; 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@626: updatepo: dongsheng@626: 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@626: endif 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@626: ifneq "$(findstring $(LINGUA),$(DBK_LANGUAGES))" "" dongsheng@654: $(LINGUA)/examples/.run: dongsheng@654: (cd $(LINGUA)/examples; ./run-example -v -a) dongsheng@654: songdongsheng@668: build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(images) $(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@626: else dongsheng@654: en/examples/.run: dongsheng@654: (cd en/examples; ./run-example -v -a) dongsheng@654: dongsheng@654: build/en/source/hgbook.xml: dongsheng@654: ${MAKE} LINGUA=en $@ dongsheng@654: songdongsheng@668: build/$(LINGUA)/source/hgbook.xml: $(wildcard en/*.xml) po/$(LINGUA).po $(images) 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@626: 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@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 $@ $<