-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (67 loc) · 2.66 KB
/
Makefile
File metadata and controls
76 lines (67 loc) · 2.66 KB
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
MAIN_TEX := latex/praxis.tex
OUTDIR := build
ENGINE ?= pdflatex
ASSETS_DIR := $(OUTDIR)/assets
MOEBIUS_SVG := images/Moebius_strip.svg
MOEBIUS_PDF := $(ASSETS_DIR)/Moebius_strip.pdf
WORDMARK ?= 15
# You can override this with a full path, e.g.:
# make pdf WORDMARK_SVG_FILE="images/PRAXIS (12).svg"
WORDMARK_SVG_FILE ?= images/PRAXIS ($(WORDMARK)).svg
WORDMARK_PDF := $(ASSETS_DIR)/PRAXIS-wordmark.pdf
WORDMARK_SOURCE_TXT := $(ASSETS_DIR)/PRAXIS-wordmark.source.txt
ifeq ($(ENGINE),pdflatex)
LATEXMK_ENGINE :=
else ifeq ($(ENGINE),xelatex)
LATEXMK_ENGINE := -xelatex
else ifeq ($(ENGINE),lualatex)
LATEXMK_ENGINE := -lualatex
else
$(error ENGINE must be pdflatex, xelatex, or lualatex)
endif
.PHONY: pdf watch clean wordmark
.PHONY: recolor-wordmark
pdf: $(MOEBIUS_PDF) wordmark
@mkdir -p $(OUTDIR) $(OUTDIR)/chapters
LC_ALL=C LANG=C latexmk -cd -pdf $(LATEXMK_ENGINE) \
-outdir=../$(OUTDIR) -auxdir=../$(OUTDIR) \
-latexoption="-interaction=nonstopmode -halt-on-error -file-line-error" \
$(MAIN_TEX)
watch: $(MOEBIUS_PDF) wordmark
@mkdir -p $(OUTDIR) $(OUTDIR)/chapters
LC_ALL=C LANG=C latexmk -cd -pvc -pdf $(LATEXMK_ENGINE) \
-outdir=../$(OUTDIR) -auxdir=../$(OUTDIR) \
-latexoption="-interaction=nonstopmode -halt-on-error -file-line-error" \
$(MAIN_TEX)
$(MOEBIUS_PDF): $(MOEBIUS_SVG)
@mkdir -p $(ASSETS_DIR)
@# Convert SVG to PDF (for LaTeX inclusion without shell-escape).
inkscape $(MOEBIUS_SVG) --export-type=pdf --export-filename=$(MOEBIUS_PDF) >/dev/null
wordmark:
@mkdir -p $(ASSETS_DIR)
@# Convert SVG to PDF (for LaTeX inclusion without shell-escape).
@if [ ! -f "$(WORDMARK_SVG_FILE)" ]; then \
echo "Missing wordmark SVG: $(WORDMARK_SVG_FILE)"; \
echo "Try: make pdf WORDMARK=12 (or set WORDMARK_SVG_FILE=...)"; \
exit 1; \
fi
@current_src="$(WORDMARK_SVG_FILE)"; \
prev_src="$$(cat "$(WORDMARK_SOURCE_TXT)" 2>/dev/null || true)"; \
if [ -f "$(WORDMARK_PDF)" ] && [ "$$prev_src" = "$$current_src" ] && [ "$(WORDMARK_PDF)" -nt "$(WORDMARK_SVG_FILE)" ]; then \
echo "Wordmark up-to-date: $$current_src"; \
else \
echo "Building wordmark from: $$current_src"; \
inkscape "$$current_src" --export-type=pdf --export-filename="$(WORDMARK_PDF)" >/dev/null; \
printf "%s" "$$current_src" > "$(WORDMARK_SOURCE_TXT)"; \
fi
clean:
LC_ALL=C LANG=C latexmk -cd -C -pdf $(LATEXMK_ENGINE) \
-outdir=../$(OUTDIR) -auxdir=../$(OUTDIR) \
$(MAIN_TEX) || true
rm -rf $(OUTDIR)
recolor-wordmark:
@# Usage:
@# make recolor-wordmark WORDMARK=12
@# make recolor-wordmark WORDMARK_SVG_FILE="images/PRAXIS (12).svg" RECOLOR_SEED=123
@seed="$${RECOLOR_SEED:-$(WORDMARK)}"; \
python3 scripts/recolor_svg_paths.py "$(WORDMARK_SVG_FILE)" --seed "$$seed" --ensure-stops