hgbook

annotate en/Makefile @ 146:65f6f9d18fa1

Oops! I forgot that I need the undoctored output files in the book!
Now they're named "*.lxo", instead of "*.out". Ugh.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Mar 06 21:55:48 2007 -0800 (2007-03-06)
parents 1e013fbe35f7
children 16f02802f448
rev   line source
bos@18 1 # This makefile requires GNU make.
bos@18 2
gb@69 3 hg_id := $(shell hg parents --template '{node|short}\n')
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@132 10 cmdref.tex \
bos@59 11 concepts.tex \
bos@42 12 daily.tex \
bos@133 13 filenames.tex \
bos@34 14 hook.tex \
bos@16 15 intro.tex \
bos@16 16 mq.tex \
bos@104 17 mq-collab.tex \
bos@104 18 mq-ref.tex \
bos@76 19 preface.tex \
bos@85 20 srcinstall.tex \
bos@84 21 template.tex \
bos@95 22 tour-basic.tex \
bos@121 23 tour-merge.tex \
bos@121 24 undo.tex
bos@0 25
bos@11 26 image-sources := \
bos@108 27 filelog.svg \
bos@103 28 kdiff3.png \
bos@109 29 metadata.svg \
bos@96 30 mq-stack.svg \
bos@112 31 revlog.svg \
bos@110 32 snapshot.svg \
bos@99 33 tour-history.svg \
bos@103 34 tour-merge-conflict.svg \
bos@103 35 tour-merge-merge.svg \
bos@100 36 tour-merge-pull.svg \
bos@113 37 tour-merge-sep-repos.svg \
bos@124 38 undo-manual.dot \
bos@124 39 undo-manual-merge.dot \
bos@124 40 undo-non-tip.dot \
bos@124 41 undo-simple.dot \
bos@113 42 wdir.svg \
bos@115 43 wdir-after-commit.svg \
bos@115 44 wdir-branch.svg \
bos@115 45 wdir-merge.svg \
bos@115 46 wdir-pre-branch.svg
bos@103 47
bos@124 48 image-dot := $(filter %.dot,$(image-sources))
bos@103 49 image-svg := $(filter %.svg,$(image-sources))
bos@124 50 image-png := $(filter %.png,$(image-sources))
bos@11 51
bos@4 52 example-sources := \
bos@124 53 backout \
bos@131 54 bisect \
bos@133 55 cmdref \
bos@117 56 daily.copy \
bos@86 57 daily.files \
bos@118 58 daily.rename \
bos@122 59 daily.revert \
bos@133 60 filenames \
bos@86 61 hook.msglen \
bos@86 62 hook.simple \
bos@86 63 hook.ws \
bos@104 64 mq.guards \
bos@86 65 mq.qinit-help \
bos@86 66 mq.dodiff \
bos@86 67 mq.id \
bos@86 68 mq.tarball \
bos@86 69 mq.tools \
bos@86 70 mq.tutorial \
bos@121 71 rollback \
bos@86 72 template.simple \
bos@87 73 template.svnstyle \
bos@103 74 tour \
bos@103 75 tour-merge-conflict
bos@4 76
bos@0 77 latex-options = \
bos@0 78 -interaction batchmode \
bos@0 79 -output-directory $(dir $(1)) \
bos@0 80 -jobname $(basename $(notdir $(1)))
bos@0 81
bos@0 82 all: pdf html
bos@0 83
bos@0 84 pdf: pdf/hgbook.pdf
bos@0 85
bos@18 86 define pdf
bos@0 87 mkdir -p $(dir $@)
bos@21 88 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@2 89 cp 99book.bib $(dir $@)
bos@2 90 cd $(dir $@) && bibtex $(basename $(notdir $@))
bos@16 91 cd $(dir $@) && makeindex $(basename $(notdir $@))
bos@21 92 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@21 93 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@26 94 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
bos@18 95 endef
bos@18 96
bos@124 97 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
bos@124 98
bos@124 99 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
bos@18 100 $(call pdf)
bos@0 101
bos@0 102 html: html/onepage/hgbook.html html/split/hgbook.html
bos@0 103
bos@18 104 # This is a horrible hack to work around the fact that the htlatex
bos@18 105 # command in tex4ht is itself a horrible hack. I really don't want to
bos@18 106 # include verbatim the big wad of TeX that is repeated in that script,
bos@18 107 # so instead I mangle the script itself.
bos@18 108
bos@0 109 define htlatex
bos@0 110 mkdir -p $(dir $(1))
bos@7 111 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
bos@7 112 cp 99book.bib $(dir $@)
bos@7 113 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
bos@16 114 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
bos@7 115 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
bos@7 116 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
bos@0 117 chmod 755 $(dir $(1))/htlatex.book
bos@21 118 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 119 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
bos@0 120 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
bos@7 121 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
bos@0 122 endef
bos@0 123
bos@124 124 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
bos@124 125
bos@124 126 html/onepage/hgbook.html: $(sources) $(image-html) examples
bos@0 127 $(call htlatex,$@,$<)
bos@11 128 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@0 129
bos@124 130 html/split/hgbook.html: $(sources) $(image-html) examples
bos@0 131 $(call htlatex,$@,$<,2)
bos@11 132 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@0 133
bos@18 134 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
bos@18 135
bos@18 136 beta/%.tex: %.tex
bos@18 137 ./fblinks $(hg_id) $(dir $@) $<
bos@18 138
jeffpc@30 139 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
bos@18 140 $(call pdf)
bos@18 141
bos@18 142 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
bos@18 143 $(call htlatex,$@,$<)
bos@18 144 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@18 145
bos@18 146 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
bos@18 147 $(call htlatex,$@,$<,2)
bos@18 148 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@18 149
bos@18 150 # Produce 90dpi PNGs for the web.
bos@18 151
bos@11 152 %.png: %.svg
bos@11 153 inkscape -D -e $@ $<
bos@11 154
bos@124 155 %.svg: %.dot
bos@124 156 dot -Tsvg -o $@ $<
bos@124 157
jeffpc@30 158 # Produce eps & pdf for the pdf
bos@18 159
jeffpc@30 160 %.pdf: %.eps
jeffpc@30 161 epstopdf $<
jeffpc@30 162
jeffpc@30 163 %.eps: %.svg
bos@32 164 inkscape -E $@ $<
bos@11 165
bos@124 166 %.eps: %.dot
bos@124 167 dot -Tps -o $@ $<
bos@124 168
bos@4 169 examples: examples/.run
bos@4 170
bos@86 171 examples/.run: $(example-sources:%=examples/%.run)
bos@45 172 touch examples/.run
bos@45 173
bos@45 174 examples/%.run: examples/% examples/run-example
bos@45 175 cd examples && ./run-example $(notdir $<)
bos@4 176
bos@18 177 build_id.tex: $(wildcard ../.hg/00changelog.[id])
bos@29 178 echo -n $(hg_id) > build_id.tex
bos@16 179
bos@0 180 clean:
bos@103 181 rm -rf beta html pdf \
bos@124 182 $(image-dot:%.dot=%.pdf) \
bos@124 183 $(image-dot:%.dot=%.png) \
bos@103 184 $(image-svg:%.svg=%.pdf) \
bos@103 185 $(image-svg:%.svg=%.png) \
bos@146 186 examples/*.{lxo,run} examples/.run build_id.tex