hgbook

view en/Makefile @ 559:b90b024729f1

WIP DocBook snapshot that all compiles. Mirabile dictu!
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Feb 18 00:22:09 2009 -0800 (2009-02-18)
parents 8631da51309b
children 27043f385f3f
line source
1 # This makefile requires GNU make.
3 sources := \
4 00book.tex \
5 99book.bib \
6 99defs.tex \
7 app*.tex \
8 ch*.tex
10 image-sources := \
11 feature-branches.dot \
12 filelog.svg \
13 kdiff3.png \
14 metadata.svg \
15 mq-stack.svg \
16 note.png \
17 revlog.svg \
18 snapshot.svg \
19 tour-history.svg \
20 tour-merge-conflict.svg \
21 tour-merge-merge.svg \
22 tour-merge-pull.svg \
23 tour-merge-sep-repos.svg \
24 undo-manual.dot \
25 undo-manual-merge.dot \
26 undo-non-tip.dot \
27 undo-simple.dot \
28 wdir.svg \
29 wdir-after-commit.svg \
30 wdir-branch.svg \
31 wdir-merge.svg \
32 wdir-pre-branch.svg
34 xml-src-files := \
35 00book.xml \
36 app*.xml \
37 ch*.xml
39 image-dot := $(filter %.dot,$(image-sources))
40 image-svg := $(filter %.svg,$(image-sources))
41 image-png := $(filter %.png,$(image-sources))
43 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
44 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
46 example-sources := \
47 backout \
48 bisect \
49 branching \
50 branch-named \
51 branch-repo \
52 cmdref \
53 daily.copy \
54 daily.files \
55 daily.rename \
56 daily.revert \
57 extdiff \
58 filenames \
59 hook.msglen \
60 hook.simple \
61 hook.ws \
62 issue29 \
63 mq.guards \
64 mq.qinit-help \
65 mq.dodiff \
66 mq.id \
67 mq.tarball \
68 mq.tools \
69 mq.tutorial \
70 rename.divergent \
71 rollback \
72 tag \
73 template.simple \
74 template.svnstyle \
75 tour \
76 tour-merge-conflict
78 xsltproc := xsltproc
79 xsltproc-opts := --nonet --xinclude --path '$(xml-path)'
81 xmllint := xmllint
82 xmllint-opts := --noout --nonet --valid
84 system-xsl-dir := $(firstword $(wildcard \
85 /usr/share/sgml/docbook/xsl-stylesheets \
86 /usr/share/xml/docbook/stylesheet/nwalsh \
87 ))
89 # Bletcherousness.
91 ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),)
92 dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*)
93 else
94 ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),)
95 dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4)
96 else
97 $(error Do not know where to look for DocBook XML 4.4 DTD)
98 endif
99 endif
101 ifeq ($(system-xsl-dir),)
102 $(error add a suitable directory to system-xsl-dir)
103 endif
105 example-prereqs := \
106 /usr/bin/merge
108 dist-sources := \
109 ../html/hgicon.png \
110 ../html/index.html.var \
111 ../html/index.en.html
113 latex-options = \
114 -interaction batchmode \
115 -output-directory $(dir $(1)) \
116 -jobname $(basename $(notdir $(1)))
118 hg = $(shell which hg)
120 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
122 hg-version = $(shell hg version -q | \
123 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
125 all: pdf html
127 pdf: pdf/hgbook.pdf
129 define pdf
130 mkdir -p $(dir $@)
131 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
132 cp 99book.bib $(dir $@)
133 cd $(dir $@) && bibtex $(basename $(notdir $@))
134 cd $(dir $@) && makeindex $(basename $(notdir $@))
135 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
136 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
137 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
138 endef
140 pdf/hgbook.pdf: $(sources) examples $(image-pdf)
141 $(call pdf)
143 html: onepage split
145 ../xsl/system-xsl: $(system-xsl-dir)
146 ln -s $< $@
148 dbhtml: ../xsl/system-xsl $(xml-src-files) valid
149 xsltproc $(xsltproc-opts) ../xsl/chunk-stylesheet.xsl 00book.xml
151 valid: .validated-00book.xml
153 .validated-00book.xml: $(xml-src-files)
154 $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
155 touch $@
157 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
159 html/onepage/%: %
160 cp $< $@
162 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
164 html/split/%: %
165 cp $< $@
167 # This is a horrible hack to work around the fact that the htlatex
168 # command in tex4ht is itself a horrible hack. I really don't want to
169 # include verbatim the big wad of TeX that is repeated in that script,
170 # but I've given up and run a hacked copy as htlatex.book here.
172 define htlatex
173 mkdir -p $(dir $(1))
174 cp 99book.bib $(dir $(1))
175 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
176 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
177 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
178 ./fixhtml.py $(dir $(1))/*.html
179 rm $(dir $(1))/hgbook.css
180 endef
182 html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg
183 $(call htlatex,$@,$<)
185 html/split/hgbook.html: $(sources) examples bookhtml.cfg
186 $(call htlatex,$@,$<,2)
188 # Produce 90dpi PNGs for the web.
190 %.png: %.svg fixsvg
191 ./fixsvg $<
192 inkscape -D -e $@ $<-tmp.svg
193 rm $<-tmp.svg
195 %.svg: %.dot
196 dot -Tsvg -o $@ $<
198 # Produce eps & pdf for the pdf
200 %.pdf: %.eps
201 epstopdf $<
203 %.eps: %.svg
204 ./fixsvg $<
205 inkscape -E $@ $<-tmp.svg
206 rm $<-tmp.svg
208 %.eps: %.dot
209 dot -Tps -o $@ $<
211 examples: $(example-prereqs) examples/.run
213 examples/.run: $(example-sources:%=examples/%.run)
214 touch examples/.run
216 examples/%.run: examples/% examples/run-example
217 cd examples && ./run-example $(notdir $<)
219 changelog := $(wildcard ../.hg/store/00changelog.[id])
220 ifeq ($(changelog),)
221 changelog := $(wildcard ../.hg/00changelog.[id])
222 endif
224 build_id.tex: $(changelog)
225 echo -n '$(hg-id)' > build_id.tex
227 hg_id.tex: $(hg)
228 echo -n '$(hg-version)' > hg_id.tex
230 clean:
231 rm -rf dist html pdf \
232 $(image-dot:%.dot=%.pdf) \
233 $(image-dot:%.dot=%.png) \
234 $(image-svg:%.svg=%.pdf) \
235 $(image-svg:%.svg=%.png) \
236 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
238 install: pdf split $(dist-sources)
239 rm -rf dist
240 mkdir -p dist
241 cp pdf/hgbook.pdf dist
242 cp html/split/*.{css,html,png} dist
243 cp $(dist-sources) dist
245 rsync: install
246 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook