hgbook

view en/Makefile @ 132:e1e2f3e0256a

Start command reference, with the diff command.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu Dec 28 16:45:56 2006 -0800 (2006-12-28)
parents 153efeaa8f57
children 1e013fbe35f7
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 hook.tex \
14 intro.tex \
15 mq.tex \
16 mq-collab.tex \
17 mq-ref.tex \
18 preface.tex \
19 srcinstall.tex \
20 template.tex \
21 tour-basic.tex \
22 tour-merge.tex \
23 undo.tex
25 image-sources := \
26 filelog.svg \
27 kdiff3.png \
28 metadata.svg \
29 mq-stack.svg \
30 revlog.svg \
31 snapshot.svg \
32 tour-history.svg \
33 tour-merge-conflict.svg \
34 tour-merge-merge.svg \
35 tour-merge-pull.svg \
36 tour-merge-sep-repos.svg \
37 undo-manual.dot \
38 undo-manual-merge.dot \
39 undo-non-tip.dot \
40 undo-simple.dot \
41 wdir.svg \
42 wdir-after-commit.svg \
43 wdir-branch.svg \
44 wdir-merge.svg \
45 wdir-pre-branch.svg
47 image-dot := $(filter %.dot,$(image-sources))
48 image-svg := $(filter %.svg,$(image-sources))
49 image-png := $(filter %.png,$(image-sources))
51 example-sources := \
52 backout \
53 bisect \
54 daily.copy \
55 daily.files \
56 daily.rename \
57 daily.revert \
58 hook.msglen \
59 hook.simple \
60 hook.ws \
61 mq.guards \
62 mq.qinit-help \
63 mq.dodiff \
64 mq.id \
65 mq.tarball \
66 mq.tools \
67 mq.tutorial \
68 rollback \
69 template.simple \
70 template.svnstyle \
71 tour \
72 tour-merge-conflict
74 latex-options = \
75 -interaction batchmode \
76 -output-directory $(dir $(1)) \
77 -jobname $(basename $(notdir $(1)))
79 all: pdf html
81 pdf: pdf/hgbook.pdf
83 define pdf
84 mkdir -p $(dir $@)
85 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
86 cp 99book.bib $(dir $@)
87 cd $(dir $@) && bibtex $(basename $(notdir $@))
88 cd $(dir $@) && makeindex $(basename $(notdir $@))
89 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
90 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
91 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
92 endef
94 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
96 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
97 $(call pdf)
99 html: html/onepage/hgbook.html html/split/hgbook.html
101 # This is a horrible hack to work around the fact that the htlatex
102 # command in tex4ht is itself a horrible hack. I really don't want to
103 # include verbatim the big wad of TeX that is repeated in that script,
104 # so instead I mangle the script itself.
106 define htlatex
107 mkdir -p $(dir $(1))
108 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
109 cp 99book.bib $(dir $@)
110 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
111 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
112 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
113 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
114 chmod 755 $(dir $(1))/htlatex.book
115 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
116 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
117 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
118 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
119 endef
121 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
123 html/onepage/hgbook.html: $(sources) $(image-html) examples
124 $(call htlatex,$@,$<)
125 cp $(image-sources:%.svg=%.png) $(dir $@)
127 html/split/hgbook.html: $(sources) $(image-html) examples
128 $(call htlatex,$@,$<,2)
129 cp $(image-sources:%.svg=%.png) $(dir $@)
131 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
133 beta/%.tex: %.tex
134 ./fblinks $(hg_id) $(dir $@) $<
136 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
137 $(call pdf)
139 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
140 $(call htlatex,$@,$<)
141 cp $(image-sources:%.svg=%.png) $(dir $@)
143 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
144 $(call htlatex,$@,$<,2)
145 cp $(image-sources:%.svg=%.png) $(dir $@)
147 # Produce 90dpi PNGs for the web.
149 %.png: %.svg
150 inkscape -D -e $@ $<
152 %.svg: %.dot
153 dot -Tsvg -o $@ $<
155 # Produce eps & pdf for the pdf
157 %.pdf: %.eps
158 epstopdf $<
160 %.eps: %.svg
161 inkscape -E $@ $<
163 %.eps: %.dot
164 dot -Tps -o $@ $<
166 examples: examples/.run
168 examples/.run: $(example-sources:%=examples/%.run)
169 touch examples/.run
171 examples/%.run: examples/% examples/run-example
172 cd examples && ./run-example $(notdir $<)
174 build_id.tex: $(wildcard ../.hg/00changelog.[id])
175 echo -n $(hg_id) > build_id.tex
177 clean:
178 rm -rf beta html pdf \
179 $(image-dot:%.dot=%.pdf) \
180 $(image-dot:%.dot=%.png) \
181 $(image-svg:%.svg=%.pdf) \
182 $(image-svg:%.svg=%.png) \
183 examples/*.{out,run} examples/.run build_id.tex