hgbook

view en/Makefile @ 83:b476081a9c04

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