-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathcommon.mk
82 lines (66 loc) · 2.05 KB
/
common.mk
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
ifndef LANGUAGE
$(error LANGUAGE is not defined)
endif
.PHONY : all check clean commands html pages pdf spell words
# Settings
OUTPUT=../docs/${LANGUAGE}
TEX=$(filter-out temp.tex,$(wildcard *.tex))
BIB=$(wildcard *.bib)
FIGURES_SRC=$(wildcard figures/*)
FIGURES_DST=$(patsubst %,${OUTPUT}/%,${FIGURES_SRC})
# Commands.
LATEX=pdflatex --shell-escape --recorder
PANDOC=pandoc \
--standalone \
--css=../static/bootstrap.min.css \
--css=../static/tango.css \
--css=../static/book.css \
--toc \
--toc-depth=2 \
--csl=../tex/chicago.csl
# Controls
all : commands
## commands : show all commands.
commands :
@grep -h -E '^##' ${MAKEFILE_LIST} | sed -e 's/## //g' | column -t -s ':'
## html : re-make HTML.
html: tex.html bib.html ../bin/post-pandoc.py
@mkdir -p ${OUTPUT}
../bin/post-pandoc.py tex.html bib.html > ${OUTPUT}/index.html
tex.html: temp.tex template.html
${PANDOC} --template=template.html --bibliography=book.bib --output=tex.html temp.tex
bib.html: book.bib ../bin/bib2html.py
../bin/bib2html.py < book.bib > bib.html
temp.tex: ${TEX} ${FIGURES_DST} ../bin/pre-pandoc.py
../bin/pre-pandoc.py < book.tex > temp.tex
## pdf : Re-make PDF.
pdf : ${TEX} ${BIB}
${LATEX} book
biber book
makeindex book
${LATEX} book
${LATEX} book
${LATEX} book
# Copy figures.
${OUTPUT}/figures/% : figures/%
@mkdir -p ${OUTPUT}/figures
@cp $< $@
## check : check internal consistency.
check :
@../bin/check.py -b book.bib -f figures ${TEX}
## spell : check spelling.
spell :
@-cat ${TEX} | aspell -t list | sort | uniq | diff -y --suppress-common-lines - wordlist.txt
## pages : pages per chapter.
pages : ${PDF}
@../bin/pages.py book.log book.toc
## words : count words.
words :
@../bin/texcount.pl -brief ${TEX} | sed -e 's/\+.*://g' -e 's/+.* Total//g' | sort -n -r
## clean : Clean things up.
clean :
@rm -f book.pdf
@rm -f *.aux *.bak *.bbl *.bcf *.blg *.dvi *.fls *.idx *.ilg *.ind *.lof *.log *.lot *.out *.pyg *.run.xml *.tmp *.toc *.xref
@rm -f tex.html bib.html temp.tex
@find . -name '*~' -delete
@find . -name '_minted-*' -prune -exec rm -r "{}" \;