hgbook

view en/Makefile @ 213:18cffee85038

Fix build of HTML pages with PNG images.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed May 09 15:17:10 2007 -0700 (2007-05-09)
parents 6f167e644762
children 154e4ba293e7
line source
1 # This makefile requires GNU make.
3 sources := \
4 00book.tex \
5 99book.bib \
6 99defs.tex \
7 build_id.tex \
8 branch.tex \
9 cmdref.tex \
10 collab.tex \
11 concepts.tex \
12 daily.tex \
13 filenames.tex \
14 hg_id.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 feature-branches.dot \
29 filelog.svg \
30 kdiff3.png \
31 metadata.svg \
32 mq-stack.svg \
33 note.png \
34 revlog.svg \
35 snapshot.svg \
36 tour-history.svg \
37 tour-merge-conflict.svg \
38 tour-merge-merge.svg \
39 tour-merge-pull.svg \
40 tour-merge-sep-repos.svg \
41 undo-manual.dot \
42 undo-manual-merge.dot \
43 undo-non-tip.dot \
44 undo-simple.dot \
45 wdir.svg \
46 wdir-after-commit.svg \
47 wdir-branch.svg \
48 wdir-merge.svg \
49 wdir-pre-branch.svg
51 image-dot := $(filter %.dot,$(image-sources))
52 image-svg := $(filter %.svg,$(image-sources))
53 image-png := $(filter %.png,$(image-sources))
55 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
56 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
58 example-sources := \
59 backout \
60 bisect \
61 branching \
62 branch-named \
63 branch-repo \
64 cmdref \
65 daily.copy \
66 daily.files \
67 daily.rename \
68 daily.revert \
69 filenames \
70 hook.msglen \
71 hook.simple \
72 hook.ws \
73 issue29 \
74 mq.guards \
75 mq.qinit-help \
76 mq.dodiff \
77 mq.id \
78 mq.tarball \
79 mq.tools \
80 mq.tutorial \
81 rename.divergent \
82 rollback \
83 tag \
84 template.simple \
85 template.svnstyle \
86 tour \
87 tour-merge-conflict
89 example-prereqs := \
90 /usr/bin/merge
92 dist-sources := \
93 ../html/hgicon.png \
94 ../html/index.html.var \
95 ../html/index.en.html
97 latex-options = \
98 -interaction batchmode \
99 -output-directory $(dir $(1)) \
100 -jobname $(basename $(notdir $(1)))
102 hg = $(shell which hg)
104 hg-id = $(shell hg parents --template '{node|short} \(dated {date|isodate}\)\n')
106 hg-version = $(shell hg version -q | \
107 sed 's,.*(version \(unknown\|[a-f0-9]*\)),\1,')
109 all: pdf html
111 pdf: pdf/hgbook.pdf
113 define pdf
114 mkdir -p $(dir $@)
115 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
116 cp 99book.bib $(dir $@)
117 cd $(dir $@) && bibtex $(basename $(notdir $@))
118 cd $(dir $@) && makeindex $(basename $(notdir $@))
119 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
120 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
121 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
122 endef
124 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
125 $(call pdf)
127 html: onepage split
129 htlatex := /usr/bin/htlatex
131 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
133 html/onepage/%: %
134 cp $< $@
136 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
138 html/split/%: %
139 cp $< $@
141 # This is a horrible hack to work around the fact that the htlatex
142 # command in tex4ht is itself a horrible hack. I really don't want to
143 # include verbatim the big wad of TeX that is repeated in that script,
144 # but I've given up and run a hacked copy as htlatex.book here.
146 define htlatex
147 mkdir -p $(dir $(1))
148 cp 99book.bib $(dir $(1))
149 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
150 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
151 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
152 ./fixhtml.py $(dir $(1))/*.html
153 endef
155 html/onepage/hgbook.html: $(sources) $(image-html) examples bookhtml.cfg
156 $(call htlatex,$@,$<)
158 html/split/hgbook.html: $(sources) examples bookhtml.cfg
159 $(call htlatex,$@,$<,2)
161 # Produce 90dpi PNGs for the web.
163 %.png: %.svg
164 inkscape -D -e $@ $<
166 %.svg: %.dot
167 dot -Tsvg -o $@ $<
169 # Produce eps & pdf for the pdf
171 %.pdf: %.eps
172 epstopdf $<
174 %.eps: %.svg
175 inkscape -E $@ $<
177 %.eps: %.dot
178 dot -Tps -o $@ $<
180 examples: $(example-prereqs) examples/.run
182 examples/.run: $(example-sources:%=examples/%.run)
183 touch examples/.run
185 examples/%.run: examples/% examples/run-example
186 cd examples && ./run-example $(notdir $<)
188 build_id.tex: $(wildcard ../.hg/00changelog.[id])
189 echo -n $(hg-id) > build_id.tex
191 hg_id.tex: $(hg)
192 echo -n $(hg-version) > hg_id.tex
194 clean:
195 rm -rf dist html pdf \
196 $(image-dot:%.dot=%.pdf) \
197 $(image-dot:%.dot=%.png) \
198 $(image-svg:%.svg=%.pdf) \
199 $(image-svg:%.svg=%.png) \
200 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
202 install: pdf split $(dist-sources)
203 rm -rf dist
204 mkdir -p dist
205 cp pdf/hgbook.pdf dist
206 cp html/split/*.{css,html,png} dist
207 cp $(dist-sources) dist
209 rsync: install
210 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook