hgbook

view es/Makefile @ 901:9768fafa5977

Add html template for documents.
author dukebody <dukebody@gmail.com>
date Mon Oct 26 14:56:39 2009 +0100 (2009-10-26)
parents 9412f706651e
children
line source
1 # This makefile requires GNU make.
3 sources := \
4 00book.tex \
5 99book.bib \
6 99defs.tex \
7 build_id.tex \
8 branch.tex \
9 cmdref.tex \
10 collab.tex \
11 concepts.tex \
12 daily.tex \
13 filenames.tex \
14 hg_id.tex \
15 hgext.tex \
16 hook.tex \
17 intro.tex \
18 mq.tex \
19 mq-collab.tex \
20 mq-ref.tex \
21 preface.tex \
22 srcinstall.tex \
23 template.tex \
24 tour-basic.tex \
25 tour-merge.tex \
26 undo.tex
28 image-sources := \
29 feature-branches.dot \
30 filelog.svg \
31 kdiff3.png \
32 metadata.svg \
33 mq-stack.svg \
34 note.png \
35 revlog.svg \
36 snapshot.svg \
37 tour-history.svg \
38 tour-merge-conflict.svg \
39 tour-merge-merge.svg \
40 tour-merge-pull.svg \
41 tour-merge-sep-repos.svg \
42 undo-manual.dot \
43 undo-manual-merge.dot \
44 undo-non-tip.dot \
45 undo-simple.dot \
46 wdir.svg \
47 wdir-after-commit.svg \
48 wdir-branch.svg \
49 wdir-merge.svg \
50 wdir-pre-branch.svg
52 image-dot := $(filter %.dot,$(image-sources))
53 image-svg := $(filter %.svg,$(image-sources))
54 image-png := $(filter %.png,$(image-sources))
56 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
57 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
59 example-sources := \
60 backout \
61 bisect \
62 branching \
63 branch-named \
64 branch-repo \
65 cmdref \
66 daily.copy \
67 daily.files \
68 daily.rename \
69 daily.revert \
70 extdiff \
71 filenames \
72 hook.msglen \
73 hook.simple \
74 hook.ws \
75 issue29 \
76 mq.guards \
77 mq.qinit-help \
78 mq.dodiff \
79 mq.id \
80 mq.tarball \
81 mq.tools \
82 mq.tutorial \
83 rename.divergent \
84 rollback \
85 tag \
86 template.simple \
87 template.svnstyle \
88 tour \
89 tour-merge-conflict
91 example-prereqs := \
92 /usr/bin/merge
94 dist-sources := \
95 ../html/hgicon.png \
96 ../html/index.html.var \
97 ../html/index.en.html \
98 ../html/index.es.html
100 latex-options = \
101 -interaction batchmode \
102 -output-directory $(dir $(1)) \
103 -jobname $(basename $(notdir $(1)))
105 hg = $(shell which hg)
107 hg-id = $(shell hg parents --template '{node|short}, fechado {date|isodate},\n')
109 hg-version = $(shell hg version -q | \
110 sed 's,.*(versiĆ³n \(unknown\|[a-f0-9+]*\)),\1,')
112 all: pdf html
114 pdf: pdf/hgbook.pdf
116 define pdf
117 mkdir -p $(dir $@)
118 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
119 cp 99book.bib $(dir $@)
120 cd $(dir $@) && bibtex $(basename $(notdir $@))
121 cd $(dir $@) && makeindex $(basename $(notdir $@))
122 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
123 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
124 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
125 endef
127 pdf/hgbook.pdf: $(sources) examples $(image-pdf)
128 $(call pdf)
130 html: onepage split
132 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
134 html/onepage/%: %
135 cp $< $@
137 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
139 html/split/%: %
140 cp $< $@
142 # This is a horrible hack to work around the fact that the htlatex
143 # command in tex4ht is itself a horrible hack. I really don't want to
144 # include verbatim the big wad of TeX that is repeated in that script,
145 # but I've given up and run a hacked copy as htlatex.book here.
147 define htlatex
148 mkdir -p $(dir $(1))
149 cp 99book.bib $(dir $(1))
150 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
151 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
152 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
153 ./fixhtml.py $(dir $(1))/*.html
154 rm $(dir $(1))/hgbook.css
155 endef
157 html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg
158 $(call htlatex,$@,$<)
160 html/split/hgbook.html: $(sources) examples bookhtml.cfg
161 $(call htlatex,$@,$<,2)
163 # Produce 90dpi PNGs for the web.
165 %.png: %.svg fixsvg
166 ./fixsvg $<
167 inkscape -D -e $@ $<-tmp.svg
168 rm $<-tmp.svg
170 %.svg: %.dot
171 dot -Tsvg -o $@ $<
173 # Produce eps & pdf for the pdf
175 %.pdf: %.eps
176 epstopdf $<
178 %.eps: %.svg
179 ./fixsvg $<
180 inkscape -E $@ $<-tmp.svg
181 rm $<-tmp.svg
183 %.eps: %.dot
184 dot -Tps -o $@ $<
186 examples: $(example-prereqs) examples/.run
188 examples/.run: $(example-sources:%=examples/%.run)
189 touch examples/.run
191 examples/%.run: examples/% examples/run-example
192 cd examples && ./run-example $(notdir $<)
194 changelog := $(wildcard ../.hg/store/00changelog.[id])
195 ifeq ($(changelog),)
196 changelog := $(wildcard ../.hg/00changelog.[id])
197 endif
199 build_id.tex: $(changelog)
200 echo -n '$(hg-id)' > build_id.tex
202 hg_id.tex: $(hg)
203 echo -n '$(hg-version)' > hg_id.tex
205 clean:
206 rm -rf dist html pdf \
207 $(image-dot:%.dot=%.pdf) \
208 $(image-dot:%.dot=%.png) \
209 $(image-svg:%.svg=%.pdf) \
210 $(image-svg:%.svg=%.png) \
211 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
213 install: pdf split $(dist-sources)
214 rm -rf dist
215 mkdir -p dist
216 cp pdf/hgbook.pdf dist
217 cp html/split/*.{css,html,png} dist
218 cp html/onepage/hgbook.html dist/onepage.html
219 ln -s index.es.html dist/index.html
220 cp $(dist-sources) dist
222 rsync: install
223 rsync -avz --delete dist/ ikks@sulaco.devnull.li:public_html/hgbook/