-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
95 lines (81 loc) · 2.58 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
# Build the PDF of the manuscript.
#
# Commands:
#
# make Compile PDF in the output folder
# make show Show the generated PDF (only Linux and Mac)
# make wc Count the number of words in manuscript
# make clean Delete all generated files
# make greyscale Create greyscale version of the PDF
# CONFIGURATION
###############################################################################
# The name of the main .tex file to build.
# Other latex files should be included into this one.
PROJECT = four-phase-inversion
# 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 & )
# Count the number of words in the manuscript. Not perfect and will skip any
# included files.
wc:
@ detex $(PROJECT).tex | sed '1,/Quantitative/d' | wc -w
# Check the text for common mistakes
lint:
@ proselint $(PROJECT).tex
# Create greyscale PDF version
greyscale: $(OUTPUT)
gs \
-sDEVICE=pdfwrite \
-sProcessColorModel=DeviceGray \
-sColorConversionStrategy=Gray \
-dOverrideICC \
-o $(patsubst %.pdf,%-greyscale.pdf,$<) \
-f $<
### 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) $<