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