hgbook

view en/Makefile @ 218:75fd236d736b

History of SCM tools.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu May 10 17:21:09 2007 -0700 (2007-05-10)
parents 18cffee85038
children 4c9b9416cd23
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 rm $(dir $(1))/hgbook.css
154 endef
156 html/onepage/hgbook.html: $(sources) $(image-html) examples bookhtml.cfg
157 $(call htlatex,$@,$<)
159 html/split/hgbook.html: $(sources) examples bookhtml.cfg
160 $(call htlatex,$@,$<,2)
162 # Produce 90dpi PNGs for the web.
164 %.png: %.svg
165 inkscape -D -e $@ $<
167 %.svg: %.dot
168 dot -Tsvg -o $@ $<
170 # Produce eps & pdf for the pdf
172 %.pdf: %.eps
173 epstopdf $<
175 %.eps: %.svg
176 inkscape -E $@ $<
178 %.eps: %.dot
179 dot -Tps -o $@ $<
181 examples: $(example-prereqs) examples/.run
183 examples/.run: $(example-sources:%=examples/%.run)
184 touch examples/.run
186 examples/%.run: examples/% examples/run-example
187 cd examples && ./run-example $(notdir $<)
189 build_id.tex: $(wildcard ../.hg/00changelog.[id])
190 echo -n $(hg-id) > build_id.tex
192 hg_id.tex: $(hg)
193 echo -n $(hg-version) > hg_id.tex
195 clean:
196 rm -rf dist html pdf \
197 $(image-dot:%.dot=%.pdf) \
198 $(image-dot:%.dot=%.png) \
199 $(image-svg:%.svg=%.pdf) \
200 $(image-svg:%.svg=%.png) \
201 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
203 install: pdf split $(dist-sources)
204 rm -rf dist
205 mkdir -p dist
206 cp pdf/hgbook.pdf dist
207 cp html/split/*.{css,html,png} dist
208 cp $(dist-sources) dist
210 rsync: install
211 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook