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