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