hgbook

view en/Makefile @ 598:7893b3824715

Add a top-level index page.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri Mar 27 00:01:58 2009 -0700 (2009-03-27)
parents e0a4ba81f888
children 9e8e5292acaa
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 ../xsl/system-xsl: $(system-xsl-dir)
116 ln -s $< $@
118 web: ../xsl/system-xsl websup html
120 html: $(obj-web-read)/index.html
122 $(obj-web-read)/index.html: ../xsl/system-xsl .validated-00book.xml
123 xsltproc $(xsltproc-opts) -o $(obj-web-read)/x ../xsl/chunk-stylesheet.xsl 00book.xml
124 for i in $(obj-web-read)/*.html; do \
125 gzip -9 -c $$i > $$i.gz; \
126 done
128 websup: $(extras-web) $(image-web)
129 mkdir -p $(obj-websup)/figs $(obj-web-read)/figs
130 cp ../xsl/system-xsl/images/*.png $(obj-websup)/figs
131 cp -f ../web/icons/*.png $(obj-websup)/figs
133 all-ids.dat: ../xsl/all-ids.xsl $(xml-src-files)
134 $(xsltproc) $(xsltproc-opts) -o $@ ../xsl/all-ids.xsl 00book.xml
136 web: websup
138 valid: .validated-00book.xml
140 .validated-00book.xml: $(xml-src-files)
141 $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
142 touch $@
144 # Produce 90dpi PNGs for the web.
146 $(obj-web-read)/figs/%.png: $(obj-web-read)/figs/%.svg fixsvg
147 mkdir -p $(dir $@)
148 ./fixsvg $<
149 inkscape -D -e $@ $<-tmp.svg
150 rm $<-tmp.svg
152 $(obj-web-read)/figs/%.png: figs/%.svg fixsvg
153 mkdir -p $(dir $@)
154 ./fixsvg $<
155 inkscape -D -e $@ $<-tmp.svg
156 rm $<-tmp.svg
158 $(obj-web-read)/figs/%.gif: figs/%.gif
159 cp $< $@
161 $(obj-web-read)/figs/%.png: figs/%.png
162 cp $< $@
164 $(obj-web-read)/figs/%.svg: figs/%.dot
165 mkdir -p $(dir $@)
166 dot -Tsvg -o $@ $<
168 examples: $(example-prereqs) examples/.run
170 examples/.run: $(example-sources)
171 cd examples && ./run-example
173 examples/%.run: examples/% examples/run-example
175 clean:
176 -rm -rf dist html $(image-dot:%.dot=%.pdf) $(image-dot:%.dot=%.png) \
177 $(image-svg:%.svg=%.png) examples/*.{lxo,run} examples/.run
179 install: html $(dist-sources)
180 rm -rf dist
181 mkdir -p dist
182 cp html/*.{css,html,png} dist
183 cp $(dist-sources) dist
185 rsync: install
186 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook
188 vpath %.css ../web
189 vpath %.html.in ../web
190 vpath %.js ../web/javascript
192 $(obj-websup)/%.css: %.css
193 @mkdir -p $(dir $@)
194 cp $< $@
196 $(obj-websup)/%.jpg: %.jpg
197 @mkdir -p $(dir $@)
198 cp $< $@
200 $(obj-websup)/%.js: %.js
201 @mkdir -p $(dir $@)
202 cp $< $@
204 $(obj-web)/%: ../web/%
205 @mkdir -p $(dir $@)
206 cp $< $@
208 $(obj-web)/%.html: %.html.in
209 @mkdir -p $(dir $@)
210 python ../web/texpand.py $< $@
212 %.gz: %
213 gzip -9 -c $< > $@