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