hgbook

view en/Makefile @ 156:91a936be78b8

Document merge behaviour with file names.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Mar 12 23:11:26 2007 -0700 (2007-03-12)
parents cf24633b8de7
children e49f4451d0e3
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 concepts.tex \
12 daily.tex \
13 filenames.tex \
14 hook.tex \
15 intro.tex \
16 mq.tex \
17 mq-collab.tex \
18 mq-ref.tex \
19 preface.tex \
20 srcinstall.tex \
21 template.tex \
22 tour-basic.tex \
23 tour-merge.tex \
24 undo.tex
26 image-sources := \
27 filelog.svg \
28 kdiff3.png \
29 metadata.svg \
30 mq-stack.svg \
31 note.png \
32 revlog.svg \
33 snapshot.svg \
34 tour-history.svg \
35 tour-merge-conflict.svg \
36 tour-merge-merge.svg \
37 tour-merge-pull.svg \
38 tour-merge-sep-repos.svg \
39 undo-manual.dot \
40 undo-manual-merge.dot \
41 undo-non-tip.dot \
42 undo-simple.dot \
43 wdir.svg \
44 wdir-after-commit.svg \
45 wdir-branch.svg \
46 wdir-merge.svg \
47 wdir-pre-branch.svg
49 image-dot := $(filter %.dot,$(image-sources))
50 image-svg := $(filter %.svg,$(image-sources))
51 image-png := $(filter %.png,$(image-sources))
53 example-sources := \
54 backout \
55 bisect \
56 cmdref \
57 daily.copy \
58 daily.files \
59 daily.rename \
60 daily.revert \
61 filenames \
62 hook.msglen \
63 hook.simple \
64 hook.ws \
65 issue29 \
66 mq.guards \
67 mq.qinit-help \
68 mq.dodiff \
69 mq.id \
70 mq.tarball \
71 mq.tools \
72 mq.tutorial \
73 rename.divergent \
74 rollback \
75 template.simple \
76 template.svnstyle \
77 tour \
78 tour-merge-conflict
80 latex-options = \
81 -interaction batchmode \
82 -output-directory $(dir $(1)) \
83 -jobname $(basename $(notdir $(1)))
85 all: pdf html
87 pdf: pdf/hgbook.pdf
89 define pdf
90 mkdir -p $(dir $@)
91 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
92 cp 99book.bib $(dir $@)
93 cd $(dir $@) && bibtex $(basename $(notdir $@))
94 cd $(dir $@) && makeindex $(basename $(notdir $@))
95 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
96 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
97 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
98 endef
100 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
102 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
103 $(call pdf)
105 html: onepage split
107 onepage: html/onepage/hgbook.html
109 split: html/split/hgbook.html
111 # This is a horrible hack to work around the fact that the htlatex
112 # command in tex4ht is itself a horrible hack. I really don't want to
113 # include verbatim the big wad of TeX that is repeated in that script,
114 # so instead I mangle the script itself.
116 define htlatex
117 mkdir -p $(dir $(1))
118 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
119 cp 99book.bib $(dir $@)
120 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
121 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
122 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
123 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
124 chmod 755 $(dir $(1))/htlatex.book
125 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(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
182 rm -rf dist
183 mkdir -p dist
184 cp pdf/hgbook.pdf dist
185 cp html/split/*.{css,html,png} dist
187 rsync: install
188 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook