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