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@76
|
15 preface.tex \
|
bos@85
|
16 srcinstall.tex \
|
bos@84
|
17 template.tex \
|
bos@95
|
18 tour-basic.tex \
|
bos@95
|
19 tour-merge.tex
|
bos@0
|
20
|
bos@11
|
21 image-sources := \
|
bos@103
|
22 kdiff3.png \
|
bos@96
|
23 mq-stack.svg \
|
bos@99
|
24 tour-history.svg \
|
bos@103
|
25 tour-merge-conflict.svg \
|
bos@103
|
26 tour-merge-merge.svg \
|
bos@100
|
27 tour-merge-pull.svg \
|
bos@103
|
28 tour-merge-sep-repos.svg
|
bos@103
|
29
|
bos@103
|
30 image-svg := $(filter %.svg,$(image-sources))
|
bos@11
|
31
|
bos@4
|
32 example-sources := \
|
bos@86
|
33 daily.files \
|
bos@86
|
34 hook.msglen \
|
bos@86
|
35 hook.simple \
|
bos@86
|
36 hook.ws \
|
bos@86
|
37 mq.qinit-help \
|
bos@86
|
38 mq.dodiff \
|
bos@86
|
39 mq.id \
|
bos@86
|
40 mq.tarball \
|
bos@86
|
41 mq.tools \
|
bos@86
|
42 mq.tutorial \
|
bos@86
|
43 template.simple \
|
bos@87
|
44 template.svnstyle \
|
bos@103
|
45 tour \
|
bos@103
|
46 tour-merge-conflict
|
bos@4
|
47
|
bos@0
|
48 latex-options = \
|
bos@0
|
49 -interaction batchmode \
|
bos@0
|
50 -output-directory $(dir $(1)) \
|
bos@0
|
51 -jobname $(basename $(notdir $(1)))
|
bos@0
|
52
|
bos@0
|
53 all: pdf html
|
bos@0
|
54
|
bos@0
|
55 pdf: pdf/hgbook.pdf
|
bos@0
|
56
|
bos@18
|
57 define pdf
|
bos@0
|
58 mkdir -p $(dir $@)
|
bos@21
|
59 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
|
bos@2
|
60 cp 99book.bib $(dir $@)
|
bos@2
|
61 cd $(dir $@) && bibtex $(basename $(notdir $@))
|
bos@16
|
62 cd $(dir $@) && makeindex $(basename $(notdir $@))
|
bos@21
|
63 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
|
bos@21
|
64 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
|
bos@26
|
65 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
|
bos@18
|
66 endef
|
bos@18
|
67
|
jeffpc@30
|
68 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
|
bos@18
|
69 $(call pdf)
|
bos@0
|
70
|
bos@0
|
71 html: html/onepage/hgbook.html html/split/hgbook.html
|
bos@0
|
72
|
bos@18
|
73 # This is a horrible hack to work around the fact that the htlatex
|
bos@18
|
74 # command in tex4ht is itself a horrible hack. I really don't want to
|
bos@18
|
75 # include verbatim the big wad of TeX that is repeated in that script,
|
bos@18
|
76 # so instead I mangle the script itself.
|
bos@18
|
77
|
bos@0
|
78 define htlatex
|
bos@0
|
79 mkdir -p $(dir $(1))
|
bos@7
|
80 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
|
bos@7
|
81 cp 99book.bib $(dir $@)
|
bos@7
|
82 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
|
bos@16
|
83 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
|
bos@7
|
84 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
|
bos@7
|
85 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
|
bos@0
|
86 chmod 755 $(dir $(1))/htlatex.book
|
bos@21
|
87 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
|
88 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
|
bos@0
|
89 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
|
bos@7
|
90 perl -pi -e 's/�([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
|
bos@0
|
91 endef
|
bos@0
|
92
|
bos@11
|
93 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
|
bos@0
|
94 $(call htlatex,$@,$<)
|
bos@11
|
95 cp $(image-sources:%.svg=%.png) $(dir $@)
|
bos@0
|
96
|
bos@11
|
97 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
|
bos@0
|
98 $(call htlatex,$@,$<,2)
|
bos@11
|
99 cp $(image-sources:%.svg=%.png) $(dir $@)
|
bos@0
|
100
|
bos@18
|
101 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
|
bos@18
|
102
|
bos@18
|
103 beta/%.tex: %.tex
|
bos@18
|
104 ./fblinks $(hg_id) $(dir $@) $<
|
bos@18
|
105
|
jeffpc@30
|
106 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
|
bos@18
|
107 $(call pdf)
|
bos@18
|
108
|
bos@18
|
109 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
|
bos@18
|
110 $(call htlatex,$@,$<)
|
bos@18
|
111 cp $(image-sources:%.svg=%.png) $(dir $@)
|
bos@18
|
112
|
bos@18
|
113 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
|
bos@18
|
114 $(call htlatex,$@,$<,2)
|
bos@18
|
115 cp $(image-sources:%.svg=%.png) $(dir $@)
|
bos@18
|
116
|
bos@18
|
117 # Produce 90dpi PNGs for the web.
|
bos@18
|
118
|
bos@11
|
119 %.png: %.svg
|
bos@11
|
120 inkscape -D -e $@ $<
|
bos@11
|
121
|
jeffpc@30
|
122 # Produce eps & pdf for the pdf
|
bos@18
|
123
|
jeffpc@30
|
124 %.pdf: %.eps
|
jeffpc@30
|
125 epstopdf $<
|
jeffpc@30
|
126
|
jeffpc@30
|
127 %.eps: %.svg
|
bos@32
|
128 inkscape -E $@ $<
|
bos@11
|
129
|
bos@4
|
130 examples: examples/.run
|
bos@4
|
131
|
bos@86
|
132 examples/.run: $(example-sources:%=examples/%.run)
|
bos@45
|
133 touch examples/.run
|
bos@45
|
134
|
bos@45
|
135 examples/%.run: examples/% examples/run-example
|
bos@45
|
136 cd examples && ./run-example $(notdir $<)
|
bos@4
|
137
|
bos@18
|
138 build_id.tex: $(wildcard ../.hg/00changelog.[id])
|
bos@29
|
139 echo -n $(hg_id) > build_id.tex
|
bos@16
|
140
|
bos@0
|
141 clean:
|
bos@103
|
142 rm -rf beta html pdf \
|
bos@103
|
143 $(image-svg:%.svg=%.pdf) \
|
bos@103
|
144 $(image-svg:%.svg=%.png) \
|
bos@46
|
145 examples/*.{out,run} examples/.run build_id.tex
|