-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
88 lines (65 loc) · 1.63 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
# Default-Config
# Libraries
LIBS = -lm -lSDL2
# Compiler
CC = gcc
# Flags for compilations
# c ... compilation without linking
CFLAGS = -std=c11 -pedantic -Wall \
-D_DEFAULT_SOURCE -D_BSD_SOURCE \
-D_SVID_SOURCE -D_POSIX_C_SOURCE=200809L \
-DNDEBUG -D_GNU_SOURCE -c
# Flags for linking
LFLAGS = $(LIBS)
# Flags for debug compilation
# UNDEBUG ... undefines NDEBUG (enables asserts)
# g ... keep debug symbols
DCFLAGS = -UNDEBUG -g
DLFLAGS = -g
# Flags for production compilation
# O ... sets optimization-level
PC_FLAGS = -O2
BUILD_PATH = build/
SRC_PATH = src/
# Name of the executable
TARGET = main
DOXY_PATH = docs/
# Name of the doxy configuration
DOXY_CONF = .doxy.dox
# Format flag for indent
FORMAT = -linux
HEADERS = $(wildcard $(SRC_PATH)*.h)
SOURCES = $(wildcard $(SRC_PATH)*.c)
OBJECTS = $(patsubst $(SRC_PATH)%.c, $(BUILD_PATH)%.o, $(SOURCES))
$(BUILD_PATH)%.o: $(SRC_PATH)%.c $(HEADERS)
$(CC) $(CFLAGS) $< -o $@
all: --all-pre $(OBJECTS)
echo "Linking..."
$(CC) $(LFLAGS) $(OBJECTS) $(LIBS) -o $(BUILD_PATH)$(TARGET)
echo "Done."
--all-pre:
mkdir -p $(BUILD_PATH)
prod: --prod-pre all
--prod-pre:
echo "Adding production flags..."
$(eval CFLAGS += $(PC_FLAGS))
debug: --debug-pre all
--debug-pre:
echo "Adding debug flags..."
$(eval CFLAGS += $(DCFLAGS))
$(eval LFLAGS += $(DLFLAGS))
doxy: clean
echo "Generating documentation..."
doxygen $(DOXY_CONF) $(DOXY_PATH)
echo "Done."
.SILENT:
clean:
echo "Cleaning..."
-rm -rf $(BUILD_PATH)
-rm -rf $(DOXY_PATH)
echo "Done."
# miscellaneous
format:
echo "Formatting header- and source-files..."
indent $(FORMAT) $(HEADERS) $(SOURCES)
echo "Done."