hgbook

annotate Makefile @ 657:1e020cb7d417

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