@@ -11,33 +11,36 @@ SRCS := $(shell find $(SRC_DIRS) -not -name 'main.c' -name '*.c')
11
11
INC_DIRS := $(shell find $(SRC_DIRS ) -type d)
12
12
INC_FLAGS := $(addprefix -I,$(INC_DIRS ) )
13
13
LIBS := -lpthread -lm
14
+
14
15
WARNING_FLAGS := -pedantic -Wall -Wextra -Wno-missing-declarations -Wstrict-prototypes -Wpointer-arith -Wwrite-strings -Wbad-function-cast -Wformat-security -Wno-discarded-qualifiers -Wno-implicit-fallthrough -Wformat-nonliteral -Wmissing-format-attribute -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function -Wno-ignored-qualifiers -Wno-strict-prototypes -Wno-bad-function-cast -Wno-pointer-sign
15
16
HARDENING_FLAGS := -fno-builtin -fvisibility=hidden -fstack-protector -fno-omit-frame-pointer -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-common -ffunction-sections -fdata-sections
16
17
PERFORMANCE_FLAGS := -fPIC -fPIE -ffast-math -fassociative-math -fno-signed-zeros -fno-trapping-math -fno-exceptions
17
18
18
- # Flags
19
- # Debug
20
- # CFLAGS := $(INC_FLAGS) -g3 -O0 -ggdb $(WARNING_FLAGS)
19
+ # Build type (debug or release)
20
+ BUILD_TYPE ?= release
21
21
22
- # Release
23
- CFLAGS := $(INC_FLAGS ) -g0 -O2 $(WARNING_FLAGS ) $(HARDENING_FLAGS ) $(PERFORMANCE_FLAGS )
22
+ ifeq ($(BUILD_TYPE ) ,debug)
23
+ CFLAGS := $(INC_FLAGS ) -g3 -O0 -ggdb $(WARNING_FLAGS )
24
+ else
25
+ CFLAGS := $(INC_FLAGS ) -g0 -O2 $(WARNING_FLAGS ) $(HARDENING_FLAGS ) $(PERFORMANCE_FLAGS )
26
+ endif
24
27
25
28
# Rules
26
29
all : $(DEPLOY_DIR ) /$(TARGET_EXEC )
27
30
28
31
$(DEPLOY_DIR ) /$(TARGET_EXEC ) : $(SRCS ) $(SRC_DIRS ) /main.c | $(DEPLOY_DIR )
29
32
$(CC ) $(SRCS ) $(SRC_DIRS ) /main.c $(CFLAGS ) $(LIBS ) -o $@
30
- $(STRIP ) -R .comment -R * .note * -s -x -X -v $@
33
+ $(STRIP ) --strip-all -v $@
31
34
32
35
$(DEPLOY_DIR ) :
33
36
mkdir -p $(DEPLOY_DIR )
34
37
35
38
clean :
36
- rm -f $(DEPLOY_DIR ) /$(TARGET_EXEC ) $(DEPLOY_DIR ) /stats_* .log $(DEPLOY_DIR ) /stats_* .raw wdt.log
39
+ $( RM ) -f $(DEPLOY_DIR ) /$(TARGET_EXEC ) $(DEPLOY_DIR ) /stats_* .log $(DEPLOY_DIR ) /stats_* .raw wdt.log
37
40
38
41
install : $(DEPLOY_DIR ) /$(TARGET_EXEC )
39
- cp $(DEPLOY_DIR ) /$(TARGET_EXEC ) ~ /
40
- cp run.sh ~ /
41
- chmod +x ~ $(TARGET_EXEC ) run.sh
42
+ $( CP ) $(DEPLOY_DIR ) /$(TARGET_EXEC ) ~ /
43
+ $( CP ) run.sh ~ /
44
+ chmod +x ~ / $(TARGET_EXEC ) ~ / run.sh
42
45
43
46
.PHONY : all clean install
0 commit comments