-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
132 lines (116 loc) · 3.12 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
123
124
125
126
127
128
129
130
# =============================================================
# Some Notes About Makefiles
# =============================================================
# cible: dependance
# commandes
# $@ Le nom de la cible
# $< Le nom de la première dépendance
# $^ La liste des dépendances
# $? La liste des dépendances plus récentes que la cible
# $* Le nom du fichier sans suffixe
# The .PHONY rule keeps make from processing a file named "watch" or "clean".
# =============================================================
# =============================================================
# Define Some Variables
# =============================================================
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
PDFVIEWER = evince
endif
ifeq ($(UNAME), Darwin)
PDFVIEWER = mupdf-gl
endif
MAINDIRECTORY := $(shell pwd)
# =============================================================
# =============================================================
# Main builders
# =============================================================
all: pdf
# PDF
.PHONY: pdf
ifeq ($(f),)
ifeq ($(t), tikz)
pdf:
cd ressources/tikz/ && \
for file in *.tex; do \
latexmk -r "$(MAINDIRECTORY)/.latexmkrc_subfiles" $${file} && \
latexmk -r "$(MAINDIRECTORY)/.latexmkrc_subfiles" -c $${file} && \
pdfcrop "$${file%.tex}.pdf" "$${file%.tex}.pdf" ; \
done
else
pdf:
mkdir -p main/build && cd main && \
latexmk -r "$(MAINDIRECTORY)/.latexmkrc_main" $(PREVIEW_CONTINUOUSLY) main.tex
endif
else
ifeq ($(t), tikz)
pdf:
cd ressources/tikz/ && \
latexmk -r "$(MAINDIRECTORY)/.latexmkrc_subfiles" $(f) && \
latexmk -r "$(MAINDIRECTORY)/.latexmkrc_subfiles" -c $(f) && \
pdfcrop "$${f}.pdf" "$${f}.pdf" && \
(${PDFVIEWER} $${f}.pdf &> /dev/null &)
else
pdf:
cd $(f) && \
latexmk -r "$(MAINDIRECTORY)/.latexmkrc_subfiles" -bibtex $(f)/$(f) && \
latexmk -r "$(MAINDIRECTORY)/.latexmkrc_subfiles" -c && \
(${PDFVIEWER} $(f).pdf &> /dev/null &)
endif
endif
# CLEAN
.PHONY: clean
ifeq ($(f),)
clean:
latexmk -cd -c -bibtex main/build/main.pdf
else
clean:
cd $(f) && \
latexmk -r "$(MAINDIRECTORY)/.latexmkrc_subfiles" -c
endif
# OPEN
.PHONY: open
ifeq ($(f),)
open:
(${PDFVIEWER} main/build/main.pdf &> /dev/null &)
else
ifeq ($(t), tikz)
open:
(${PDFVIEWER} ressources/tikz/$(f).pdf &> /dev/null &)
else
open:
(${PDFVIEWER} $(f)/$(f).pdf &> /dev/null &)
endif
endif
# WATCH
.PHONY: watch
ifeq ($(f),)
watch:
mkdir -p main/build && cd main && \
latexmk -r $(MAINDIRECTORY)/.latexmkrc_main $(PREVIEW_CONTINUOUSLY) -pvc main.tex
else
ifeq ($(t), tikz)
watch:
cd ressources/tikz/ && \
latexmk -r $(MAINDIRECTORY)/.latexmkrc_subfiles -pvc $(f) && \
latexmk -r $(MAINDIRECTORY)/.latexmkrc_subfiles -c $(f) && \
pdfcrop "$${f}.pdf" "$${f}.pdf"
else
watch:
cd $(f) && \
latexmk -r $(MAINDIRECTORY)/.latexmkrc_subfiles -bibtex -pvc $(f)/$(f) && \
latexmk -r $(MAINDIRECTORY)/.latexmkrc_subfiles -c $(f)
endif
endif
.PHONY: subfile
ifeq ($(f),)
else
subfile:
mkdir $(f) && cp $(MAINDIRECTORY)/snippets/subfile.tex $(MAINDIRECTORY)/$(f)/$(f).tex
endif
.PHONY: tikz
ifeq ($(f),)
else
tikz:
cp $(MAINDIRECTORY)/snippets/tikzpicture.tex $(MAINDIRECTORY)/ressources/tikz/$(f).tex
endif