hgbook

view en/Makefile @ 96:7d7ddc3a57af

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