-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
52 lines (42 loc) · 1.03 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
SHELL = /bin/bash
LATEX = platex
DVIPDF = dvipdfmx
PANDOC = pandoc
PANDOC_OPT = --from=markdown+east_asian_line_breaks
RM = rm
ROOT = rule
ROOT_MD = $(ROOT).md
TEMPLATE_TEX = template.tex
ROOT_TEX = $(ROOT).tex
ROOT_DVI = $(ROOT).dvi
ROOT_PDF = $(ROOT).pdf
ROOT_AUX = $(ROOT).aux
GENERATED_FILES = $(ROOT).log
.DEFAULT_GOAL = pdf
.PHONY : pdf
pdf : $(ROOT_PDF)
$(ROOT_PDF) : $(ROOT_DVI)
$(DVIPDF) $(ROOT_DVI)
.PHONY : dvi
dvi : $(ROOT_DVI)
$(ROOT_DVI) : $(ROOT_TEX) $(ROOT_AUX)
$(LATEX) -halt-on-error $(ROOT_TEX)
$(LATEX) -halt-on-error $(ROOT_TEX)
.PHONY : aux
aux : $(ROOT_AUX)
$(ROOT_AUX) : $(ROOT_TEX)
$(LATEX) -halt-on-error $(ROOT_TEX)
.PHONY : tex
tex : $(ROOT_TEX)
$(ROOT_TEX) : $(ROOT_MD) $(TEMPLATE_TEX)
# Using sed to write natural Markdown enumeration notation.
# c.f. https://stackoverflow.com/a/33675236
$(PANDOC) <(sed -e 's/^\( *\)\*/\1#./g' $(ROOT_MD)) --template=$(TEMPLATE_TEX) -o $(ROOT_TEX)
.PHONY : clean
clean:
$(RM) \
$(ROOT_PDF) \
$(ROOT_TEX) \
$(ROOT_DVI) \
$(ROOT_AUX) \
$(GENERATED_FILES); true