-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (68 loc) · 1.83 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
89
90
91
92
93
94
95
# Makefile
# $@ -- The file name of the target of the rule.
# $* -- The stem with which an implicit rule matches
# $< -- The name of the first prerequisite.
# $^ -- The names of all the prerequisites
# $(VARS:%.cpp=%.o) -- pattern replace
#CC:=g++
CC:=clang++
#CC:=emcc
# output files
OUTS:=client/main server/test client/test ext/test front/main
# targets
debug: client/main server/test client/test ext/test front/main
release: client/main server/test client/test ext/test front/main
# em opts
EMOPTS:=
EMOPTS+=-s WASM=1
EMOPTS+=-s USE_SDL=2
EMOPTS+=-s DISABLE_EXCEPTION_CATCHING=0
#EMOPTS+=-s SAFE_HEAP=1
EMOPTS+=-s ASSERTIONS=1
#EMOPTS+=-s DEMANGLE_SUPPORT=1
#EMOPTS+=-s EXCEPTION_DEBUG=1
# compiler options
CCOPTS:=
CCOPTS+=-std=c++14
#CCOPTS+=-stdlib=libc++
CCOPTS+=-I./src -I./src/server
CCOPTS+=-Wsign-compare -Wreturn-type -Wparentheses -Wpedantic -Wconversion-null
#CCOPTS+=-fmax-errors=8
#-Wno-vla-extension
CCOPTS+=-ferror-limit=16
# linker options
LLOPTS:=
# emcc
ifeq (${CC}, emcc)
CCOPTS+=${EMOPTS}
LLOPTS+=${EMOPTS}
OUT_EXT:=.html
#LLOPTS+=--preload-file res
else
LLOPTS+=-L./lib
LLOPTS+=-lSDL2
LLOPTS+=-lGL -lGLEW
LLOPTS+=-lpthread
OUT_EXT:=
endif
debug: CCOPTS+=-O0 -g
debug: LLOPTS+=-O0 -g
release: CCOPTS+=-O3
release: LLOPTS+=-O3
# assert dirs
$(shell mkdir -p obj)
$(shell find src/ -type d | cut -c 5- | xargs -I{} mkdir -p obj/{})
$(shell mkdir -p bin)
$(shell find src/ -type d | cut -c 5- | xargs -I{} mkdir -p bin/{})
# list of compiled source obj/fname.cpp.obj
OBJS:=$(shell find src -name '*.cpp')
OBJS:=$(OBJS:src/%.cpp=obj/%.cpp.obj)
-include $(OBJS:%.obj=%.d)
# compiler
${OBJS}: obj/%.obj: src/%
${CC} -c -MMD -MP -o $@ $< ${CCOPTS}
# linker
${OUTS}: $(OBJS)
${CC} -o bin/$@${OUT_EXT} obj/[email protected] $(filter-out $(OUTS:%=obj/%.cpp.obj),$(OBJS)) ${LLOPTS}
clean:
rm -rf obj/* bin/*