hgbook

view en/Makefile @ 106:9cbc5d0db542

Finish off advanced MQ chapter (maybe).
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Oct 23 15:43:04 2006 -0700 (2006-10-23)
parents 5b80c922ebdd
children e0b961975c5e
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 mq-collab.tex \
16 mq-ref.tex \
17 preface.tex \
18 srcinstall.tex \
19 template.tex \
20 tour-basic.tex \
21 tour-merge.tex
23 image-sources := \
24 kdiff3.png \
25 mq-stack.svg \
26 tour-history.svg \
27 tour-merge-conflict.svg \
28 tour-merge-merge.svg \
29 tour-merge-pull.svg \
30 tour-merge-sep-repos.svg
32 image-svg := $(filter %.svg,$(image-sources))
34 example-sources := \
35 daily.files \
36 hook.msglen \
37 hook.simple \
38 hook.ws \
39 mq.guards \
40 mq.qinit-help \
41 mq.dodiff \
42 mq.id \
43 mq.tarball \
44 mq.tools \
45 mq.tutorial \
46 template.simple \
47 template.svnstyle \
48 tour \
49 tour-merge-conflict
51 latex-options = \
52 -interaction batchmode \
53 -output-directory $(dir $(1)) \
54 -jobname $(basename $(notdir $(1)))
56 all: pdf html
58 pdf: pdf/hgbook.pdf
60 define pdf
61 mkdir -p $(dir $@)
62 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
63 cp 99book.bib $(dir $@)
64 cd $(dir $@) && bibtex $(basename $(notdir $@))
65 cd $(dir $@) && makeindex $(basename $(notdir $@))
66 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
67 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
68 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
69 endef
71 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
72 $(call pdf)
74 html: html/onepage/hgbook.html html/split/hgbook.html
76 # This is a horrible hack to work around the fact that the htlatex
77 # command in tex4ht is itself a horrible hack. I really don't want to
78 # include verbatim the big wad of TeX that is repeated in that script,
79 # so instead I mangle the script itself.
81 define htlatex
82 mkdir -p $(dir $(1))
83 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
84 cp 99book.bib $(dir $@)
85 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
86 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
87 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
88 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
89 chmod 755 $(dir $(1))/htlatex.book
90 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
91 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
92 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
93 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
94 endef
96 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
97 $(call htlatex,$@,$<)
98 cp $(image-sources:%.svg=%.png) $(dir $@)
100 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
101 $(call htlatex,$@,$<,2)
102 cp $(image-sources:%.svg=%.png) $(dir $@)
104 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
106 beta/%.tex: %.tex
107 ./fblinks $(hg_id) $(dir $@) $<
109 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
110 $(call pdf)
112 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
113 $(call htlatex,$@,$<)
114 cp $(image-sources:%.svg=%.png) $(dir $@)
116 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
117 $(call htlatex,$@,$<,2)
118 cp $(image-sources:%.svg=%.png) $(dir $@)
120 # Produce 90dpi PNGs for the web.
122 %.png: %.svg
123 inkscape -D -e $@ $<
125 # Produce eps & pdf for the pdf
127 %.pdf: %.eps
128 epstopdf $<
130 %.eps: %.svg
131 inkscape -E $@ $<
133 examples: examples/.run
135 examples/.run: $(example-sources:%=examples/%.run)
136 touch examples/.run
138 examples/%.run: examples/% examples/run-example
139 cd examples && ./run-example $(notdir $<)
141 build_id.tex: $(wildcard ../.hg/00changelog.[id])
142 echo -n $(hg_id) > build_id.tex
144 clean:
145 rm -rf beta html pdf \
146 $(image-svg:%.svg=%.pdf) \
147 $(image-svg:%.svg=%.png) \
148 examples/*.{out,run} examples/.run build_id.tex