hgbook

view en/Makefile @ 195:959357d01607

Merge with myself.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Apr 16 14:43:23 2007 -0700 (2007-04-16)
parents b60e2de6dbc3 404e7951dd04
children 4237e45506ee
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 example-sources := \
56 backout \
57 bisect \
58 branching \
59 cmdref \
60 daily.copy \
61 daily.files \
62 daily.rename \
63 daily.revert \
64 filenames \
65 hook.msglen \
66 hook.simple \
67 hook.ws \
68 issue29 \
69 mq.guards \
70 mq.qinit-help \
71 mq.dodiff \
72 mq.id \
73 mq.tarball \
74 mq.tools \
75 mq.tutorial \
76 rename.divergent \
77 rollback \
78 template.simple \
79 template.svnstyle \
80 tour \
81 tour-merge-conflict
83 example-prereqs := \
84 /usr/bin/merge
86 dist-sources := \
87 ../html/hgicon.png \
88 ../html/index.html.var \
89 ../html/index.en.html
91 latex-options = \
92 -interaction batchmode \
93 -output-directory $(dir $(1)) \
94 -jobname $(basename $(notdir $(1)))
96 hg = $(shell which hg)
98 hg-id = $(shell hg parents --template '{node|short} \(dated {date|isodate}\)\n')
100 hg-version = $(shell hg version -q | \
101 sed 's,.*(version \(unknown\|[a-f0-9]*\)),\1,')
103 all: pdf html
105 pdf: pdf/hgbook.pdf
107 define pdf
108 mkdir -p $(dir $@)
109 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
110 cp 99book.bib $(dir $@)
111 cd $(dir $@) && bibtex $(basename $(notdir $@))
112 cd $(dir $@) && makeindex $(basename $(notdir $@))
113 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
114 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
115 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
116 endef
118 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
120 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
121 $(call pdf)
123 html: onepage split
125 htlatex := /usr/bin/htlatex
127 onepage: $(htlatex) html/onepage/hgbook.html
129 split: $(htlatex) html/split/hgbook.html
131 # This is a horrible hack to work around the fact that the htlatex
132 # command in tex4ht is itself a horrible hack. I really don't want to
133 # include verbatim the big wad of TeX that is repeated in that script,
134 # but I've given up and run a hacked copy as htlatex.book here.
136 define htlatex
137 mkdir -p $(dir $(1))
138 cp 99book.bib $(dir $(1))
139 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
140 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
141 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
142 ./fixhtml.py $(dir $(1))/*.html
143 endef
145 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
147 html/onepage/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
148 $(call htlatex,$@,$<)
149 cp $(image-sources:%.svg=%.png) $(dir $@)
150 cp hgbook.css $(dir $@)
152 html/split/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
153 $(call htlatex,$@,$<,2)
154 cp $(image-sources:%.svg=%.png) $(dir $@)
155 cp hgbook.css $(dir $@)
157 # Produce 90dpi PNGs for the web.
159 %.png: %.svg
160 inkscape -D -e $@ $<
162 %.svg: %.dot
163 dot -Tsvg -o $@ $<
165 # Produce eps & pdf for the pdf
167 %.pdf: %.eps
168 epstopdf $<
170 %.eps: %.svg
171 inkscape -E $@ $<
173 %.eps: %.dot
174 dot -Tps -o $@ $<
176 examples: $(example-prereqs) examples/.run
178 examples/.run: $(example-sources:%=examples/%.run)
179 touch examples/.run
181 examples/%.run: examples/% examples/run-example
182 cd examples && ./run-example $(notdir $<)
184 build_id.tex: $(wildcard ../.hg/00changelog.[id])
185 echo -n $(hg-id) > build_id.tex
187 hg_id.tex: $(hg)
188 echo -n $(hg-version) > hg_id.tex
190 clean:
191 rm -rf dist html pdf \
192 $(image-dot:%.dot=%.pdf) \
193 $(image-dot:%.dot=%.png) \
194 $(image-svg:%.svg=%.pdf) \
195 $(image-svg:%.svg=%.png) \
196 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
198 install: pdf split $(dist-sources)
199 rm -rf dist
200 mkdir -p dist
201 cp pdf/hgbook.pdf dist
202 cp html/split/*.{css,html,png} dist
203 cp $(dist-sources) dist
205 rsync: install
206 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook