-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
160 lines (139 loc) · 5.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# ----------------------------------------------------------------------------
# PROJECT DIRECTORIES
# ----------------------------------------------------------------------------
PROJECTDIR = .
ASYDIR = asy
BINDIR = bin
FIGDIR = fig
TEXDIR = tex
SRCDIR = src
OUTDIR = $(PROJECTDIR)
# ----------------------------------------------------------------------------
# MAIN FILE AND CHAPTERS
# ----------------------------------------------------------------------------
MAINFILE = $(PROJECTDIR)/main
RENDERFILE = main
CHDIRS = $(SRCDIR)/00_introduction
# ----------------------------------------------------------------------------
# CRITICAL FILES AND SUFFIXES
# ----------------------------------------------------------------------------
STRUCTURE = $(PROJECTDIR) $(TEXDIR) $(CHDIRS)
ASYFILES := $(addsuffix /*.asy, $(ASYDIR))
AUXFILES := $(addsuffix /*.aux,$(STRUCTURE))
BAKFILES := $(addsuffix /*.bak*,$(STRUCTURE))
BBLFILES := $(addsuffix /*.bbl,$(STRUCTURE))
BCFFILES := $(addsuffix /*.bcf,$(STRUCTURE))
BLGFILES := $(addsuffix /*.blg,$(STRUCTURE))
BLXFILES := $(addsuffix /*blx.bib,$(STRUCTURE))
GZFILES := $(addsuffix /*.gz,$(STRUCTURE))
LOFFILES := $(addsuffix /*.lof,$(STRUCTURE))
LOGFILES := $(addsuffix /*.log,$(STRUCTURE))
LOTFILES := $(addsuffix /*.lot,$(STRUCTURE))
OUTFILES := $(addsuffix /*.out,$(STRUCTURE))
PYFILES := $(addsuffix /*.py, $(BINDIR))
RUNFILES := $(addsuffix /*run.xml,$(STRUCTURE))
TEXFILES := $(addsuffix /*.tex,$(STRUCTURE))
TOCFILES := $(addsuffix /*.toc,$(STRUCTURE))
JUNKFILES := $(AUXFILES) $(AUXFILES) \
$(BAKFILES) $(BBLFILES) $(BCFFILES) $(BLGFILES) $(BLXFILES) \
$(GZFILES) \
$(LOFFILES) $(LOGFILES) $(LOTFILES) \
$(OUTFILES) \
$(RUNFILES) \
$(TOCFILES)
# ----------------------------------------------------------------------------
# TOOLS AND CONFIGURATION
# ----------------------------------------------------------------------------
# Latex engine and compiling options
LATEXENGINE = xelatex
LATEXOPTS = -interaction=batchmode -output-directory=$(OUTDIR) -jobname=$(RENDERFILE)
# 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)"
# Finding tool engine and options
FIND = find
FINDOPTS =
# ----------------------------------------------------------------------------
# CRITICAL FILES AND SUFFIX
# ----------------------------------------------------------------------------
ASYFILES := $(addsuffix /*.asy, $(ASYDIR))
PYFILES := $(addsuffix /*.py, $(BINDIR))
BAKFILES := $(addsuffix /*.bak0, $(STRUCTURE))
LOGFILES := $(addsuffix /*.log, $(STRUCTURE))
LOTFILES := $(addsuffix /*.lot, $(STRUCTURE))
LOFFILES := $(addsuffix /*.lof, $(STRUCTURE))
LOFFILES := $(addsuffix /*.tex, $(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)
# ----------------------------------------------------------------------------
# ALL MAKE RULES ARE DEFINED BELOW
# ----------------------------------------------------------------------------
# Default rule
all: clean pdf
# Generates a PDF and cleans all the work space
pdf: compile
# Build auxiliary and PDF files
compile: binaries drawings
@echo "Building PDF file..."
@$(LATEXENGINE) $(LATEXOPTS) $(MAINFILE)
@$(BIBENGINE) $(BIBOPTS) $(RENDERFILE)
# Compile twice for properly linking the bibliography
@$(LATEXENGINE) $(LATEXOPTS) $(MAINFILE)
@rm -f $(FIGDIR)/*.png
@echo "Done!"
# Compile all Asymptote scripts
drawings:
@echo "Compiling drawings..."
ifeq ($(ASYFILES), $(ASYDIR)/*.asy)
@echo "No Asymptote drawings were found in $(ASYDIR)!"
else
@$(ASYENGINE) $(ASYOPTS) $(ASYFILES)
@echo "Copying all files to $(FIGDIR) directory..."
@mv *.png $(FIGDIR)
@echo "Done!"
endif
# Compile all the binaries
binaries:
@echo "Compiling binaries..."
ifeq ($(PYFILES), $(BINDIR)/*.py)
@echo "No Python binaries were found in $(BINDIR)!"
else
@echo "Compiling Python binaries..."
@for script in $(PYFILES); do\
echo "$${script}";\
python $${script};\
done
@echo "Done!"
endif
# 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!"
info:
@echo "$(LOGFILES)"