jeffpc@57: # This makefile requires GNU make. jeffpc@57: jeffpc@57: hg_id := $(shell hg parents --template '{node|short}\n' | head -1) jeffpc@57: jeffpc@57: sources := \ jeffpc@57: 00book.tex \ jeffpc@57: 99book.bib \ jeffpc@57: 99defs.tex \ jeffpc@57: build_id.tex \ jeffpc@57: concepts.tex \ jeffpc@57: daily.tex \ jeffpc@57: hook.tex \ jeffpc@57: intro.tex \ jeffpc@57: mq.tex \ jeffpc@57: preface.tex jeffpc@57: jeffpc@57: image-sources := \ jeffpc@57: mq-stack.svg jeffpc@57: jeffpc@57: example-sources := \ jeffpc@57: examples/daily.files \ jeffpc@58: examples/hook.msglen \ jeffpc@57: examples/hook.simple \ jeffpc@57: examples/hook.ws \ jeffpc@57: examples/concepts \ jeffpc@57: examples/mq.qinit-help \ jeffpc@57: examples/mq.dodiff \ jeffpc@57: examples/mq.tarball \ jeffpc@57: examples/mq.tools \ jeffpc@57: examples/mq.tutorial jeffpc@57: jeffpc@57: latex-options = \ jeffpc@57: -interaction batchmode \ jeffpc@57: -output-directory $(dir $(1)) \ jeffpc@57: -jobname $(basename $(notdir $(1))) jeffpc@57: jeffpc@57: all: pdf html jeffpc@57: jeffpc@57: pdf: pdf/hgbook.pdf jeffpc@57: jeffpc@57: define pdf jeffpc@57: mkdir -p $(dir $@) jeffpc@57: TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) jeffpc@57: cp 99book.bib $(dir $@) jeffpc@57: cd $(dir $@) && bibtex $(basename $(notdir $@)) jeffpc@57: cd $(dir $@) && makeindex $(basename $(notdir $@)) jeffpc@57: TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) jeffpc@57: TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) jeffpc@57: if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi jeffpc@57: endef jeffpc@57: jeffpc@57: pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples jeffpc@57: $(call pdf) jeffpc@57: jeffpc@57: html: html/onepage/hgbook.html html/split/hgbook.html jeffpc@57: jeffpc@57: # This is a horrible hack to work around the fact that the htlatex jeffpc@57: # command in tex4ht is itself a horrible hack. I really don't want to jeffpc@57: # include verbatim the big wad of TeX that is repeated in that script, jeffpc@57: # so instead I mangle the script itself. jeffpc@57: jeffpc@57: define htlatex jeffpc@57: mkdir -p $(dir $(1)) jeffpc@57: head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book jeffpc@57: cp 99book.bib $(dir $@) jeffpc@57: echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book jeffpc@57: echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book jeffpc@57: head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book jeffpc@57: echo 'echo status $$$$' >> $(dir $(1))/htlatex.book jeffpc@57: chmod 755 $(dir $(1))/htlatex.book jeffpc@57: 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: cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf jeffpc@57: cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1))) jeffpc@57: perl -pi -e 's/�([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html jeffpc@57: endef jeffpc@57: jeffpc@57: html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples jeffpc@57: $(call htlatex,$@,$<) jeffpc@57: cp $(image-sources:%.svg=%.png) $(dir $@) jeffpc@57: jeffpc@57: html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples jeffpc@57: $(call htlatex,$@,$<,2) jeffpc@57: cp $(image-sources:%.svg=%.png) $(dir $@) jeffpc@57: jeffpc@57: beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html jeffpc@57: jeffpc@57: beta/%.tex: %.tex jeffpc@57: ./fblinks $(hg_id) $(dir $@) $< jeffpc@57: jeffpc@57: beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks jeffpc@57: $(call pdf) jeffpc@57: jeffpc@57: beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples jeffpc@57: $(call htlatex,$@,$<) jeffpc@57: cp $(image-sources:%.svg=%.png) $(dir $@) jeffpc@57: jeffpc@57: beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples jeffpc@57: $(call htlatex,$@,$<,2) jeffpc@57: cp $(image-sources:%.svg=%.png) $(dir $@) jeffpc@57: jeffpc@57: # Produce 90dpi PNGs for the web. jeffpc@57: jeffpc@57: %.png: %.svg jeffpc@57: inkscape -D -e $@ $< jeffpc@57: jeffpc@57: # Produce eps & pdf for the pdf jeffpc@57: jeffpc@57: %.pdf: %.eps jeffpc@57: epstopdf $< jeffpc@57: jeffpc@57: %.eps: %.svg jeffpc@57: inkscape -E $@ $< jeffpc@57: jeffpc@57: examples: examples/.run jeffpc@57: jeffpc@57: examples/.run: $(example-sources:%=%.run) jeffpc@57: touch examples/.run jeffpc@57: jeffpc@57: examples/%.run: examples/% examples/run-example jeffpc@57: cd examples && ./run-example $(notdir $<) jeffpc@57: jeffpc@57: build_id.tex: $(wildcard ../.hg/00changelog.[id]) jeffpc@57: echo -n $(hg_id) > build_id.tex jeffpc@57: jeffpc@57: clean: jeffpc@57: rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \ jeffpc@57: examples/*.{out,run} examples/.run build_id.tex