-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
82 lines (59 loc) · 2.1 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
#
# Makefile
# Malcolm Ramsay, 2018-07-03 10:48
#
# Find the direcotry of this makefile so files can be referenced relative to this
WORK_DIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
# Find all the markdown files which have a path starting with two digits
subfiles := $(shell find . -name "*.md" -path "./[0-9][0-9]*")
subfiles := $(subfiles:.md=.tex)
# The file which comprise the preamble
preamble = $(wildcard Classes/*.sty)
# The directory which will contain all the temporary output files
makedir = output
makesubdirs = $(addprefix $(makedir)/, $(wildcard [0-9]*))
pandoc_filters = --filter $(WORK_DIR)/src/pandoc-svg.py --filter pandoc-crossref
pandoc_options = --listings --number-sections --metadata-file=$(WORK_DIR)/pandoc_options.yml
figures = $(patsubst %.gv, %.pdf, $(shell find . -name "*.gv"))
.PHONY: all clean clean_subfiles test figures submodules
all: thesis.pdf
submodules:
git submodule update
figures: $(figures)
thesis.pdf: thesis.tex $(subfiles) bibliography/bibliography.bib $(preamble) version.tex | $(makedir) $(makesubdirs)
tectonic -o $(makedir) --keep-intermediates -r0 $<
if [ -f $(makedir)/$(notdir $(<:.tex=.bcf)) ]; then biber --input-directory $(makedir) $(notdir $(<:.tex=)); fi
tectonic -o $(makedir) --keep-intermediates $<
cp $(makedir)/$(notdir $@) .
%.tex: %.md $(figures) # Convert markdown files to latex using pandoc
cd $(dir $<); pandoc -t latex $(notdir $<) -o $(notdir $@) --biblatex $(pandoc_filters) $(pandoc_options)
$(makedir) $(makesubdirs): %:
mkdir -p $@
%.pdf: %.gv
dot -Tpdf $< -o $@
test:
mdl .
clean: clean_subfiles
rm -rf output/*
rm -f thesis.{pdf,bcf,blg,bbl}
rm -f texput.log
clean_subfiles:
rm -f $(subfiles)
rm -f pandoc.out
git submodule foreach git clean -fX
#
# Linting
#
# A set of rules to enfore style within the repsitory
#
.PHONY: lint style grammar
lint: style grammar
style:
@./node_modules/.bin/markdownlint $(subfiles:.tex=.md)
fix:
@./node_modules/.bin/markdownlint --fix $(subfiles:.tex=.md)
@./node_modules/.bin/textlint --fix $(subfiles:.tex=.md)
grammar:
@./node_modules/.bin/textlint $(subfiles:.tex=.md)
# vim:ft=make
#