hgbook

view en/Makefile @ 87:0995016342f8

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