bos@18: # This makefile requires GNU make. bos@18: bos@2: sources := \ bos@2: 00book.tex \ bos@2: 99book.bib \ bos@2: 99defs.tex \ bos@34: build_id.tex \ bos@187: branch.tex \ bos@132: cmdref.tex \ bos@159: collab.tex \ bos@59: concepts.tex \ bos@42: daily.tex \ bos@133: filenames.tex \ bos@177: hg_id.tex \ bos@223: hgext.tex \ bos@34: hook.tex \ bos@16: intro.tex \ bos@16: mq.tex \ bos@104: mq-collab.tex \ bos@104: mq-ref.tex \ bos@76: preface.tex \ bos@85: srcinstall.tex \ bos@84: template.tex \ bos@95: tour-basic.tex \ bos@121: tour-merge.tex \ bos@121: undo.tex bos@0: bos@11: image-sources := \ bos@179: feature-branches.dot \ bos@108: filelog.svg \ bos@103: kdiff3.png \ bos@109: metadata.svg \ bos@96: mq-stack.svg \ bos@149: note.png \ bos@112: revlog.svg \ bos@110: snapshot.svg \ bos@99: tour-history.svg \ bos@103: tour-merge-conflict.svg \ bos@103: tour-merge-merge.svg \ bos@100: tour-merge-pull.svg \ bos@113: tour-merge-sep-repos.svg \ bos@124: undo-manual.dot \ bos@124: undo-manual-merge.dot \ bos@124: undo-non-tip.dot \ bos@124: undo-simple.dot \ bos@113: wdir.svg \ bos@115: wdir-after-commit.svg \ bos@115: wdir-branch.svg \ bos@115: wdir-merge.svg \ bos@115: wdir-pre-branch.svg bos@103: bos@124: image-dot := $(filter %.dot,$(image-sources)) bos@103: image-svg := $(filter %.svg,$(image-sources)) bos@124: image-png := $(filter %.png,$(image-sources)) bos@11: bos@213: image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png) bos@213: image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png) bos@213: bos@4: example-sources := \ bos@124: backout \ bos@131: bisect \ bos@179: branching \ bos@202: branch-named \ bos@198: branch-repo \ bos@133: cmdref \ bos@117: daily.copy \ bos@86: daily.files \ bos@118: daily.rename \ bos@122: daily.revert \ bos@226: extdiff \ bos@133: filenames \ bos@86: hook.msglen \ bos@86: hook.simple \ bos@86: hook.ws \ bos@156: issue29 \ bos@104: mq.guards \ bos@86: mq.qinit-help \ bos@86: mq.dodiff \ bos@86: mq.id \ bos@86: mq.tarball \ bos@86: mq.tools \ bos@86: mq.tutorial \ bos@156: rename.divergent \ bos@121: rollback \ bos@196: tag \ bos@86: template.simple \ bos@87: template.svnstyle \ bos@103: tour \ bos@103: tour-merge-conflict bos@4: bos@172: example-prereqs := \ bos@172: /usr/bin/merge bos@172: bos@157: dist-sources := \ bos@159: ../html/hgicon.png \ bos@157: ../html/index.html.var \ bos@157: ../html/index.en.html bos@157: bos@0: latex-options = \ bos@0: -interaction batchmode \ bos@0: -output-directory $(dir $(1)) \ bos@0: -jobname $(basename $(notdir $(1))) bos@0: bos@177: hg = $(shell which hg) bos@177: bos@269: hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n') bos@177: bos@177: hg-version = $(shell hg version -q | \ bos@242: sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,') bos@177: bos@0: all: pdf html bos@0: bos@0: pdf: pdf/hgbook.pdf bos@0: bos@18: define pdf bos@0: mkdir -p $(dir $@) bos@21: TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) bos@2: cp 99book.bib $(dir $@) bos@2: cd $(dir $@) && bibtex $(basename $(notdir $@)) bos@16: cd $(dir $@) && makeindex $(basename $(notdir $@)) bos@21: TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) bos@21: TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) bos@26: if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi bos@18: endef bos@18: bos@124: pdf/hgbook.pdf: $(sources) $(image-pdf) examples bos@18: $(call pdf) bos@0: bos@149: html: onepage split bos@149: bos@213: onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%) bos@213: bos@213: html/onepage/%: % bos@213: cp $< $@ bos@213: bos@213: split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%) bos@213: bos@213: html/split/%: % bos@213: cp $< $@ bos@0: bos@18: # This is a horrible hack to work around the fact that the htlatex bos@18: # command in tex4ht is itself a horrible hack. I really don't want to bos@18: # include verbatim the big wad of TeX that is repeated in that script, bos@171: # but I've given up and run a hacked copy as htlatex.book here. bos@18: bos@0: define htlatex bos@0: mkdir -p $(dir $(1)) bos@170: cp 99book.bib $(dir $(1)) bos@170: TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1) bos@0: cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf bos@0: cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1))) bos@149: ./fixhtml.py $(dir $(1))/*.html bos@214: rm $(dir $(1))/hgbook.css bos@0: endef bos@0: bos@213: html/onepage/hgbook.html: $(sources) $(image-html) examples bookhtml.cfg bos@0: $(call htlatex,$@,$<) bos@213: bos@213: html/split/hgbook.html: $(sources) examples bookhtml.cfg bos@0: $(call htlatex,$@,$<,2) bos@18: bos@18: # Produce 90dpi PNGs for the web. bos@18: bos@11: %.png: %.svg bos@11: inkscape -D -e $@ $< bos@11: bos@124: %.svg: %.dot bos@124: dot -Tsvg -o $@ $< bos@124: jeffpc@30: # Produce eps & pdf for the pdf bos@18: jeffpc@30: %.pdf: %.eps jeffpc@30: epstopdf $< jeffpc@30: jeffpc@30: %.eps: %.svg bos@32: inkscape -E $@ $< bos@11: bos@124: %.eps: %.dot bos@124: dot -Tps -o $@ $< bos@124: bos@172: examples: $(example-prereqs) examples/.run bos@4: bos@86: examples/.run: $(example-sources:%=examples/%.run) bos@45: touch examples/.run bos@45: bos@45: examples/%.run: examples/% examples/run-example bos@45: cd examples && ./run-example $(notdir $<) bos@4: bos@250: changelog := $(wildcard ../.hg/store/00changelog.[id]) bos@250: ifeq ($(changelog),) bos@250: changelog := $(wildcard ../.hg/00changelog.[id]) bos@250: endif bos@250: bos@250: build_id.tex: $(changelog) wbunaarfubss@249: echo -n '$(hg-id)' > build_id.tex bos@177: bos@177: hg_id.tex: $(hg) wbunaarfubss@249: echo -n '$(hg-version)' > hg_id.tex bos@16: bos@0: clean: bos@153: rm -rf dist html pdf \ bos@124: $(image-dot:%.dot=%.pdf) \ bos@124: $(image-dot:%.dot=%.png) \ bos@103: $(image-svg:%.svg=%.pdf) \ bos@103: $(image-svg:%.svg=%.png) \ bos@177: examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex bos@153: bos@157: install: pdf split $(dist-sources) bos@153: rm -rf dist bos@153: mkdir -p dist bos@153: cp pdf/hgbook.pdf dist bos@153: cp html/split/*.{css,html,png} dist bos@157: cp $(dist-sources) dist bos@153: bos@153: rsync: install bos@153: rsync -avz --delete dist sp.red-bean.com:public_html/hgbook