hgbook

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