-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
123 lines (98 loc) · 2.09 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#
#
#
# Variables
#
#
#
export MAKE_FLAGS=--no-print-directory
export OUT=$(shell pwd)/bin
export OUT_LATEX=$(OUT)/latex/
export OUT_HTML=$(OUT)/html/
export SCRIPTS=$(shell pwd)/scripts/
## Source directory
SRC_DIR=$(shell pwd)/src
## All markdown files in the working directory
export SOURCES=$(shell find $(SRC_DIR) -name "*.md" | sort)
## Templates
export TEMPLATE=$(shell pwd)/template
# target
export TARGET=$(OUT)/document.pdf
#
#
#
# Binary and argument construction
#
#
#
ECHO_CMD=$(shell which echo)
ECHO_ARG=-e
ECHO=$(ECHO_CMD) $(ECHO_ARG)
export ECHO
CP_CMD=$(shell which cp)
CP_ARG=-nr
CP=$(CP_CMD) $(CP_ARG)
export CP
MKDIR_CMD=$(shell which mkdir)
MKDIR_ARG=-p
MKDIR=$(MKDIR_CMD) $(MKDIR_ARG)
export MKDIR
RM_CMD=$(shell which rm)
RM_ARG=-fr
RM=$(RM_CMD) $(RM_ARG)
export RM
#
# Filters
#
export FILTER_SCRIPTS=$(shell find $(SCRIPTS) -name "*-filter.py")
export FILTERING_ARGS=$(foreach x, $(FILTER_SCRIPTS), --filter $x)
#
# CC
#
PANDOC_CC=$(shell which pandoc)
PANDOC_PARAMS=-r \
markdown+simple_tables+table_captions+yaml_metadata_block+definition_lists+footnotes+inline_notes+raw_tex+fenced_code_blocks+fenced_code_attributes+backtick_code_blocks \
--filter pandoc-crossref \
--filter pandoc-citeproc \
$(FILTERING_ARGS)
export PANDOC=$(PANDOC_CC) $(PANDOC_PARAMS)
#
# Settings
#
DOCUMENT_SETTINGS=\
--standalone \
-M listings=true \
--latex-engine=xelatex \
-V fontsize=12pt \
-V documentclass:book \
-V papersize:a4paper \
-V classoption:openright \
--chapters \
--bibliography=papers.bib \
--include-in-header $(TEMPLATE)/preamble.tex \
--csl=$(TEMPLATE)/csl/acm-sig-proceedings.csl \
--highlight-style pygments
#
#
# Tasks
#
#
all: $(TARGET)
@$(ECHO) "[READY ]"
$(TARGET): $(OUT)
@$(ECHO) "[PANDOC]"
@$(PANDOC) $(DOCUMENT_SETTINGS) $(SOURCES) -o $(TARGET)
latex-out:
@$(ECHO) "[PANDOC]"
@$(PANDOC) $(DOCUMENT_SETTINGS) $(SOURCES) --to latex
$(OUT):
@$(ECHO) "[MKDIR ]"
@$(MKDIR) $(OUT)
clean:
@$(ECHO) "[RM ] $(TARGET)"
@$(RM) $(TARGET)
@$(ECHO) "[RMDIR ] $(OUT)"
@$(RM) $(OUT)
@$(ECHO) "[RM -r ] generated-images"
@$(RM) generated-images
.PHONY: $(TARGET)