hgbook

annotate en/Makefile @ 50:8b0d389cf6e0

Update MQ chapter to match recent bug fixes.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu Jul 27 10:20:55 2006 -0700 (2006-07-27)
parents 18210d46491f
children 0aae9d676e0f
rev   line source
bos@18 1 # This makefile requires GNU make.
bos@18 2
bos@29 3 hg_id := $(shell hg parents --template '{node|short}\n' | head -1)
bos@18 4
bos@2 5 sources := \
bos@2 6 00book.tex \
bos@2 7 99book.bib \
bos@2 8 99defs.tex \
bos@34 9 build_id.tex \
bos@42 10 daily.tex \
bos@34 11 hook.tex \
bos@16 12 intro.tex \
bos@16 13 mq.tex \
bos@34 14 preface.tex
bos@0 15
bos@11 16 image-sources := \
bos@11 17 mq-stack.svg
bos@11 18
bos@4 19 example-sources := \
bos@43 20 examples/daily.files \
bos@49 21 examples/hook.msglen \
bos@34 22 examples/hook.simple \
bos@44 23 examples/hook.ws \
bos@7 24 examples/mq.qinit-help \
bos@46 25 examples/mq.dodiff \
bos@50 26 examples/mq.id \
bos@19 27 examples/mq.tarball \
bos@19 28 examples/mq.tools \
bos@7 29 examples/mq.tutorial
bos@4 30
bos@0 31 latex-options = \
bos@0 32 -interaction batchmode \
bos@0 33 -output-directory $(dir $(1)) \
bos@0 34 -jobname $(basename $(notdir $(1)))
bos@0 35
bos@0 36 all: pdf html
bos@0 37
bos@0 38 pdf: pdf/hgbook.pdf
bos@0 39
bos@18 40 define pdf
bos@0 41 mkdir -p $(dir $@)
bos@21 42 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@2 43 cp 99book.bib $(dir $@)
bos@2 44 cd $(dir $@) && bibtex $(basename $(notdir $@))
bos@16 45 cd $(dir $@) && makeindex $(basename $(notdir $@))
bos@21 46 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@21 47 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@26 48 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
bos@18 49 endef
bos@18 50
jeffpc@30 51 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
bos@18 52 $(call pdf)
bos@0 53
bos@0 54 html: html/onepage/hgbook.html html/split/hgbook.html
bos@0 55
bos@18 56 # This is a horrible hack to work around the fact that the htlatex
bos@18 57 # command in tex4ht is itself a horrible hack. I really don't want to
bos@18 58 # include verbatim the big wad of TeX that is repeated in that script,
bos@18 59 # so instead I mangle the script itself.
bos@18 60
bos@0 61 define htlatex
bos@0 62 mkdir -p $(dir $(1))
bos@7 63 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
bos@7 64 cp 99book.bib $(dir $@)
bos@7 65 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
bos@16 66 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
bos@7 67 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
bos@7 68 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
bos@0 69 chmod 755 $(dir $(1))/htlatex.book
bos@21 70 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
bos@0 71 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
bos@0 72 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
bos@7 73 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
bos@0 74 endef
bos@0 75
bos@11 76 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
bos@0 77 $(call htlatex,$@,$<)
bos@11 78 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@0 79
bos@11 80 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
bos@0 81 $(call htlatex,$@,$<,2)
bos@11 82 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@0 83
bos@18 84 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
bos@18 85
bos@18 86 beta/%.tex: %.tex
bos@18 87 ./fblinks $(hg_id) $(dir $@) $<
bos@18 88
jeffpc@30 89 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
bos@18 90 $(call pdf)
bos@18 91
bos@18 92 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
bos@18 93 $(call htlatex,$@,$<)
bos@18 94 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@18 95
bos@18 96 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
bos@18 97 $(call htlatex,$@,$<,2)
bos@18 98 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@18 99
bos@18 100 # Produce 90dpi PNGs for the web.
bos@18 101
bos@11 102 %.png: %.svg
bos@11 103 inkscape -D -e $@ $<
bos@11 104
jeffpc@30 105 # Produce eps & pdf for the pdf
bos@18 106
jeffpc@30 107 %.pdf: %.eps
jeffpc@30 108 epstopdf $<
jeffpc@30 109
jeffpc@30 110 %.eps: %.svg
bos@32 111 inkscape -E $@ $<
bos@11 112
bos@4 113 examples: examples/.run
bos@4 114
bos@45 115 examples/.run: $(example-sources:%=%.run)
bos@45 116 touch examples/.run
bos@45 117
bos@45 118 examples/%.run: examples/% examples/run-example
bos@45 119 cd examples && ./run-example $(notdir $<)
bos@4 120
bos@18 121 build_id.tex: $(wildcard ../.hg/00changelog.[id])
bos@29 122 echo -n $(hg_id) > build_id.tex
bos@16 123
bos@0 124 clean:
jeffpc@30 125 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
bos@46 126 examples/*.{out,run} examples/.run build_id.tex