hgbook

view en/Makefile @ 736:263a6c849b6c

Better title for Ch.2.
author Giulio@puck
date Wed Jul 01 08:37:21 2009 +0200 (2009-07-01)
parents 3b33dd6aba87
children
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 issue29 \
39 mq.guards \
40 mq.qinit-help \
41 mq.dodiff \
42 mq.id \
43 mq.tarball \
44 mq.tools \
45 mq.tutorial \
46 rename.divergent \
47 rollback \
48 tag \
49 template.simple \
50 template.svnstyle \
51 tour \
52 tour-merge-conflict
54 example-sources := \
55 $(example-sources-by-name:%=examples/%) \
56 $(wildcard examples/ch*/*)
58 extras-web-base := \
59 $(obj-web)/index.html \
60 $(obj-web)/robots.txt \
61 $(obj-websup)/form-min.js \
62 $(obj-websup)/form.js \
63 $(obj-websup)/hsbook.js \
64 $(obj-websup)/jquery-min.js \
65 $(obj-websup)/jquery.js \
66 $(obj-websup)/styles.css
68 extras-web := $(extras-web-base) $(extras-web-base:%=%.gz)
70 xsltproc := xsltproc
71 xsltproc-opts := --nonet --xinclude --path '$(xml-path)'
73 xmllint := xmllint
74 xmllint-opts := --noout --nonet --valid
76 system-xsl-dir := $(firstword $(wildcard \
77 /usr/share/sgml/docbook/xsl-stylesheets \
78 /usr/share/xml/docbook/stylesheet/nwalsh \
79 ))
81 # Bletcherousness.
83 ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),)
84 dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*)
85 else
86 ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),)
87 dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4)
88 else
89 $(error Do not know where to look for DocBook XML 4.4 DTD)
90 endif
91 endif
93 ifeq ($(system-xsl-dir),)
94 $(error add a suitable directory to system-xsl-dir)
95 endif
97 example-prereqs := \
98 /usr/bin/merge
100 dist-sources := \
101 ../html/hgicon.png \
102 ../html/index.html.var \
103 ../html/index.en.html
105 hg = $(shell which hg)
107 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
109 hg-version = $(shell hg version -q | \
110 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
112 all: web complete.xml
114 ../stylesheets/system-xsl: $(system-xsl-dir)
115 ln -s $< $@
117 web: ../stylesheets/system-xsl websup html
119 html: $(obj-web-read)/index.html
121 ../web/index-read.html.in: ../web/genindex.py $(xml-src-files)
122 cd ../web && ./genindex.py
124 $(obj-web-read)/index.html: ../stylesheets/system-xsl .validated-00book.xml ../web/index-read.html.in
125 xsltproc $(xsltproc-opts) -o $(obj-web-read)/x ../stylesheets/chunk-stylesheet.xsl 00book.xml
126 python ../web/texpand.py ../web/index-read.html.in html/read/index.html
127 for i in $(obj-web-read)/*.html; do \
128 gzip -9 -c $$i > $$i.gz; \
129 done
131 websup: $(extras-web) $(image-web)
132 mkdir -p $(obj-websup)/figs $(obj-web-read)/figs
133 cp ../stylesheets/system-xsl/images/*.png $(obj-websup)/figs
134 cp -f ../web/icons/*.png $(obj-websup)/figs
136 complete.xml: .validated-00book.xml
137 $(xsltproc) $(xsltproc-opts) -o $@ ../stylesheets/dtd-profile.xsl 00book.xml
139 all-ids.dat: ../stylesheets/all-ids.xsl $(xml-src-files)
140 $(xsltproc) $(xsltproc-opts) -o $@ ../stylesheets/all-ids.xsl 00book.xml
142 web: websup
144 valid: .validated-00book.xml
146 .validated-00book.xml: $(xml-src-files) examples/.run
147 $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
148 touch $@
150 # Produce 90dpi PNGs for the web.
152 $(obj-web-read)/figs/%.png: $(obj-web-read)/figs/%.svg fixsvg
153 mkdir -p $(dir $@)
154 ./fixsvg $<
155 inkscape -D -e $@ $<-tmp.svg
156 rm $<-tmp.svg
158 $(obj-web-read)/figs/%.png: figs/%.svg fixsvg
159 mkdir -p $(dir $@)
160 ./fixsvg $<
161 inkscape -D -e $@ $<-tmp.svg
162 rm $<-tmp.svg
164 $(obj-web-read)/figs/%.gif: figs/%.gif
165 cp $< $@
167 $(obj-web-read)/figs/%.png: figs/%.png
168 cp $< $@
170 $(obj-web-read)/figs/%.svg: figs/%.dot
171 mkdir -p $(dir $@)
172 dot -Tsvg -o $@ $<
174 examples: $(example-prereqs) examples/.run
176 examples/.run: $(example-sources)
177 cd examples && ./run-example -a
179 examples/%.run: examples/% examples/run-example
181 clean:
182 -rm -rf dist html $(image-dot:%.dot=%.pdf) $(image-dot:%.dot=%.png) \
183 $(image-svg:%.svg=%.png) examples/*.{lxo,run} examples/.run
185 install: html $(dist-sources)
186 rm -rf dist
187 mkdir -p dist
188 cp html/*.{css,html,png} dist
189 cp $(dist-sources) dist
191 rsync: install
192 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook
194 vpath %.css ../web
195 vpath %.html.in ../web
196 vpath %.js ../web/javascript
198 $(obj-websup)/%.css: %.css
199 @mkdir -p $(dir $@)
200 cp $< $@
202 $(obj-websup)/%.jpg: %.jpg
203 @mkdir -p $(dir $@)
204 cp $< $@
206 $(obj-websup)/%.js: %.js
207 @mkdir -p $(dir $@)
208 cp $< $@
210 $(obj-web)/%: ../web/%
211 @mkdir -p $(dir $@)
212 cp $< $@
214 $(obj-web)/%.html: %.html.in
215 @mkdir -p $(dir $@)
216 python ../web/texpand.py $< $@
218 %.gz: %
219 gzip -9 -c $< > $@