hgbook

view en/Makefile @ 550:5cd47f721686

Rename LaTeX input files to have numeric prefixes
author Bryan O'Sullivan <bos@serpentine.com>
date Thu Jan 29 22:56:27 2009 -0800 (2009-01-29)
parents 4d2fb4251217
children 8631da51309b
line source
1 # This makefile requires GNU make.
3 sources := \
4 00book.tex \
5 99book.bib \
6 99defs.tex \
7 app*.tex \
8 ch*.tex
10 image-sources := \
11 feature-branches.dot \
12 filelog.svg \
13 kdiff3.png \
14 metadata.svg \
15 mq-stack.svg \
16 note.png \
17 revlog.svg \
18 snapshot.svg \
19 tour-history.svg \
20 tour-merge-conflict.svg \
21 tour-merge-merge.svg \
22 tour-merge-pull.svg \
23 tour-merge-sep-repos.svg \
24 undo-manual.dot \
25 undo-manual-merge.dot \
26 undo-non-tip.dot \
27 undo-simple.dot \
28 wdir.svg \
29 wdir-after-commit.svg \
30 wdir-branch.svg \
31 wdir-merge.svg \
32 wdir-pre-branch.svg
34 image-dot := $(filter %.dot,$(image-sources))
35 image-svg := $(filter %.svg,$(image-sources))
36 image-png := $(filter %.png,$(image-sources))
38 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
39 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
41 example-sources := \
42 backout \
43 bisect \
44 branching \
45 branch-named \
46 branch-repo \
47 cmdref \
48 daily.copy \
49 daily.files \
50 daily.rename \
51 daily.revert \
52 extdiff \
53 filenames \
54 hook.msglen \
55 hook.simple \
56 hook.ws \
57 issue29 \
58 mq.guards \
59 mq.qinit-help \
60 mq.dodiff \
61 mq.id \
62 mq.tarball \
63 mq.tools \
64 mq.tutorial \
65 rename.divergent \
66 rollback \
67 tag \
68 template.simple \
69 template.svnstyle \
70 tour \
71 tour-merge-conflict
73 example-prereqs := \
74 /usr/bin/merge
76 dist-sources := \
77 ../html/hgicon.png \
78 ../html/index.html.var \
79 ../html/index.en.html
81 latex-options = \
82 -interaction batchmode \
83 -output-directory $(dir $(1)) \
84 -jobname $(basename $(notdir $(1)))
86 hg = $(shell which hg)
88 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
90 hg-version = $(shell hg version -q | \
91 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
93 all: pdf html
95 pdf: pdf/hgbook.pdf
97 define pdf
98 mkdir -p $(dir $@)
99 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
100 cp 99book.bib $(dir $@)
101 cd $(dir $@) && bibtex $(basename $(notdir $@))
102 cd $(dir $@) && makeindex $(basename $(notdir $@))
103 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
104 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
105 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
106 endef
108 pdf/hgbook.pdf: $(sources) examples $(image-pdf)
109 $(call pdf)
111 html: onepage split
113 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
115 html/onepage/%: %
116 cp $< $@
118 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
120 html/split/%: %
121 cp $< $@
123 # This is a horrible hack to work around the fact that the htlatex
124 # command in tex4ht is itself a horrible hack. I really don't want to
125 # include verbatim the big wad of TeX that is repeated in that script,
126 # but I've given up and run a hacked copy as htlatex.book here.
128 define htlatex
129 mkdir -p $(dir $(1))
130 cp 99book.bib $(dir $(1))
131 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(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 rm $(dir $(1))/hgbook.css
136 endef
138 html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg
139 $(call htlatex,$@,$<)
141 html/split/hgbook.html: $(sources) examples bookhtml.cfg
142 $(call htlatex,$@,$<,2)
144 # Produce 90dpi PNGs for the web.
146 %.png: %.svg fixsvg
147 ./fixsvg $<
148 inkscape -D -e $@ $<-tmp.svg
149 rm $<-tmp.svg
151 %.svg: %.dot
152 dot -Tsvg -o $@ $<
154 # Produce eps & pdf for the pdf
156 %.pdf: %.eps
157 epstopdf $<
159 %.eps: %.svg
160 ./fixsvg $<
161 inkscape -E $@ $<-tmp.svg
162 rm $<-tmp.svg
164 %.eps: %.dot
165 dot -Tps -o $@ $<
167 examples: $(example-prereqs) examples/.run
169 examples/.run: $(example-sources:%=examples/%.run)
170 touch examples/.run
172 examples/%.run: examples/% examples/run-example
173 cd examples && ./run-example $(notdir $<)
175 changelog := $(wildcard ../.hg/store/00changelog.[id])
176 ifeq ($(changelog),)
177 changelog := $(wildcard ../.hg/00changelog.[id])
178 endif
180 build_id.tex: $(changelog)
181 echo -n '$(hg-id)' > build_id.tex
183 hg_id.tex: $(hg)
184 echo -n '$(hg-version)' > hg_id.tex
186 clean:
187 rm -rf dist html pdf \
188 $(image-dot:%.dot=%.pdf) \
189 $(image-dot:%.dot=%.png) \
190 $(image-svg:%.svg=%.pdf) \
191 $(image-svg:%.svg=%.png) \
192 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
194 install: pdf split $(dist-sources)
195 rm -rf dist
196 mkdir -p dist
197 cp pdf/hgbook.pdf dist
198 cp html/split/*.{css,html,png} dist
199 cp $(dist-sources) dist
201 rsync: install
202 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook