hgbook

view en/Makefile @ 58:3649ee841264

Merge with bos
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Tue Jul 25 09:07:20 2006 -0400 (2006-07-25)
parents fa8bafe467cb 18210d46491f
children 0aae9d676e0f
line source
1 # This makefile requires GNU make.
3 hg_id := $(shell hg parents --template '{node|short}\n' | head -1)
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
17 image-sources := \
18 mq-stack.svg
20 example-sources := \
21 examples/daily.files \
22 examples/hook.msglen \
23 examples/hook.simple \
24 examples/hook.ws \
25 examples/concepts \
26 examples/mq.qinit-help \
27 examples/mq.dodiff \
28 examples/mq.tarball \
29 examples/mq.tools \
30 examples/mq.tutorial
32 latex-options = \
33 -interaction batchmode \
34 -output-directory $(dir $(1)) \
35 -jobname $(basename $(notdir $(1)))
37 all: pdf html
39 pdf: pdf/hgbook.pdf
41 define pdf
42 mkdir -p $(dir $@)
43 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
44 cp 99book.bib $(dir $@)
45 cd $(dir $@) && bibtex $(basename $(notdir $@))
46 cd $(dir $@) && makeindex $(basename $(notdir $@))
47 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
48 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
49 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
50 endef
52 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
53 $(call pdf)
55 html: html/onepage/hgbook.html html/split/hgbook.html
57 # This is a horrible hack to work around the fact that the htlatex
58 # command in tex4ht is itself a horrible hack. I really don't want to
59 # include verbatim the big wad of TeX that is repeated in that script,
60 # so instead I mangle the script itself.
62 define htlatex
63 mkdir -p $(dir $(1))
64 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
65 cp 99book.bib $(dir $@)
66 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
67 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
68 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
69 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
70 chmod 755 $(dir $(1))/htlatex.book
71 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
72 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
73 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
74 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
75 endef
77 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
78 $(call htlatex,$@,$<)
79 cp $(image-sources:%.svg=%.png) $(dir $@)
81 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
82 $(call htlatex,$@,$<,2)
83 cp $(image-sources:%.svg=%.png) $(dir $@)
85 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
87 beta/%.tex: %.tex
88 ./fblinks $(hg_id) $(dir $@) $<
90 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
91 $(call pdf)
93 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
94 $(call htlatex,$@,$<)
95 cp $(image-sources:%.svg=%.png) $(dir $@)
97 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
98 $(call htlatex,$@,$<,2)
99 cp $(image-sources:%.svg=%.png) $(dir $@)
101 # Produce 90dpi PNGs for the web.
103 %.png: %.svg
104 inkscape -D -e $@ $<
106 # Produce eps & pdf for the pdf
108 %.pdf: %.eps
109 epstopdf $<
111 %.eps: %.svg
112 inkscape -E $@ $<
114 examples: examples/.run
116 examples/.run: $(example-sources:%=%.run)
117 touch examples/.run
119 examples/%.run: examples/% examples/run-example
120 cd examples && ./run-example $(notdir $<)
122 build_id.tex: $(wildcard ../.hg/00changelog.[id])
123 echo -n $(hg_id) > build_id.tex
125 clean:
126 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
127 examples/*.{out,run} examples/.run build_id.tex