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