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