-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
74 lines (55 loc) · 1.74 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
# Makefile for the lambda calculator.
# This is just a plug in of my most generaic Makefile.
# Call without target to make the executable
# with clean to remove intermediate files.
# with deepclean to remove all generated files.
# with test to run the program with gdb as a test wrapper.
### Variables & Setup
# The name of the executable.
EXE=lambda
# The base name of every code file used to create the binary.
FILENAMES=main tokenizer parse-node symbol rule-item cfgrammer action-table \
slr1-atg sr-op element cfg-parser token
# Leave empty to compile for release, otherwise system compiles for debugging.
USE_DEBUG=
# C++ Compiler
CXX=g++
# Flags for compilation
CXXFLAGS=-Wall --std=c++11
# Additional libraries for the linking step.
CXXLIBS=-lsfml-graphics -lsfml-window -lsfml-system
# Additional flags for debug builds.
DEBUG=-ggdb -DDEBUG=true
TMPDIR=.obj
CODEDIR=code
CPPFILES=${FILENAMES:%=${CODEDIR}/%.cpp}
OBJFILES=${FILENAMES:%=${TMPDIR}/%.o}
DEPFILES=${OBJFILES:%.o=%.d}
CXXFLAGS+=${if ${USE_DEBUG},${DEBUG},}
.PHONY : all clean deepclean test
### Recipes and Rules
all : ${EXE}
# Rule for the binary
${EXE} : ${OBJFILES}
${CXX} ${CXXFLAGS} ${CXXLIBS} $^ -o $@
# Rule for object files
${OBJFILES} : ${TMPDIR}/%.o : ${CODEDIR}/%.cpp | ${TMPDIR}
${CXX} ${CXXFLAGS} -MMD -c $< -o $@
# Rule for the temperary directory
${TMPDIR} :
mkdir ${TMPDIR}
# Phony rule for cleaning intermediate files
clean :
-rm ${OBJFILES}
-rm ${DEPFILES}
-rmdir ${TMPDIR}
# Phony rule for cleaning generated files
deepclean : clean
-rm ${EXE}
# Phony rule for running the test wrapper
test : ${EXE}
# gdb ./${EXE}
valgrind ./${EXE}
# Better way to select the test wrapper, opition, setting, two rules?
### Include Depends Files
-include ${DEPFILES}