-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
77 lines (64 loc) · 2.11 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
# Makefile borrowed from here: https://github.com/pinga-lab/paper-template/blob/master/manuscript/Makefile
# Build the PDF
#
# Commands:
#
# make Compile PDF in the output folder
# make show Show the generated PDF (only Linux and Mac)
# make clean Delete all generated files
# CONFIGURATION
###############################################################################
# The name of the main .tex file to build.
# Other latex files should be included into this one.
PROJECT = thesis
# Folder with the figure files
FIGDIR = "./"
# Folder where output will be placed
OUTDIR = output
# Name of the output file
OUTPUT = $(OUTDIR)/$(PROJECT).pdf
### File Types (for dependencies)
TEX = $(wildcard *.tex)
BIB = $(wildcard *.bib)
STY = $(wildcard *.sty)
CLS = $(wildcard *.cls)
BST = $(wildcard *.bst)
EPS = $(wildcard $(FIGDIR)/*.eps)
PNG = $(wildcard $(FIGDIR)/*.png)
PDF = $(wildcard $(FIGDIR)/*.pdf)
JPG = $(wildcard $(FIGDIR)/*.jpg)
FIGS = $(EPS) $(PNG) $(PDF) $(JPG)
### Compilation Flags
LATEX_FLAGS = -halt-on-error -output-directory $(OUTDIR)/
### Set commands for opening the generated PDF
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
PDFVIEWER = xdg-open
endif
ifeq ($(UNAME), Darwin)
PDFVIEWER = open
endif
# TARGETS
###############################################################################
# Main target. Executed when calling 'make' with no arguments
all: $(OUTPUT)
# Open the PDF
show: $(OUTPUT)
@ # Redirect stdout and stderr to /dev/null for silent execution
@ (${PDFVIEWER} $(OUTPUT) > /dev/null 2>&1 & )
### Clean
# This target cleans the temporary files generated by the tex programs in
# use. All temporary files generated by this makefile will be placed in OUTDIR
# so cleanup is easy.
clean::
rm -rf $(OUTDIR)/ *.aux
rm -rf $(FIGDIR)/*-eps-converted-to.pdf
# Compile the PDF output
$(OUTPUT): $(PROJECT).tex $(STY) $(CLS) $(BIB) $(BST) $(FIGS) $(TEX)
# Create the output directory if it doesn't exist
mkdir -p $(OUTDIR)/
cp $(BIB) $(BST) $(OUTDIR)
pdflatex $(LATEX_FLAGS) $<
cd $(OUTDIR) && bibtex $(patsubst %.tex,%,$<)
pdflatex $(LATEX_FLAGS) $< 1>/dev/null
pdflatex $(LATEX_FLAGS) $<