-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (87 loc) · 2.88 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
# A collection of rules for simplifying project's building process
# Project directories and structure
PROJECTDIR = .
ASYDIR = asy
BINDIR = bin
FIGDIR = fig
TEXDIR = tex
SRCDIR = src
CHDIRS = $(SRCDIR)/00_introduction $(SRCDIR)/01_lamberts_problem $(SRCDIR)/02_modern_solvers $(SRCDIR)/03_performance_comparison
STRUCTURE := $(PROJECTDIR) $(CHDIRS) $(TEXDIR)
# Main project file
MAINFILE = $(PROJECTDIR)/main
# Filter files by their type within actual project structure
ASYFILES := $(addsuffix /*.asy, $(ASYDIR))
PYFILES := $(addsuffix /*.py, $(BINDIR))
BAKFILES := $(addsuffix /*.bak0, $(STRUCTURE))
LOGFILES := $(addsuffix /*.log, $(STRUCTURE))
LOTFILES := $(addsuffix /*.lot, $(STRUCTURE))
LOFFILES := $(addsuffix /*.lof, $(STRUCTURE))
TEXFILES := $(addsuffix /*.tex, $(STRUCTURE))
AUXFILES := $(addsuffix /*.aux,$(STRUCTURE))
OUTFILES := $(addsuffix /*.out,$(STRUCTURE))
LOGFILES := $(addsuffix /*.log,$(STRUCTURE))
TOCFILES := $(addsuffix /*.toc,$(STRUCTURE))
GZFILES := $(addsuffix /*.gz,$(STRUCTURE))
BBLFILES := $(addsuffix /*.bbl,$(STRUCTURE))
BCFFILES := $(addsuffix /*.bcf,$(STRUCTURE))
BLGFILES := $(addsuffix /*.blg,$(STRUCTURE))
BLXFILES := $(addsuffix /*blx.bib,$(STRUCTURE))
RUNFILES := $(addsuffix /*run.xml,$(STRUCTURE))
JUNKFILES := $(AUXFILES) $(OUTFILES) $(LOGFILES) $(TOCFILES) $(GZFILES) $(BBLFILES) $(BCFFILES) $(BLGFILES) $(BLXFILES) $(RUNFILES)
# Latex engine and compiling options
LATEXENGINE = xelatex
LATEXOPTS = -interaction=batchmode
# Bibliography engine and options
BIBENGINE = biber
BIBOPTS = -quiet
# Latex indentation engine and options
LATEXINDENT = latexindent
LATEXINDENTOPTS = -s -w -y="defaultIndent: ' '"
# Asymptote options
ASYENGINE = asy
ASYOPTS = -maxtile "(256,256)"
# Default rule
all: clean pdf
# Generates a PDF and cleans all the workspace
pdf: compile clean
# Build auxiliary and PDF files
compile: binaries drawings
@echo "Building PDF file..."
@$(LATEXENGINE) $(LATEXOPTS) $(MAINFILE)
@$(BIBENGINE) $(BIBOPTS) $(MAINFILE)
# Compiles twice for linking properly the bibliography
@$(LATEXENGINE) $(LATEXOPTS) $(MAINFILE)
@rm -f $(FIGDIR)/*.png
@echo "Done!"
# Compile all Asymptote scripts
drawings:
@echo "Building Asymptote drawings..."
@$(ASYENGINE) $(ASYOPTS) $(ASYFILES)
@echo "Copying all files to $(FIGDIR) directory..."
@mv *.png $(FIGDIR)
@echo "Done!"
# Compile all the binaries
binaries:
@echo "Compiling binaries..."
@for py_file in $(PYFILES); do\
echo "$${py_file}";\
python $${py_file};\
done
@echo "Done!"
# Reformat all the required files for good code quality
reformat:
@echo "Reformating all TEX files..."
@for tex_file in $(TEXFILES); do\
echo "$${tex_file}";\
$(LATEXINDENT) $(LATEXINDENTOPTS) $${tex_file};\
done
@echo "Cleaning log files..."
@rm -rf $(LOGFILES) $(BAKFILES)
@echo "Done!"
# Clean workspace by removing junk files
clean:
@echo "Cleaning workspace..."
@rm -f $(JUNKFILES)
@rm -f $(FIGDIR)/*.png
@echo "Done!"