hgbook

view en/Makefile @ 558:8631da51309b

Slow progress on XML conversion
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Feb 09 23:25:40 2009 -0800 (2009-02-09)
parents 5cd47f721686
children b90b024729f1
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 ch01-intro.xml \
37 ch02-tour-basic.xml \
38 ch12-mq.xml
40 image-dot := $(filter %.dot,$(image-sources))
41 image-svg := $(filter %.svg,$(image-sources))
42 image-png := $(filter %.png,$(image-sources))
44 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
45 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
47 example-sources := \
48 backout \
49 bisect \
50 branching \
51 branch-named \
52 branch-repo \
53 cmdref \
54 daily.copy \
55 daily.files \
56 daily.rename \
57 daily.revert \
58 extdiff \
59 filenames \
60 hook.msglen \
61 hook.simple \
62 hook.ws \
63 issue29 \
64 mq.guards \
65 mq.qinit-help \
66 mq.dodiff \
67 mq.id \
68 mq.tarball \
69 mq.tools \
70 mq.tutorial \
71 rename.divergent \
72 rollback \
73 tag \
74 template.simple \
75 template.svnstyle \
76 tour \
77 tour-merge-conflict
79 xsltproc := xsltproc
80 xsltproc-opts := --nonet --xinclude --path '$(xml-path)'
82 xmllint := xmllint
83 xmllint-opts := --noout --nonet --valid
85 system-xsl-dir := $(firstword $(wildcard \
86 /usr/share/sgml/docbook/xsl-stylesheets \
87 /usr/share/xml/docbook/stylesheet/nwalsh \
88 ))
90 # Bletcherousness.
92 ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),)
93 dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*)
94 else
95 ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),)
96 dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4)
97 else
98 $(error Do not know where to look for DocBook XML 4.4 DTD)
99 endif
100 endif
102 ifeq ($(system-xsl-dir),)
103 $(error add a suitable directory to system-xsl-dir)
104 endif
106 example-prereqs := \
107 /usr/bin/merge
109 dist-sources := \
110 ../html/hgicon.png \
111 ../html/index.html.var \
112 ../html/index.en.html
114 latex-options = \
115 -interaction batchmode \
116 -output-directory $(dir $(1)) \
117 -jobname $(basename $(notdir $(1)))
119 hg = $(shell which hg)
121 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
123 hg-version = $(shell hg version -q | \
124 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
126 all: pdf html
128 pdf: pdf/hgbook.pdf
130 define pdf
131 mkdir -p $(dir $@)
132 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
133 cp 99book.bib $(dir $@)
134 cd $(dir $@) && bibtex $(basename $(notdir $@))
135 cd $(dir $@) && makeindex $(basename $(notdir $@))
136 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
137 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
138 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
139 endef
141 pdf/hgbook.pdf: $(sources) examples $(image-pdf)
142 $(call pdf)
144 html: onepage split
146 ../xsl/system-xsl: $(system-xsl-dir)
147 ln -s $< $@
149 dbhtml: ../xsl/system-xsl $(xml-src-files) valid
150 xsltproc $(xsltproc-opts) ../xsl/chunk-stylesheet.xsl 00book.xml
152 valid: .validated-00book.xml
154 .validated-00book.xml: $(xml-src-files)
155 $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
156 touch $@
158 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
160 html/onepage/%: %
161 cp $< $@
163 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
165 html/split/%: %
166 cp $< $@
168 # This is a horrible hack to work around the fact that the htlatex
169 # command in tex4ht is itself a horrible hack. I really don't want to
170 # include verbatim the big wad of TeX that is repeated in that script,
171 # but I've given up and run a hacked copy as htlatex.book here.
173 define htlatex
174 mkdir -p $(dir $(1))
175 cp 99book.bib $(dir $(1))
176 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
177 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
178 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
179 ./fixhtml.py $(dir $(1))/*.html
180 rm $(dir $(1))/hgbook.css
181 endef
183 html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg
184 $(call htlatex,$@,$<)
186 html/split/hgbook.html: $(sources) examples bookhtml.cfg
187 $(call htlatex,$@,$<,2)
189 # Produce 90dpi PNGs for the web.
191 %.png: %.svg fixsvg
192 ./fixsvg $<
193 inkscape -D -e $@ $<-tmp.svg
194 rm $<-tmp.svg
196 %.svg: %.dot
197 dot -Tsvg -o $@ $<
199 # Produce eps & pdf for the pdf
201 %.pdf: %.eps
202 epstopdf $<
204 %.eps: %.svg
205 ./fixsvg $<
206 inkscape -E $@ $<-tmp.svg
207 rm $<-tmp.svg
209 %.eps: %.dot
210 dot -Tps -o $@ $<
212 examples: $(example-prereqs) examples/.run
214 examples/.run: $(example-sources:%=examples/%.run)
215 touch examples/.run
217 examples/%.run: examples/% examples/run-example
218 cd examples && ./run-example $(notdir $<)
220 changelog := $(wildcard ../.hg/store/00changelog.[id])
221 ifeq ($(changelog),)
222 changelog := $(wildcard ../.hg/00changelog.[id])
223 endif
225 build_id.tex: $(changelog)
226 echo -n '$(hg-id)' > build_id.tex
228 hg_id.tex: $(hg)
229 echo -n '$(hg-version)' > hg_id.tex
231 clean:
232 rm -rf dist html pdf \
233 $(image-dot:%.dot=%.pdf) \
234 $(image-dot:%.dot=%.png) \
235 $(image-svg:%.svg=%.pdf) \
236 $(image-svg:%.svg=%.png) \
237 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
239 install: pdf split $(dist-sources)
240 rm -rf dist
241 mkdir -p dist
242 cp pdf/hgbook.pdf dist
243 cp html/split/*.{css,html,png} dist
244 cp $(dist-sources) dist
246 rsync: install
247 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook