-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (50 loc) · 1.68 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
COMPILER = gcc
LINKER = gcc
NASM_COMPILER = nasm
BIN_FILE = teavpn
LIBS = -lpthread
SOURCE_DIR = src/
ROOT_DEPDIR = .deps
STD_FLAG =
CONSTANTS =
INCLUDE = -Iinclude/
ifeq (${RELEASE_MODE},1)
LINKER_FLAGS = ${STD_FLAG} ${INCLUDE} -Wall -fno-stack-protector -Ofast ${CONSTANTS} -o
COMPILER_FLAGS = ${STD_FLAG} ${INCLUDE} -Wall -fno-stack-protector -Ofast ${CONSTANTS} -c -o
NASM_COMPILE_FLAG = -f elf64 -O3 -o
else
LINKER_FLAGS = ${STD_FLAG} ${INCLUDE} -Wall -fstack-protector-strong -ggdb3 -O0 -DTEAVPN_DEBUG ${CONSTANTS} -o
COMPILER_FLAGS = ${STD_FLAG} ${INCLUDE} -Wall -fstack-protector-strong -ggdb3 -O0 -DTEAVPN_DEBUG ${CONSTANTS} -c -o
NASM_COMPILE_FLAG = -f elf64 -O0 -o
endif
SOURCES = $(shell find ${SOURCE_DIR} -name '*.c')
SOURCES += $(shell find ${SOURCE_DIR} -name '*.cpp')
SOURCES += $(shell find ${SOURCE_DIR} -name '*.S')
NASM_SOURCES = $(shell find ${SOURCE_DIR} -name '*.asm')
NASM_OBJECTS = $(NASM_SOURCES:%=%.o)
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=%}
${NASM_OBJECTS}:
${NASM_COMPILER} ${NASM_COMPILE_FLAG} $@ ${@:%.o=%}
${BIN_FILE}: ${OBJECTS} ${NASM_OBJECTS}
${LINKER} ${LINKER_FLAGS} ${BIN_FILE} ${OBJECTS} ${NASM_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}