hgbook

view en/Makefile @ 116:ca99f247899e

Minor tweaks.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Nov 14 11:42:40 2006 -0800 (2006-11-14)
parents a0f57b3e677e
children 6b0f4498569e
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 filelog.svg \
25 kdiff3.png \
26 metadata.svg \
27 mq-stack.svg \
28 revlog.svg \
29 snapshot.svg \
30 tour-history.svg \
31 tour-merge-conflict.svg \
32 tour-merge-merge.svg \
33 tour-merge-pull.svg \
34 tour-merge-sep-repos.svg \
35 wdir.svg \
36 wdir-after-commit.svg \
37 wdir-branch.svg \
38 wdir-merge.svg \
39 wdir-pre-branch.svg
41 image-svg := $(filter %.svg,$(image-sources))
43 example-sources := \
44 daily.files \
45 hook.msglen \
46 hook.simple \
47 hook.ws \
48 mq.guards \
49 mq.qinit-help \
50 mq.dodiff \
51 mq.id \
52 mq.tarball \
53 mq.tools \
54 mq.tutorial \
55 template.simple \
56 template.svnstyle \
57 tour \
58 tour-merge-conflict
60 latex-options = \
61 -interaction batchmode \
62 -output-directory $(dir $(1)) \
63 -jobname $(basename $(notdir $(1)))
65 all: pdf html
67 pdf: pdf/hgbook.pdf
69 define pdf
70 mkdir -p $(dir $@)
71 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
72 cp 99book.bib $(dir $@)
73 cd $(dir $@) && bibtex $(basename $(notdir $@))
74 cd $(dir $@) && makeindex $(basename $(notdir $@))
75 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
76 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
77 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
78 endef
80 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
81 $(call pdf)
83 html: html/onepage/hgbook.html html/split/hgbook.html
85 # This is a horrible hack to work around the fact that the htlatex
86 # command in tex4ht is itself a horrible hack. I really don't want to
87 # include verbatim the big wad of TeX that is repeated in that script,
88 # so instead I mangle the script itself.
90 define htlatex
91 mkdir -p $(dir $(1))
92 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
93 cp 99book.bib $(dir $@)
94 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
95 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
96 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
97 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
98 chmod 755 $(dir $(1))/htlatex.book
99 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
100 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
101 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
102 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
103 endef
105 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
106 $(call htlatex,$@,$<)
107 cp $(image-sources:%.svg=%.png) $(dir $@)
109 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
110 $(call htlatex,$@,$<,2)
111 cp $(image-sources:%.svg=%.png) $(dir $@)
113 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
115 beta/%.tex: %.tex
116 ./fblinks $(hg_id) $(dir $@) $<
118 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
119 $(call pdf)
121 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
122 $(call htlatex,$@,$<)
123 cp $(image-sources:%.svg=%.png) $(dir $@)
125 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
126 $(call htlatex,$@,$<,2)
127 cp $(image-sources:%.svg=%.png) $(dir $@)
129 # Produce 90dpi PNGs for the web.
131 %.png: %.svg
132 inkscape -D -e $@ $<
134 # Produce eps & pdf for the pdf
136 %.pdf: %.eps
137 epstopdf $<
139 %.eps: %.svg
140 inkscape -E $@ $<
142 examples: examples/.run
144 examples/.run: $(example-sources:%=examples/%.run)
145 touch examples/.run
147 examples/%.run: examples/% examples/run-example
148 cd examples && ./run-example $(notdir $<)
150 build_id.tex: $(wildcard ../.hg/00changelog.[id])
151 echo -n $(hg_id) > build_id.tex
153 clean:
154 rm -rf beta html pdf \
155 $(image-svg:%.svg=%.pdf) \
156 $(image-svg:%.svg=%.png) \
157 examples/*.{out,run} examples/.run build_id.tex