-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
57 lines (44 loc) · 1.31 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/make -f
VOL ?= 6
NAME = vol_$(VOL)/newsletter_$(VOL)
OUTPUT_HTML = $(NAME).html
OUTPUT_PDF = $(NAME).pdf
OUTPUT_ODT = $(NAME).odt
OUTPUT_TEX = $(NAME).tex
OUTPUTS = $(OUTPUT_HTML) \
$(OUTPUT_PDF) \
$(OUTPUT_ODT) \
$(OUTPUT_TEX)
PDFLATEX_FLAGS = -interaction batchmode
RST2LATEX_FLAGS = --template=template.tex \
--no-section-numbering
.PHONY: all clean html pdf odt tex
.SUFFIXES: .rst .html .pdf .tex .odt
all: $(OUTPUTS)
# convenience aliases
html: $(OUTPUT_HTML)
pdf: $(OUTPUT_PDF)
odt: $(OUTPUT_ODT)
tex: $(OUTPUT_TEX)
clean:
rm -f $(OUTPUTS)
.rst.html:
rst2html --stylesheet=stylesheets/mainstyle.css --toc-top-backlinks $< > $@
.tex.pdf:
maxpasses=5; \
file=`basename $< .tex`; \
cd `dirname $<` || exit 1; \
pdflatex $(PDFLATEX_FLAGS) "$$file.tex" >/dev/null || exit 2; \
while test $$maxpasses -gt 0 && grep -q -i 'rerun' $$file.log; do \
pdflatex $(PDFLATEX_FLAGS) "$$file.tex" >/dev/null || exit 3; \
maxpasses=`expr $$maxpasses - 1`; \
done; \
rm -f "$$file.log" "$$file.toc" "$$file.out" "$$file.aux"
.rst.tex:
rst2latex $(RST2LATEX_FLAGS) $< > $@ || rm -f $@
sed -r -f rst2latex.sed -i $@ || rm -f $@
.rst.odt:
rst2odt $< > $@
# extra dependencies we cannot add to suffix rules
$(OUTPUT_HTML): stylesheets/mainstyle.css
$(OUTPUT_TEX): template.tex rst2latex.sed