-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (38 loc) · 1.4 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
INPUT ?= src/session/index.tex
OUTPUT ?= $(shell basename "$(shell dirname "$(INPUT)")")
OUTPUT_DIRECTORY = build
LATEXMK_ARGS ?= -halt-on-error -MP -logfilewarninglist -pdf -shell-escape -interaction=nonstopmode -file-line-error -output-directory=$(OUTPUT_DIRECTORY)
TEXINPUTS = "$(shell pwd)/src//:"
TEXLIVE_RUN = TEXINPUTS=$(TEXINPUTS)
PANDOC_RUN = pandoc
PLANTUML_RUN = plantuml
MOGRIFY_RUN = magick mogrify
LATEXMK_COMMAND = $(TEXLIVE_RUN) latexmk $(LATEXMK_ARGS)
# Make does not offer a recursive wildcard function, so here's one:
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
.PHONY: build view
%:
$(MAKE) build INPUT=src/$@/index.tex
build :
$(LATEXMK_COMMAND) -jobname=$(OUTPUT) $(INPUT)
$(MAKE) chmodbuild
pandoc :
$(PANDOC_RUN) -s $(INPUT) -o $(OUTPUT)
latexindent :
$(TEXLIVE_RUN) latexindent
clean :
rm -rf build
lint :
# $(foreach file, $(call rwildcard,$(shell dirname "$(INPUT)"),*.tex), lacheck $(file);)
# $(foreach file, $(call rwildcard,$(shell dirname "$(INPUT)"),*.tex), chktex $(file);)
$(foreach file, $(call rwildcard,$(shell dirname "$(INPUT)"),*.tex), latexindent -l -w $(file);)
chmodbuild:
$(TEXLIVE_RUN) chmod 777 build
watch:
$(LATEXMK_COMMAND) -pvc -jobname=$(OUTPUT) $(INPUT)
$(MAKE) chmodbuild
fresh:
$(MAKE) chmodbuild clean build
buildall:
$(MAKE) clean
$(foreach file, $(wildcard src/**/index.tex), $(MAKE) build INPUT=$(file);)