hgbook

view en/Makefile @ 657:1e020cb7d417

Remove tools
author Dongsheng Song <songdongsheng@live.cn>
date Mon Mar 30 21:36:31 2009 +0800 (2009-03-30)
parents 7e7c47481e4f 9e8e5292acaa
children 3b33dd6aba87
line source
1 # This makefile requires GNU make.
3 image-sources := $(wildcard figs/*.dot figs/*.gif figs/*.png figs/*.svg)
5 xml-src-files := \
6 00book.xml \
7 app*.xml \
8 ch*.xml
10 image-dot := $(filter %.dot,$(image-sources))
11 image-svg := $(filter %.svg,$(image-sources))
12 image-oth := $(filter %.gif %.png,$(image-sources))
14 obj-web := html
15 obj-websup := $(obj-web)/support
16 obj-web-read := $(obj-web)/read
18 image-web := \
19 $(image-dot:%.dot=$(obj-web-read)/%.png) \
20 $(image-svg:%.svg=$(obj-web-read)/%.png) \
21 $(image-oth:%=$(obj-web-read)/%)
23 example-sources-by-name := \
24 backout \
25 bisect \
26 branching \
27 branch-named \
28 branch-repo \
29 cmdref \
30 daily.copy \
31 daily.files \
32 daily.rename \
33 daily.revert \
34 extdiff \
35 filenames \
36 hook.msglen \
37 hook.simple \
38 hook.ws \
39 issue29 \
40 mq.guards \
41 mq.qinit-help \
42 mq.dodiff \
43 mq.id \
44 mq.tarball \
45 mq.tools \
46 mq.tutorial \
47 rename.divergent \
48 rollback \
49 tag \
50 template.simple \
51 template.svnstyle \
52 tour \
53 tour-merge-conflict
55 example-sources := \
56 $(example-sources-by-name:%=examples/%) \
57 $(wildcard examples/ch*/*)
59 extras-web-base := \
60 $(obj-web)/index.html \
61 $(obj-web)/robots.txt \
62 $(obj-websup)/form-min.js \
63 $(obj-websup)/form.js \
64 $(obj-websup)/hsbook.js \
65 $(obj-websup)/jquery-min.js \
66 $(obj-websup)/jquery.js \
67 $(obj-websup)/styles.css
69 extras-web := $(extras-web-base) $(extras-web-base:%=%.gz)
71 xsltproc := xsltproc
72 xsltproc-opts := --nonet --xinclude --path '$(xml-path)'
74 xmllint := xmllint
75 xmllint-opts := --noout --nonet --valid
77 system-xsl-dir := $(firstword $(wildcard \
78 /usr/share/sgml/docbook/xsl-stylesheets \
79 /usr/share/xml/docbook/stylesheet/nwalsh \
80 ))
82 # Bletcherousness.
84 ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),)
85 dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*)
86 else
87 ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),)
88 dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4)
89 else
90 $(error Do not know where to look for DocBook XML 4.4 DTD)
91 endif
92 endif
94 ifeq ($(system-xsl-dir),)
95 $(error add a suitable directory to system-xsl-dir)
96 endif
98 example-prereqs := \
99 /usr/bin/merge
101 dist-sources := \
102 ../html/hgicon.png \
103 ../html/index.html.var \
104 ../html/index.en.html
106 hg = $(shell which hg)
108 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
110 hg-version = $(shell hg version -q | \
111 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
113 all: web
115 ../stylesheets/system-xsl: $(system-xsl-dir)
116 ln -s $< $@
118 web: ../stylesheets/system-xsl websup html
120 html: $(obj-web-read)/index.html
122 ../web/index-read.html.in: ../web/genindex.py $(xml-src-files)
123 $<
125 $(obj-web-read)/index.html: ../stylesheets/system-xsl .validated-00book.xml ../web/index-read.html.in
126 xsltproc $(xsltproc-opts) -o $(obj-web-read)/x ../stylesheets/chunk-stylesheet.xsl 00book.xml
127 python ../web/texpand.py ../web/index-read.html.in html/read/index.html
128 for i in $(obj-web-read)/*.html; do \
129 gzip -9 -c $$i > $$i.gz; \
130 done
132 websup: $(extras-web) $(image-web)
133 mkdir -p $(obj-websup)/figs $(obj-web-read)/figs
134 cp ../stylesheets/system-xsl/images/*.png $(obj-websup)/figs
135 cp -f ../web/icons/*.png $(obj-websup)/figs
137 all-ids.dat: ../stylesheets/all-ids.xsl $(xml-src-files)
138 $(xsltproc) $(xsltproc-opts) -o $@ ../stylesheets/all-ids.xsl 00book.xml
140 web: websup
142 valid: .validated-00book.xml
144 .validated-00book.xml: $(xml-src-files)
145 $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
146 touch $@
148 # Produce 90dpi PNGs for the web.
150 $(obj-web-read)/figs/%.png: $(obj-web-read)/figs/%.svg fixsvg
151 mkdir -p $(dir $@)
152 ./fixsvg $<
153 inkscape -D -e $@ $<-tmp.svg
154 rm $<-tmp.svg
156 $(obj-web-read)/figs/%.png: figs/%.svg fixsvg
157 mkdir -p $(dir $@)
158 ./fixsvg $<
159 inkscape -D -e $@ $<-tmp.svg
160 rm $<-tmp.svg
162 $(obj-web-read)/figs/%.gif: figs/%.gif
163 cp $< $@
165 $(obj-web-read)/figs/%.png: figs/%.png
166 cp $< $@
168 $(obj-web-read)/figs/%.svg: figs/%.dot
169 mkdir -p $(dir $@)
170 dot -Tsvg -o $@ $<
172 examples: $(example-prereqs) examples/.run
174 examples/.run: $(example-sources)
175 cd examples && ./run-example
177 examples/%.run: examples/% examples/run-example
179 clean:
180 -rm -rf dist html $(image-dot:%.dot=%.pdf) $(image-dot:%.dot=%.png) \
181 $(image-svg:%.svg=%.png) examples/*.{lxo,run} examples/.run
183 install: html $(dist-sources)
184 rm -rf dist
185 mkdir -p dist
186 cp html/*.{css,html,png} dist
187 cp $(dist-sources) dist
189 rsync: install
190 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook
192 vpath %.css ../web
193 vpath %.html.in ../web
194 vpath %.js ../web/javascript
196 $(obj-websup)/%.css: %.css
197 @mkdir -p $(dir $@)
198 cp $< $@
200 $(obj-websup)/%.jpg: %.jpg
201 @mkdir -p $(dir $@)
202 cp $< $@
204 $(obj-websup)/%.js: %.js
205 @mkdir -p $(dir $@)
206 cp $< $@
208 $(obj-web)/%: ../web/%
209 @mkdir -p $(dir $@)
210 cp $< $@
212 $(obj-web)/%.html: %.html.in
213 @mkdir -p $(dir $@)
214 python ../web/texpand.py $< $@
216 %.gz: %
217 gzip -9 -c $< > $@