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