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