-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
78 lines (63 loc) · 1.39 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
CC ?= clang
DEBUG ?= 0
PROFILE ?= 0
rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
SRCS = $(call rwildcard, bes/, *.cpp *.c)
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
# Release builds /w most aggressive optimization flags
CFLAGS_RELEASE = \
-O3 \
-fomit-frame-pointer \
-fno-stack-protector \
-ffast-math
# Profile builds /w slightly less aggressive optimization and /w debug symbols and
# disables Cef and Leap motion (as they fork the process which gprof cannot deal with)
CFLAGS_PROFILE = \
-D_NDEBUG \
-g3 \
-O2 \
-pg \
-no-pie \
-fno-inline-functions \
-fno-inline-functions-called-once \
-fno-optimize-sibling-calls
# Debug builds enable trap and stack protector /w Leap and Cef enabled
CFLAGS_DEBUG = \
-g3 \
-O0 \
-ftrapv \
-fstack-protector-all \
CFLAGS_COMMON = \
-I. \
-Imodules/foundation/ \
-fPIC \
-fstrict-aliasing \
-Wall \
-Wextra \
-Wundef \
-Wshadow \
-Wpointer-arith \
-Wunreachable-code \
-Wwrite-strings \
-Winit-self \
-MMD
CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_RELEASE)
LIB = bes-pkv.a
ifeq ($(PROFILE),1)
CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_PROFILE)
LIB = bes-pkv.a
endif
ifeq ($(DEBUG), 1)
CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_DEBUG)
LIB = bes-pkv.a
endif
all: $(LIB)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
$(LIB): $(OBJS)
$(AR) -r -o $(LIB) $^
clean:
rm -rf $(OBJS) $(DEPS) $(LIB)
.PHONY: clean
-include $(DEPS)