hgbook

view en/Makefile @ 34:c0979ed1eabd

Get started on hook chapter.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun Jul 16 00:01:43 2006 -0700 (2006-07-16)
parents b7d46e86a5f1
children cbfa08bcf181 b8539d91c84d
line source
1 # This makefile requires GNU make.
3 hg_id := $(shell hg parents --template '{node|short}\n' | head -1)
5 sources := \
6 00book.tex \
7 99book.bib \
8 99defs.tex \
9 build_id.tex \
10 hook.tex \
11 intro.tex \
12 mq.tex \
13 preface.tex
15 image-sources := \
16 mq-stack.svg
18 example-sources := \
19 examples/run-example \
20 examples/hook.simple \
21 examples/mq.qinit-help \
22 examples/mq.diff \
23 examples/mq.tarball \
24 examples/mq.tools \
25 examples/mq.tutorial
27 latex-options = \
28 -interaction batchmode \
29 -output-directory $(dir $(1)) \
30 -jobname $(basename $(notdir $(1)))
32 all: pdf html
34 pdf: pdf/hgbook.pdf
36 define pdf
37 mkdir -p $(dir $@)
38 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
39 cp 99book.bib $(dir $@)
40 cd $(dir $@) && bibtex $(basename $(notdir $@))
41 cd $(dir $@) && makeindex $(basename $(notdir $@))
42 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
43 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
44 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
45 endef
47 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
48 $(call pdf)
50 html: html/onepage/hgbook.html html/split/hgbook.html
52 # This is a horrible hack to work around the fact that the htlatex
53 # command in tex4ht is itself a horrible hack. I really don't want to
54 # include verbatim the big wad of TeX that is repeated in that script,
55 # so instead I mangle the script itself.
57 define htlatex
58 mkdir -p $(dir $(1))
59 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
60 cp 99book.bib $(dir $@)
61 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
62 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
63 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
64 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
65 chmod 755 $(dir $(1))/htlatex.book
66 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
67 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
68 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
69 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
70 endef
72 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
73 $(call htlatex,$@,$<)
74 cp $(image-sources:%.svg=%.png) $(dir $@)
76 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
77 $(call htlatex,$@,$<,2)
78 cp $(image-sources:%.svg=%.png) $(dir $@)
80 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
82 beta/%.tex: %.tex
83 ./fblinks $(hg_id) $(dir $@) $<
85 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
86 $(call pdf)
88 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
89 $(call htlatex,$@,$<)
90 cp $(image-sources:%.svg=%.png) $(dir $@)
92 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
93 $(call htlatex,$@,$<,2)
94 cp $(image-sources:%.svg=%.png) $(dir $@)
96 # Produce 90dpi PNGs for the web.
98 %.png: %.svg
99 inkscape -D -e $@ $<
101 # Produce eps & pdf for the pdf
103 %.pdf: %.eps
104 epstopdf $<
106 %.eps: %.svg
107 inkscape -E $@ $<
109 examples: examples/.run
111 examples/.run: $(example-sources)
112 cd examples && ./run-example
114 build_id.tex: $(wildcard ../.hg/00changelog.[id])
115 echo -n $(hg_id) > build_id.tex
117 clean:
118 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
119 examples/*.out examples/.run build_id.tex