hgbook

view en/Makefile @ 575:bebd5ff7fe7f

And there was much tidying, and the result was good.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Mar 10 21:58:03 2009 -0700 (2009-03-10)
parents 3bcc001ce34f
children 8366882f67f2 1879ec732a28 c88aa4edf9df
line source
1 # This makefile requires GNU make.
3 image-sources := \
4 feature-branches.dot \
5 filelog.svg \
6 kdiff3.png \
7 metadata.svg \
8 mq-stack.svg \
9 note.png \
10 revlog.svg \
11 snapshot.svg \
12 tour-history.svg \
13 tour-merge-conflict.svg \
14 tour-merge-merge.svg \
15 tour-merge-pull.svg \
16 tour-merge-sep-repos.svg \
17 undo-manual.dot \
18 undo-manual-merge.dot \
19 undo-non-tip.dot \
20 undo-simple.dot \
21 wdir.svg \
22 wdir-after-commit.svg \
23 wdir-branch.svg \
24 wdir-merge.svg \
25 wdir-pre-branch.svg
27 xml-src-files := \
28 00book.xml \
29 app*.xml \
30 ch*.xml
32 image-dot := $(filter %.dot,$(image-sources))
33 image-svg := $(filter %.svg,$(image-sources))
34 image-png := $(filter %.png,$(image-sources))
36 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
38 example-sources := \
39 backout \
40 bisect \
41 branching \
42 branch-named \
43 branch-repo \
44 cmdref \
45 daily.copy \
46 daily.files \
47 daily.rename \
48 daily.revert \
49 extdiff \
50 filenames \
51 hook.msglen \
52 hook.simple \
53 hook.ws \
54 issue29 \
55 mq.guards \
56 mq.qinit-help \
57 mq.dodiff \
58 mq.id \
59 mq.tarball \
60 mq.tools \
61 mq.tutorial \
62 rename.divergent \
63 rollback \
64 tag \
65 template.simple \
66 template.svnstyle \
67 tour \
68 tour-merge-conflict
70 obj-web := html
71 obj-websup := html/support
73 extras-web-base := \
74 $(obj-web)/index.html \
75 $(obj-web)/robots.txt \
76 $(obj-websup)/form-min.js \
77 $(obj-websup)/form.js \
78 $(obj-websup)/hsbook.js \
79 $(obj-websup)/jquery-min.js \
80 $(obj-websup)/jquery.js \
81 $(obj-websup)/styles.css
83 extras-web := $(extras-web-base) $(extras-web-base:%=%.gz)
85 xsltproc := xsltproc
86 xsltproc-opts := --nonet --xinclude --path '$(xml-path)'
88 xmllint := xmllint
89 xmllint-opts := --noout --nonet --valid
91 system-xsl-dir := $(firstword $(wildcard \
92 /usr/share/sgml/docbook/xsl-stylesheets \
93 /usr/share/xml/docbook/stylesheet/nwalsh \
94 ))
96 # Bletcherousness.
98 ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),)
99 dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*)
100 else
101 ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),)
102 dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4)
103 else
104 $(error Do not know where to look for DocBook XML 4.4 DTD)
105 endif
106 endif
108 ifeq ($(system-xsl-dir),)
109 $(error add a suitable directory to system-xsl-dir)
110 endif
112 example-prereqs := \
113 /usr/bin/merge
115 dist-sources := \
116 ../html/hgicon.png \
117 ../html/index.html.var \
118 ../html/index.en.html
120 hg = $(shell which hg)
122 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
124 hg-version = $(shell hg version -q | \
125 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
127 all: web
129 ../xsl/system-xsl: $(system-xsl-dir)
130 ln -s $< $@
132 web: websup html
134 html: ../xsl/system-xsl $(xml-src-files) valid
135 xsltproc $(xsltproc-opts) -o html/read/x ../xsl/chunk-stylesheet.xsl 00book.xml
136 for i in html/read/*.html; do \
137 gzip -9 -c $$i > $$i.gz; \
138 done
140 websup: $(extras-web)
141 mkdir -p $(obj-websup)/figs
142 cp ../xsl/system-xsl/images/*.png $(obj-websup)/figs
143 cp -f ../web/icons/*.png $(obj-websup)/figs
145 web: websup
147 valid: .validated-00book.xml
149 .validated-00book.xml: $(xml-src-files)
150 $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
151 touch $@
153 # Produce 90dpi PNGs for the web.
155 %.png: %.svg fixsvg
156 ./fixsvg $<
157 inkscape -D -e $@ $<-tmp.svg
158 rm $<-tmp.svg
160 %.svg: %.dot
161 dot -Tsvg -o $@ $<
163 examples: $(example-prereqs) examples/.run
165 examples/.run: $(example-sources:%=examples/%.run)
166 touch examples/.run
168 examples/%.run: examples/% examples/run-example
169 cd examples && ./run-example $(notdir $<)
171 clean:
172 -rm -rf dist html $(image-dot:%.dot=%.pdf) $(image-dot:%.dot=%.png) \
173 $(image-svg:%.svg=%.png) examples/*.{lxo,run} examples/.run
175 install: html $(dist-sources)
176 rm -rf dist
177 mkdir -p dist
178 cp html/*.{css,html,png} dist
179 cp $(dist-sources) dist
181 rsync: install
182 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook
184 vpath %.css ../web
185 vpath %.js ../web/javascript
187 $(obj-websup)/%.css: %.css
188 @mkdir -p $(dir $@)
189 cp $< $@
191 $(obj-websup)/%.jpg: %.jpg
192 @mkdir -p $(dir $@)
193 cp $< $@
195 $(obj-websup)/%.js: %.js
196 @mkdir -p $(dir $@)
197 cp $< $@
199 $(obj-web)/%: ../web/%
200 @mkdir -p $(dir $@)
201 cp $< $@
203 $(obj-web)/%.html: %.html.in
204 @mkdir -p $(dir $@)
205 python ../web/texpand.py $< $@
207 %.gz: %
208 gzip -9 -c $< > $@