hgbook

view en/Makefile @ 18:e6f4088ebe52

Generate a PDF file with a feedback link on each paragraph.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Jul 04 16:41:31 2006 -0700 (2006-07-04)
parents 81454425eee9
children 187702df428b ce3339dbeb6f
line source
1 # This makefile requires GNU make.
3 hg_id := $(shell hg id 2>/dev/null | sed -e 's/ tip\>//' -e 's/ /,/g' || echo external)
5 sources := \
6 00book.tex \
7 99book.bib \
8 99defs.tex \
9 intro.tex \
10 mq.tex \
11 build_id.tex
13 image-sources := \
14 mq-stack.svg
16 example-sources := \
17 examples/run-example \
18 examples/mq.qinit-help \
19 examples/mq.tutorial
21 latex-options = \
22 -interaction batchmode \
23 -output-directory $(dir $(1)) \
24 -jobname $(basename $(notdir $(1)))
26 all: pdf html
28 pdf: pdf/hgbook.pdf
30 define pdf
31 mkdir -p $(dir $@)
32 pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
33 cp 99book.bib $(dir $@)
34 cd $(dir $@) && bibtex $(basename $(notdir $@))
35 cd $(dir $@) && makeindex $(basename $(notdir $@))
36 pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
37 pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
38 endef
40 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%_pdf.png) examples
41 $(call pdf)
43 html: html/onepage/hgbook.html html/split/hgbook.html
45 # This is a horrible hack to work around the fact that the htlatex
46 # command in tex4ht is itself a horrible hack. I really don't want to
47 # include verbatim the big wad of TeX that is repeated in that script,
48 # so instead I mangle the script itself.
50 define htlatex
51 mkdir -p $(dir $(1))
52 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
53 cp 99book.bib $(dir $@)
54 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
55 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
56 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
57 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
58 chmod 755 $(dir $(1))/htlatex.book
59 $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
60 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
61 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
62 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
63 endef
65 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
66 $(call htlatex,$@,$<)
67 cp $(image-sources:%.svg=%.png) $(dir $@)
69 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
70 $(call htlatex,$@,$<,2)
71 cp $(image-sources:%.svg=%.png) $(dir $@)
73 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
75 beta/%.tex: %.tex
76 ./fblinks $(hg_id) $(dir $@) $<
78 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%_pdf.png) examples fblinks
79 $(call pdf)
81 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
82 $(call htlatex,$@,$<)
83 cp $(image-sources:%.svg=%.png) $(dir $@)
85 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
86 $(call htlatex,$@,$<,2)
87 cp $(image-sources:%.svg=%.png) $(dir $@)
89 # Produce 90dpi PNGs for the web.
91 %.png: %.svg
92 inkscape -D -e $@ $<
94 # Produce 300dpi PNGs for PDF.
96 %_pdf.png: %.svg
97 inkscape -D -d 300 -e $@ $<
99 examples: examples/.run
101 examples/.run: $(example-sources)
102 cd examples && ./run-example
104 build_id.tex: $(wildcard ../.hg/00changelog.[id])
105 echo $(hg_id) > build_id.tex
107 clean:
108 rm -rf beta html pdf *.eps *.png *.aux *.dvi *.log *.out \
109 examples/*.out examples/.run build_id.tex