hgbook

view en/Makefile @ 99:06383f9e46e4

More graphics.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Oct 16 14:54:37 2006 -0700 (2006-10-16)
parents 7d7ddc3a57af
children 272146fab009
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-basic.tex \
19 tour-merge.tex
21 image-sources := \
22 mq-stack.svg \
23 tour-history.svg \
24 tour-merge-sep-repos.svg \
25 tour-merge-pull.svg
27 example-sources := \
28 daily.files \
29 hook.msglen \
30 hook.simple \
31 hook.ws \
32 mq.qinit-help \
33 mq.dodiff \
34 mq.id \
35 mq.tarball \
36 mq.tools \
37 mq.tutorial \
38 template.simple \
39 template.svnstyle \
40 tour
42 latex-options = \
43 -interaction batchmode \
44 -output-directory $(dir $(1)) \
45 -jobname $(basename $(notdir $(1)))
47 all: pdf html
49 pdf: pdf/hgbook.pdf
51 define pdf
52 mkdir -p $(dir $@)
53 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
54 cp 99book.bib $(dir $@)
55 cd $(dir $@) && bibtex $(basename $(notdir $@))
56 cd $(dir $@) && makeindex $(basename $(notdir $@))
57 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
58 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
59 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
60 endef
62 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
63 $(call pdf)
65 html: html/onepage/hgbook.html html/split/hgbook.html
67 # This is a horrible hack to work around the fact that the htlatex
68 # command in tex4ht is itself a horrible hack. I really don't want to
69 # include verbatim the big wad of TeX that is repeated in that script,
70 # so instead I mangle the script itself.
72 define htlatex
73 mkdir -p $(dir $(1))
74 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
75 cp 99book.bib $(dir $@)
76 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
77 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
78 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
79 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
80 chmod 755 $(dir $(1))/htlatex.book
81 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
82 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
83 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
84 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
85 endef
87 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
88 $(call htlatex,$@,$<)
89 cp $(image-sources:%.svg=%.png) $(dir $@)
91 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
92 $(call htlatex,$@,$<,2)
93 cp $(image-sources:%.svg=%.png) $(dir $@)
95 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
97 beta/%.tex: %.tex
98 ./fblinks $(hg_id) $(dir $@) $<
100 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
101 $(call pdf)
103 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
104 $(call htlatex,$@,$<)
105 cp $(image-sources:%.svg=%.png) $(dir $@)
107 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
108 $(call htlatex,$@,$<,2)
109 cp $(image-sources:%.svg=%.png) $(dir $@)
111 # Produce 90dpi PNGs for the web.
113 %.png: %.svg
114 inkscape -D -e $@ $<
116 # Produce eps & pdf for the pdf
118 %.pdf: %.eps
119 epstopdf $<
121 %.eps: %.svg
122 inkscape -E $@ $<
124 examples: examples/.run
126 examples/.run: $(example-sources:%=examples/%.run)
127 touch examples/.run
129 examples/%.run: examples/% examples/run-example
130 cd examples && ./run-example $(notdir $<)
132 build_id.tex: $(wildcard ../.hg/00changelog.[id])
133 echo -n $(hg_id) > build_id.tex
135 clean:
136 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
137 examples/*.{out,run} examples/.run build_id.tex