-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (53 loc) · 2.57 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
################################################################################
## Document Parameters #########################################################
################################################################################
# Name of the main file, without the .tex extension.
DOCUMENT_FILENAME ?= main
################################################################################
## Binaries ####################################################################
################################################################################
PDFLATEX ?= pdflatex
################################################################################
## Deducing Main Target ########################################################
################################################################################
ifeq ($(strip $(PDFVIEWER)),)
main_target: compile
else
main_target: view
endif
################################################################################
## Basic Makefile Shenanigans ##################################################
################################################################################
COMMA =,
################################################################################
## Localising Relevant Files ###################################################
################################################################################
TEX_FILES = $(shell find ${CURDIR} -iname \*.tex)
################################################################################
## Making the Actual PDF #######################################################
################################################################################
$(DOCUMENT_FILENAME).pdf: $(TEX_FILES) Makefile
$(PDFLATEX) $(DOCUMENT_FILENAME).tex
$(PDFLATEX) $(DOCUMENT_FILENAME).tex
grep -i "\\(Reference\\|Citation\\).*undefined" \
$(DOCUMENT_FILENAME).log || true
################################################################################
## Secondary Targets ###########################################################
################################################################################
view: compile
$(PDFVIEWER) $(DOCUMENT_FILENAME).pdf
compile: $(DOCUMENT_FILENAME).pdf
$(MAKE) clean_mess
edit:
$(EDITOR) $(TEX_FILES)
clean:
rm -f \
$(filter-out $(DOCUMENT_FILENAME).tex,$(wildcard $(DOCUMENT_FILENAME).*))
################################################################################
clean_mess:
rm -f \
$(filter-out $(DOCUMENT_FILENAME).tex, \
$(filter-out $(DOCUMENT_FILENAME).pdf, \
$(wildcard $(DOCUMENT_FILENAME)\.*) \
) \
)