hgbook

view en/Makefile @ 165:06d18465df03

Make an example run more predictably.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Mar 26 22:45:48 2007 -0700 (2007-03-26)
parents e49f4451d0e3
children 9cd856b4bd21
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 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
125 cp 99book.bib $(dir $@)
126 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
127 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
128 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
129 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
130 chmod 755 $(dir $(1))/htlatex.book
131 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
132 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
133 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
134 ./fixhtml.py $(dir $(1))/*.html
135 endef
137 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
139 html/onepage/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
140 $(call htlatex,$@,$<)
141 cp $(image-sources:%.svg=%.png) $(dir $@)
142 cp hgbook.css $(dir $@)
144 html/split/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
145 $(call htlatex,$@,$<,2)
146 cp $(image-sources:%.svg=%.png) $(dir $@)
147 cp hgbook.css $(dir $@)
149 # Produce 90dpi PNGs for the web.
151 %.png: %.svg
152 inkscape -D -e $@ $<
154 %.svg: %.dot
155 dot -Tsvg -o $@ $<
157 # Produce eps & pdf for the pdf
159 %.pdf: %.eps
160 epstopdf $<
162 %.eps: %.svg
163 inkscape -E $@ $<
165 %.eps: %.dot
166 dot -Tps -o $@ $<
168 examples: examples/.run
170 examples/.run: $(example-sources:%=examples/%.run)
171 touch examples/.run
173 examples/%.run: examples/% examples/run-example
174 cd examples && ./run-example $(notdir $<)
176 build_id.tex: $(wildcard ../.hg/00changelog.[id])
177 echo -n $(hg_id) > build_id.tex
179 clean:
180 rm -rf dist html pdf \
181 $(image-dot:%.dot=%.pdf) \
182 $(image-dot:%.dot=%.png) \
183 $(image-svg:%.svg=%.pdf) \
184 $(image-svg:%.svg=%.png) \
185 examples/*.{lxo,run} examples/.run build_id.tex
187 install: pdf split $(dist-sources)
188 rm -rf dist
189 mkdir -p dist
190 cp pdf/hgbook.pdf dist
191 cp html/split/*.{css,html,png} dist
192 cp $(dist-sources) dist
194 rsync: install
195 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook