hgbook

annotate en/Makefile @ 42:cbfa08bcf181

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