hgbook
view en/Makefile @ 171:8c1703a98266
Add a dependency on htlatex to HTML targets, even though we don't call it.
If the files it ships with aren't present, we can't build HTML.
If the files it ships with aren't present, we can't build HTML.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Mon Mar 26 23:57:58 2007 -0700 (2007-03-26) |
parents | 9cd856b4bd21 |
children | 5f305adeb584 |
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 htlatex := /usr/bin/htlatex
115 onepage: $(htlatex) html/onepage/hgbook.html
117 split: $(htlatex) html/split/hgbook.html
119 # This is a horrible hack to work around the fact that the htlatex
120 # command in tex4ht is itself a horrible hack. I really don't want to
121 # include verbatim the big wad of TeX that is repeated in that script,
122 # but I've given up and run a hacked copy as htlatex.book here.
124 define htlatex
125 mkdir -p $(dir $(1))
126 cp 99book.bib $(dir $(1))
127 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
128 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
129 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
130 ./fixhtml.py $(dir $(1))/*.html
131 endef
133 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
135 html/onepage/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
136 $(call htlatex,$@,$<)
137 cp $(image-sources:%.svg=%.png) $(dir $@)
138 cp hgbook.css $(dir $@)
140 html/split/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
141 $(call htlatex,$@,$<,2)
142 cp $(image-sources:%.svg=%.png) $(dir $@)
143 cp hgbook.css $(dir $@)
145 # Produce 90dpi PNGs for the web.
147 %.png: %.svg
148 inkscape -D -e $@ $<
150 %.svg: %.dot
151 dot -Tsvg -o $@ $<
153 # Produce eps & pdf for the pdf
155 %.pdf: %.eps
156 epstopdf $<
158 %.eps: %.svg
159 inkscape -E $@ $<
161 %.eps: %.dot
162 dot -Tps -o $@ $<
164 examples: examples/.run
166 examples/.run: $(example-sources:%=examples/%.run)
167 touch examples/.run
169 examples/%.run: examples/% examples/run-example
170 cd examples && ./run-example $(notdir $<)
172 build_id.tex: $(wildcard ../.hg/00changelog.[id])
173 echo -n $(hg_id) > build_id.tex
175 clean:
176 rm -rf dist html pdf \
177 $(image-dot:%.dot=%.pdf) \
178 $(image-dot:%.dot=%.png) \
179 $(image-svg:%.svg=%.pdf) \
180 $(image-svg:%.svg=%.png) \
181 examples/*.{lxo,run} examples/.run build_id.tex
183 install: pdf split $(dist-sources)
184 rm -rf dist
185 mkdir -p dist
186 cp pdf/hgbook.pdf dist
187 cp html/split/*.{css,html,png} dist
188 cp $(dist-sources) dist
190 rsync: install
191 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook