hgbook

annotate Makefile @ 880:a821682ea3a5

Attach it to building
author Dongsheng Song <dongsheng.song@gmail.com>
date Wed Oct 21 16:10:27 2009 +0800 (2009-10-21)
parents c3863298abc7
children 3df0c9cfe902
rev   line source
dongsheng@626 1 #
dongsheng@626 2 # Makefile for the hgbook, top-level
dongsheng@626 3 #
songdongsheng@657 4 include Makefile.vars
dongsheng@626 5
dongsheng@661 6 FORMATS=html html-single pdf epub
dongsheng@626 7
dongsheng@626 8 PO_LANGUAGES := zh
dongsheng@880 9 DBK_LANGUAGES := en it
dongsheng@626 10 LANGUAGES := $(DBK_LANGUAGES) $(PO_LANGUAGES)
dongsheng@626 11
songdongsheng@657 12 UPDATEPO = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-updatepo -M UTF-8 \
dongsheng@661 13 -f docbook -o doctype=docbook -o includeexternal \
dongsheng@661 14 -o nodefault="<programlisting> <screen>" \
dongsheng@661 15 -o untranslated="<programlisting> <screen>"
songdongsheng@657 16 TRANSLATE = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-translate -M UTF-8 \
songdongsheng@668 17 -f docbook -o doctype=docbook -o includeexternal \
songdongsheng@668 18 -o nodefault="<programlisting> <screen>" \
songdongsheng@668 19 -o untranslated="<programlisting> <screen>" \
dongsheng@626 20 -k 0
dongsheng@626 21
dongsheng@626 22 #rev_id = $(shell hg parents --template '{node|short} ({date|isodate})')
dongsheng@626 23 rev_id = $(shell hg parents --template '{node|short} ({date|shortdate})')
dongsheng@626 24
dongsheng@880 25 images-src := $(wildcard en/figs/*.dot en/figs/*.svg en/figs/*.png)
dongsheng@880 26
dongsheng@880 27 images-dot := $(filter %.dot, $(images-src))
dongsheng@880 28 images-svg := $(filter %.svg, $(images-src))
dongsheng@880 29
dongsheng@880 30 images-dst := $(images-src:dot=png)
dongsheng@880 31 images-dst := $(images-dst:svg=png)
dongsheng@880 32
dongsheng@880 33 images-out := $(images-dot:dot=svg)
dongsheng@880 34 images-out += $(images-dot:dot=png)
dongsheng@880 35 images-out += $(images-svg:svg=png)
dongsheng@626 36
dongsheng@626 37 help:
dongsheng@880 38 @echo " make epub [LINGUA=en|it|zh|...]"
dongsheng@880 39 @echo " make html [LINGUA=en|it|zh|...]"
dongsheng@880 40 @echo " make html-single [LINGUA=en|it|zh|...]"
dongsheng@880 41 @echo " make pdf [LINGUA=en|it|zh|...]"
dongsheng@880 42 @echo " make validate [LINGUA=en|it|zh|...] # always before commit!"
dongsheng@626 43 @echo " make tidypo [LINGUA=zh|...] # always before commit!"
dongsheng@626 44 @echo " make updatepo [LINGUA=zh|...] # update po files."
dongsheng@880 45 @echo " make all [LINGUA=en|it|zh|...]"
dongsheng@626 46 @echo " make stat # print statistics about po files."
dongsheng@626 47 @echo " make clean # Remove the build files."
dongsheng@626 48
dongsheng@626 49 clean:
dongsheng@880 50 @rm -fr build hello po/*.mo en/hello en/html en/.validated-00book.xml \
dongsheng@880 51 en/examples/.run en/examples/results en/figs/*-tmp.svg \
dongsheng@880 52 stylesheets/system-xsl web/index-read.html.in
dongsheng@880 53
dongsheng@880 54 @(for l in $(DBK_LANGUAGES); do \
dongsheng@880 55 rm -fr $(subst en/figs/, $$l/figs/, $(images-out)) ;\
dongsheng@880 56 done)
dongsheng@626 57
dongsheng@626 58 all:
dongsheng@626 59 ifdef LINGUA
dongsheng@626 60 for f in $(FORMATS); do \
dongsheng@626 61 $(MAKE) LINGUA=$(LINGUA) $$f; \
dongsheng@626 62 done
dongsheng@626 63 else
dongsheng@626 64 for l in $(LANGUAGES); do \
dongsheng@626 65 for f in $(FORMATS); do \
dongsheng@626 66 $(MAKE) LINGUA=$$l $$f; \
dongsheng@626 67 done; \
dongsheng@626 68 done
dongsheng@626 69 endif
dongsheng@626 70
dongsheng@626 71 stat:
dongsheng@626 72 @( \
dongsheng@626 73 LANG=C; export LANG; cd po; \
dongsheng@626 74 for f in *.po; do \
dongsheng@626 75 printf "%s\t" $$f; \
dongsheng@626 76 msgfmt --statistics -c $$f; \
dongsheng@626 77 done; \
dongsheng@626 78 )
dongsheng@626 79
dongsheng@626 80 tidypo:
dongsheng@626 81 ifdef LINGUA
dongsheng@880 82 ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" ""
dongsheng@626 83 msgcat --sort-by-file --width=80 po/$(LINGUA).po > po/$(LINGUA).tmp && \
dongsheng@626 84 mv po/$(LINGUA).tmp po/$(LINGUA).po;
dongsheng@880 85 endif
dongsheng@626 86 else
dongsheng@626 87 for po in $(wildcard po/*.po); do \
dongsheng@626 88 msgcat --sort-by-file --width=80 $$po > $$po.tmp && mv $$po.tmp $$po; \
dongsheng@626 89 done
dongsheng@626 90 endif
dongsheng@626 91
dongsheng@626 92 ifndef LINGUA
dongsheng@626 93 updatepo:
dongsheng@626 94 for l in $(PO_LANGUAGES); do \
dongsheng@626 95 $(MAKE) $@ LINGUA=$$l; \
dongsheng@626 96 done
dongsheng@626 97 else
dongsheng@626 98 updatepo:
dongsheng@626 99 ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" ""
dongsheng@661 100 (cd po; \
dongsheng@661 101 $(UPDATEPO) -m ../en/00book.xml -p $(LINGUA).po; \
dongsheng@661 102 )
dongsheng@626 103 $(MAKE) tidypo LINGUA=$(LINGUA)
dongsheng@626 104 endif
dongsheng@626 105 endif
dongsheng@626 106
dongsheng@626 107 ifndef LINGUA
dongsheng@626 108 validate:
dongsheng@626 109 for l in $(LANGUAGES); do \
dongsheng@626 110 $(MAKE) $@ LINGUA=$$l; \
dongsheng@626 111 done
dongsheng@626 112 else
dongsheng@626 113 validate: build/$(LINGUA)/source/hgbook.xml
dongsheng@626 114 xmllint --nonet --noout --postvalid --xinclude $<
dongsheng@626 115
dongsheng@626 116 ifneq "$(findstring $(LINGUA),$(DBK_LANGUAGES))" ""
dongsheng@654 117 $(LINGUA)/examples/.run:
dongsheng@880 118 if test -x $(LINGUA)/examples/run-example; then \
dongsheng@880 119 (cd $(LINGUA)/examples; ./run-example -v -a); \
dongsheng@880 120 else \
dongsheng@880 121 touch $@; \
dongsheng@880 122 fi
dongsheng@880 123
dongsheng@880 124 build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(subst en/figs/, $(LINGUA)/figs/, $(images-dst)) $(LINGUA)/examples/.run
dongsheng@654 125 mkdir -p build/$(LINGUA)/source/figs
dongsheng@654 126 cp $(LINGUA)/figs/*.png build/$(LINGUA)/source/figs
dongsheng@661 127 cp stylesheets/hgbook.css build/$(LINGUA)/source
dongsheng@654 128 (cd $(LINGUA); xmllint --nonet --noent --xinclude --postvalid --output ../$@.tmp 00book.xml)
dongsheng@626 129 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
dongsheng@626 130 else
dongsheng@654 131 en/examples/.run:
dongsheng@654 132 (cd en/examples; ./run-example -v -a)
dongsheng@654 133
dongsheng@654 134 build/en/source/hgbook.xml:
dongsheng@654 135 ${MAKE} LINGUA=en $@
dongsheng@654 136
dongsheng@880 137 build/$(LINGUA)/source/hgbook.xml: $(wildcard en/*.xml) po/$(LINGUA).po $(images-dst)
dongsheng@654 138 mkdir -p build/$(LINGUA)/source/figs
songdongsheng@657 139 cp en/figs/*.png build/$(LINGUA)/source/figs
dongsheng@661 140 cp stylesheets/hgbook.css build/$(LINGUA)/source
songdongsheng@668 141 $(TRANSLATE) -m en/00book.xml -p po/$(LINGUA).po -l en/hgbook.xml.$(LINGUA)
songdongsheng@668 142 xmllint --nonet --noent --xinclude --postvalid --output $@.tmp en/hgbook.xml.$(LINGUA)
dongsheng@626 143 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
songdongsheng@668 144 mv en/hgbook.xml.$(LINGUA) build/$(LINGUA)/source
dongsheng@626 145 endif
dongsheng@626 146
dongsheng@626 147 endif
dongsheng@626 148
dongsheng@626 149 ifndef LINGUA
dongsheng@661 150 epub:
dongsheng@661 151 for l in $(LANGUAGES); do \
dongsheng@661 152 $(MAKE) $@ LINGUA=$$l; \
dongsheng@661 153 done
dongsheng@661 154 else
dongsheng@661 155 epub: build/$(LINGUA)/epub/hgbook.epub
dongsheng@661 156
dongsheng@661 157 build/$(LINGUA)/epub/hgbook.epub: build/$(LINGUA)/source/hgbook.xml
dongsheng@661 158 mkdir -p build/$(LINGUA)/epub
dongsheng@661 159 (cd build/$(LINGUA)/source; $(DB2EPUB) -c hgbook.css -v hgbook.xml; mv hgbook.epub ../epub)
dongsheng@661 160 endif
dongsheng@661 161
dongsheng@661 162 ifndef LINGUA
dongsheng@626 163 html:
dongsheng@626 164 for l in $(LANGUAGES); do \
dongsheng@626 165 $(MAKE) $@ LINGUA=$$l; \
dongsheng@626 166 done
dongsheng@626 167 else
dongsheng@626 168 html: build/$(LINGUA)/html/index.html
dongsheng@626 169
dongsheng@629 170 build/$(LINGUA)/html/index.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html.xsl stylesheets/$(LINGUA)/html.xsl
dongsheng@654 171 mkdir -p build/$(LINGUA)/html/figs
dongsheng@654 172 cp en/figs/*.png build/$(LINGUA)/html/figs
dongsheng@629 173 cp stylesheets/hgbook.css build/$(LINGUA)/html
dongsheng@626 174 xsltproc --output build/$(LINGUA)/html/ \
dongsheng@629 175 stylesheets/$(LINGUA)/html.xsl build/$(LINGUA)/source/hgbook.xml
dongsheng@626 176 endif
dongsheng@626 177
dongsheng@626 178 ifndef LINGUA
dongsheng@626 179 html-single:
dongsheng@626 180 for l in $(LANGUAGES); do \
dongsheng@626 181 $(MAKE) $@ LINGUA=$$l; \
dongsheng@626 182 done
dongsheng@626 183 else
dongsheng@626 184 html-single: build/$(LINGUA)/html-single/hgbook.html
dongsheng@626 185
dongsheng@629 186 build/$(LINGUA)/html-single/hgbook.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html-single.xsl stylesheets/$(LINGUA)/html-single.xsl
dongsheng@654 187 mkdir -p build/$(LINGUA)/html-single/figs
dongsheng@654 188 cp en/figs/*.png build/$(LINGUA)/html-single/figs
dongsheng@629 189 cp stylesheets/hgbook.css build/$(LINGUA)/html-single
dongsheng@626 190 xsltproc --output build/$(LINGUA)/html-single/hgbook.html \
dongsheng@629 191 stylesheets/$(LINGUA)/html-single.xsl build/$(LINGUA)/source/hgbook.xml
dongsheng@626 192 endif
dongsheng@626 193
dongsheng@626 194 ifndef LINGUA
dongsheng@626 195 pdf:
dongsheng@626 196 for l in $(LANGUAGES); do \
dongsheng@626 197 $(MAKE) $@ LINGUA=$$l; \
dongsheng@626 198 done
dongsheng@626 199 else
dongsheng@626 200 pdf: build/$(LINGUA)/pdf/hgbook.pdf
dongsheng@626 201
dongsheng@629 202 build/$(LINGUA)/pdf/hgbook.pdf: build/$(LINGUA)/source/hgbook.xml stylesheets/fo.xsl stylesheets/$(LINGUA)/fo.xsl
dongsheng@626 203 mkdir -p build/$(LINGUA)/pdf
songdongsheng@668 204 java -classpath $(JAVA_LIB)/saxon65.jar:$(JAVA_LIB)/saxon65-dbxsl.jar:$(JAVA_LIB)/xml-commons-resolver-1.2.jar:$(JAVA_LIB) \
dongsheng@626 205 com.icl.saxon.StyleSheet \
dongsheng@626 206 -x org.apache.xml.resolver.tools.ResolvingXMLReader \
dongsheng@626 207 -y org.apache.xml.resolver.tools.ResolvingXMLReader \
dongsheng@626 208 -r org.apache.xml.resolver.tools.CatalogResolver \
dongsheng@626 209 -o build/$(LINGUA)/source/hgbook.fo \
dongsheng@626 210 build/$(LINGUA)/source/hgbook.xml \
dongsheng@629 211 stylesheets/$(LINGUA)/fo.xsl \
dongsheng@626 212 fop1.extensions=1
dongsheng@626 213
dongsheng@659 214 (cd build/$(LINGUA)/source && $(FOP_HOME)/fop.sh -c $(FOP_HOME)/conf/userconfig.xml hgbook.fo ../pdf/hgbook.pdf)
dongsheng@626 215 endif
dongsheng@626 216
dongsheng@880 217 $(LINGUA)/figs/%.png: $(LINGUA)/figs/%.svg
dongsheng@880 218 if test -x $(LINGUA)/fixsvg; then \
dongsheng@880 219 $(LINGUA)/fixsvg $<; \
dongsheng@880 220 inkscape -D -d 120 -e $@ $<-tmp.svg; \
dongsheng@880 221 else \
dongsheng@880 222 inkscape -D -d 120 -e $@ $<; \
dongsheng@880 223 fi
dongsheng@880 224
dongsheng@880 225 $(LINGUA)/figs/%.svg: $(LINGUA)/figs/%.dot
dongsheng@880 226 dot -Tsvg -o $@ $<
dongsheng@880 227
dongsheng@654 228 en/figs/%.png: en/figs/%.svg en/fixsvg
dongsheng@633 229 en/fixsvg $<
dongsheng@633 230 inkscape -D -d 120 -e $@ $<-tmp.svg
dongsheng@626 231
dongsheng@654 232 en/figs/%.svg: en/figs/%.dot
dongsheng@626 233 dot -Tsvg -o $@ $<