-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (60 loc) · 1.74 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
# build settings
RM ?= rm -rf
FIND ?= find
LATEXMK ?= latexmk
LATEXPAND ?= latexpand
LATEXDIFF ?= latexdiff
EXTRACTBB ?= extractbb
POETRY ?= poetry
LATEXMAKE := $(POETRY) run $(LATEXMK)
# source files
TARGET ?= main.pdf
MAIN_SOURCE := $(TARGET:.pdf=.tex)
MAIN_SOURCE_BACKUP := $(MAIN_SOURCE:.tex=.backup.tex)
DIFF_TARGET := $(TARGET:.pdf=.diff.pdf)
MAIN_DIFF_SOURCE := $(DIFF_TARGET:.pdf=.tex)
# main tasks
.SUFFIXES: .tex .dvi .pdf
.PHONY: all
all: .installed-stamp build
.PHONY: build extractbb backup diff
build: extractbb
$(LATEXMAKE) $(MAIN_SOURCE)
.installed-stamp: pyproject.toml poetry.lock tlmgr_requirement.bash
$(POETRY) install
./tlmgr_requirement.bash || echo "run ./tlmgr_requirement.bash manually"
@touch $@
extractbb:
$(EXTRACTBB) asset/*.pdf
backup:
$(LATEXPAND) --makeatletter $(MAIN_SOURCE) > $(MAIN_SOURCE_BACKUP)
diff:
$(LATEXPAND) --makeatletter $(MAIN_SOURCE) > $(MAIN_SOURCE:.tex=.expand.tex)
$(LATEXDIFF) -e utf8 -t CFONT $(MAIN_SOURCE_BACKUP) $(MAIN_SOURCE:.tex=.expand.tex) > $(MAIN_DIFF_SOURCE)
$(RM) $(MAIN_SOURCE:.tex=.expand.tex)
$(LATEXMAKE) $(DIFF_TARGET)
# tasks
.tex.pdf:
$(LATEXMAKE) $<
.PHONY: watch watch-without-prev
watch:
$(LATEXMAKE) -pvc $(MAIN_SOURCE)
watch-without-prev:
$(LATEXMAKE) -pvc -view=none $(MAIN_SOURCE)
.PHONY: clean lessclean remove
clean: lessclean
$(FIND) . -name '*.snm' -delete
$(FIND) . -name '*.fls' -delete
$(FIND) . -name '*.*pk' -delete
$(FIND) . -name '*.tfm' -delete
$(FIND) . -name '*.tmp' -delete
lessclean:
$(LATEXMAKE) -c -bibtex
$(FIND) . -name '*.aux' -delete
$(FIND) . -name '*.synctex.gz*' -delete
$(FIND) . -name '*.dvi' -delete
$(FIND) . -name '*.nav' -delete
$(FIND) . -name '*.vrb' -delete
$(FIND) . -name '*.toc' -delete
remove: clean
$(RM) $(TARGET)