blob: e11d7814245b49a4e64c0867985cafe6e967f3cf (
plain)
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
|
#
# Author: Jake Zimmerman <jake@zimmerman.io>
#
# ===== Usage ================================================================
#
# NOTE:
# When running these commands at the command line, replace $(TARGET) with
# the actual value of the TARGET variable.
#
#
# make Compile all *.md files to PDFs
# make <filename>.pdf Compile <filename>.md to a PDF
# make <filename>.tex Generate the intermediate LaTeX for <filename>.md
#
# make view Compile $(TARGET).md to a PDF, then view it
# make again Force everything to recompile
#
# make clean Get rid of all intermediate generated files
# make veryclean Get rid of ALL generated files:
#
# make print Send $(TARGET).pdf to the default printer:
#
# ============================================================================
TARGET=sample
all: $(patsubst %.md,%.pdf,$(wildcard *.md))
PANDOC_FLAGS =\
-f markdown+tex_math_single_backslash \
-t latex \
LATEX_FLAGS = \
PDF_ENGINE = xelatex
PANDOCVERSIONGTEQ2 := $(shell expr `pandoc --version | grep ^pandoc | sed 's/^.* //g' | cut -f1 -d.` \>= 2)
ifeq "$(PANDOCVERSIONGTEQ2)" "1"
LATEX_FLAGS += --pdf-engine=$(PDF_ENGINE)
else
LATEX_FLAGS += --latex-engine=$(PDF_ENGINE)
endif
all: $(patsubst %.md,%.pdf,$(wildcard *.md))
# Generalized rule: how to build a .pdf from each .md
%.pdf: %.md
pandoc $(PANDOC_FLAGS) $(LATEX_FLAGS) -o $@ $<
# Generalized rule: how to build a .tex from each .md
%.tex: %.md
pandoc --standalone $(PANDOC_FLAGS) -o $@ $<
touch:
touch *.md
again: touch all
clean:
rm -f *.aux *.log *.nav *.out *.snm *.toc *.vrb || true
veryclean: clean
rm -f *.pdf *.md
view: $(TARGET).pdf
if [ "Darwin" = "$(shell uname)" ]; then open $(TARGET).pdf ; else xdg-open $(TARGET).pdf ; fi
print: $(TARGET).pdf
lpr $(TARGET).pdf
.PHONY: all again touch clean veryclean view print
|