hgbook

view en/Makefile @ 80:ea951cfb5cd9

Much template-related content.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Sep 06 23:36:47 2006 -0700 (2006-09-06)
parents df88df78288d
children b476081a9c04
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
34 latex-options = \
35 -interaction batchmode \
36 -output-directory $(dir $(1)) \
37 -jobname $(basename $(notdir $(1)))
39 all: pdf html
41 pdf: pdf/hgbook.pdf
43 define pdf
44 mkdir -p $(dir $@)
45 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
46 cp 99book.bib $(dir $@)
47 cd $(dir $@) && bibtex $(basename $(notdir $@))
48 cd $(dir $@) && makeindex $(basename $(notdir $@))
49 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
50 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
51 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
52 endef
54 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
55 $(call pdf)
57 html: html/onepage/hgbook.html html/split/hgbook.html
59 # This is a horrible hack to work around the fact that the htlatex
60 # command in tex4ht is itself a horrible hack. I really don't want to
61 # include verbatim the big wad of TeX that is repeated in that script,
62 # so instead I mangle the script itself.
64 define htlatex
65 mkdir -p $(dir $(1))
66 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
67 cp 99book.bib $(dir $@)
68 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
69 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
70 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
71 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
72 chmod 755 $(dir $(1))/htlatex.book
73 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
74 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
75 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
76 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
77 endef
79 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
80 $(call htlatex,$@,$<)
81 cp $(image-sources:%.svg=%.png) $(dir $@)
83 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
84 $(call htlatex,$@,$<,2)
85 cp $(image-sources:%.svg=%.png) $(dir $@)
87 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
89 beta/%.tex: %.tex
90 ./fblinks $(hg_id) $(dir $@) $<
92 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
93 $(call pdf)
95 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
96 $(call htlatex,$@,$<)
97 cp $(image-sources:%.svg=%.png) $(dir $@)
99 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
100 $(call htlatex,$@,$<,2)
101 cp $(image-sources:%.svg=%.png) $(dir $@)
103 # Produce 90dpi PNGs for the web.
105 %.png: %.svg
106 inkscape -D -e $@ $<
108 # Produce eps & pdf for the pdf
110 %.pdf: %.eps
111 epstopdf $<
113 %.eps: %.svg
114 inkscape -E $@ $<
116 examples: examples/.run
118 examples/.run: $(example-sources:%=%.run)
119 touch examples/.run
121 examples/%.run: examples/% examples/run-example
122 cd examples && ./run-example $(notdir $<)
124 build_id.tex: $(wildcard ../.hg/00changelog.[id])
125 echo -n $(hg_id) > build_id.tex
127 clean:
128 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
129 examples/*.{out,run} examples/.run build_id.tex