-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (42 loc) · 1.42 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
COMPILER = gcc
LINKER = gcc
BIN_FILE = teaserver
LIBS = -lpthread -lpcre -lcurl
SOURCE_DIR = src/
ROOT_DEPDIR = .deps
STD_FLAG =
CONSTANTS = -DTEA_SERVER_DEBUG -DINI_MAX_LINE=2048 -DINI_ALLOW_INLINE_COMMENTS=1
INCLUDE_DIR = -Iinclude/
ifeq (${RELEASE_MODE},1)
LINKER_FLAGS = ${STD_FLAG} -Wall -fno-stack-protector ${INCLUDE_DIR} -s -Ofast ${CONSTANTS} -o
COMPILER_FLAGS = ${STD_FLAG} -Wall -fno-stack-protector ${INCLUDE_DIR} -s -Ofast ${CONSTANTS} -c -o
else
LINKER_FLAGS = ${STD_FLAG} -Wall -fstack-protector-strong ${INCLUDE_DIR} -ggdb3 -O0 ${CONSTANTS} -o
COMPILER_FLAGS = ${STD_FLAG} -Wall -fstack-protector-strong ${INCLUDE_DIR} -ggdb3 -O0 ${CONSTANTS} -c -o
endif
SOURCES = $(shell find ${SOURCE_DIR} -name '*.c')
SOURCES += $(shell find ${SOURCE_DIR} -name '*.cpp')
OBJECTS = $(SOURCES:%=%.o)
SOURCES_DIR = $(shell find ${SOURCE_DIR} -type d)
DEPDIR = ${SOURCES_DIR:%=${ROOT_DEPDIR}/%}
DEPFLAGS = -MT $@ -MMD -MP -MF ${ROOT_DEPDIR}/$*.d
DEPFILES = ${SOURCES:%=${ROOT_DEPDIR}/%.d}
all: ${BIN_FILE}
${ROOT_DEPDIR}:
mkdir -p $@
${DEPDIR}: | ${ROOT_DEPDIR}
mkdir -p $@
${OBJECTS}: | ${DEPDIR}
${COMPILER} ${DEPFLAGS} ${COMPILER_FLAGS} $@ ${@:%.o=%}
${BIN_FILE}: ${OBJECTS}
${LINKER} ${LINKER_FLAGS} ${BIN_FILE} ${OBJECTS} ${LIBS}
-include ${DEPFILES}
release:
echo ${OBJECTS}
make clean
make RELEASE_MODE=1 ${RELEASE_FLAGS} ${MAKE_ARG}
strip -s ${BIN_FILE}
clean:
rm -rf ${DEPFILES}
rm -rf ${OBJECTS}
rm -rf ${BIN_FILE}