hgbook

view en/Makefile @ 170:9cd856b4bd21

Try to make HTML build a bit more portable.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Mar 26 23:55:21 2007 -0700 (2007-03-26)
parents 7355af913937
children 8c1703a98266
line source
1 # This makefile requires GNU make.
3 hg_id := $(shell hg parents --template '{node|short}\n')
5 sources := \
6 00book.tex \
7 99book.bib \
8 99defs.tex \
9 build_id.tex \
10 cmdref.tex \
11 collab.tex \
12 concepts.tex \
13 daily.tex \
14 filenames.tex \
15 hook.tex \
16 intro.tex \
17 mq.tex \
18 mq-collab.tex \
19 mq-ref.tex \
20 preface.tex \
21 srcinstall.tex \
22 template.tex \
23 tour-basic.tex \
24 tour-merge.tex \
25 undo.tex
27 image-sources := \
28 filelog.svg \
29 kdiff3.png \
30 metadata.svg \
31 mq-stack.svg \
32 note.png \
33 revlog.svg \
34 snapshot.svg \
35 tour-history.svg \
36 tour-merge-conflict.svg \
37 tour-merge-merge.svg \
38 tour-merge-pull.svg \
39 tour-merge-sep-repos.svg \
40 undo-manual.dot \
41 undo-manual-merge.dot \
42 undo-non-tip.dot \
43 undo-simple.dot \
44 wdir.svg \
45 wdir-after-commit.svg \
46 wdir-branch.svg \
47 wdir-merge.svg \
48 wdir-pre-branch.svg
50 image-dot := $(filter %.dot,$(image-sources))
51 image-svg := $(filter %.svg,$(image-sources))
52 image-png := $(filter %.png,$(image-sources))
54 example-sources := \
55 backout \
56 bisect \
57 cmdref \
58 daily.copy \
59 daily.files \
60 daily.rename \
61 daily.revert \
62 filenames \
63 hook.msglen \
64 hook.simple \
65 hook.ws \
66 issue29 \
67 mq.guards \
68 mq.qinit-help \
69 mq.dodiff \
70 mq.id \
71 mq.tarball \
72 mq.tools \
73 mq.tutorial \
74 rename.divergent \
75 rollback \
76 template.simple \
77 template.svnstyle \
78 tour \
79 tour-merge-conflict
81 dist-sources := \
82 ../html/hgicon.png \
83 ../html/index.html.var \
84 ../html/index.en.html
86 latex-options = \
87 -interaction batchmode \
88 -output-directory $(dir $(1)) \
89 -jobname $(basename $(notdir $(1)))
91 all: pdf html
93 pdf: pdf/hgbook.pdf
95 define pdf
96 mkdir -p $(dir $@)
97 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
98 cp 99book.bib $(dir $@)
99 cd $(dir $@) && bibtex $(basename $(notdir $@))
100 cd $(dir $@) && makeindex $(basename $(notdir $@))
101 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
102 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
103 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
104 endef
106 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
108 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
109 $(call pdf)
111 html: onepage split
113 onepage: html/onepage/hgbook.html
115 split: html/split/hgbook.html
117 # This is a horrible hack to work around the fact that the htlatex
118 # command in tex4ht is itself a horrible hack. I really don't want to
119 # include verbatim the big wad of TeX that is repeated in that script,
120 # so instead I mangle the script itself.
122 define htlatex
123 mkdir -p $(dir $(1))
124 cp 99book.bib $(dir $(1))
125 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
126 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
127 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
128 ./fixhtml.py $(dir $(1))/*.html
129 endef
131 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
133 html/onepage/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
134 $(call htlatex,$@,$<)
135 cp $(image-sources:%.svg=%.png) $(dir $@)
136 cp hgbook.css $(dir $@)
138 html/split/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
139 $(call htlatex,$@,$<,2)
140 cp $(image-sources:%.svg=%.png) $(dir $@)
141 cp hgbook.css $(dir $@)
143 # Produce 90dpi PNGs for the web.
145 %.png: %.svg
146 inkscape -D -e $@ $<
148 %.svg: %.dot
149 dot -Tsvg -o $@ $<
151 # Produce eps & pdf for the pdf
153 %.pdf: %.eps
154 epstopdf $<
156 %.eps: %.svg
157 inkscape -E $@ $<
159 %.eps: %.dot
160 dot -Tps -o $@ $<
162 examples: examples/.run
164 examples/.run: $(example-sources:%=examples/%.run)
165 touch examples/.run
167 examples/%.run: examples/% examples/run-example
168 cd examples && ./run-example $(notdir $<)
170 build_id.tex: $(wildcard ../.hg/00changelog.[id])
171 echo -n $(hg_id) > build_id.tex
173 clean:
174 rm -rf dist html pdf \
175 $(image-dot:%.dot=%.pdf) \
176 $(image-dot:%.dot=%.png) \
177 $(image-svg:%.svg=%.pdf) \
178 $(image-svg:%.svg=%.png) \
179 examples/*.{lxo,run} examples/.run build_id.tex
181 install: pdf split $(dist-sources)
182 rm -rf dist
183 mkdir -p dist
184 cp pdf/hgbook.pdf dist
185 cp html/split/*.{css,html,png} dist
186 cp $(dist-sources) dist
188 rsync: install
189 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook