-
Notifications
You must be signed in to change notification settings - Fork 64
/
Makefile
181 lines (157 loc) · 4.27 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
GIT_VERSION!=git describe --tags
CC=clang
CXX=clang++
# -w suppresses all warnings (the part that's commented out helps me find memory leaks, it ruins performance though!)
# If compiling with ASAN, invoke like this: $ LSAN_OPTIONS=suppressions=suppr.txt bin/fusion
CFLAGS=-Wall -Wno-unknown-pragmas -O2 -fPIE -D_FORTIFY_SOURCE=1 -fstack-protector #-g3 -fsanitize=address
CXXFLAGS=$(CFLAGS) -std=c++17 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(GIT_VERSION)\" -I./src -I./vendor
LDFLAGS=-lpthread -lsqlite3 -pie -Wl,-z,relro -Wl,-z,now #-g3 -fsanitize=address
# specifies the name of our exectuable
SERVER=bin/fusion
# assign protocol version
# this can be overriden by ex. make PROTOCOL_VERSION=728
PROTOCOL_VERSION?=104
# Windows-specific
WIN_CC=x86_64-w64-mingw32-gcc
WIN_CXX=x86_64-w64-mingw32-g++
WIN_CFLAGS=-O2 -D_WIN32_WINNT=0x0601 -Wall -Wno-unknown-pragmas
WIN_CXXFLAGS=$(WIN_CFLAGS) -std=c++17 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(GIT_VERSION)\" -I./src -I./vendor
WIN_LDFLAGS=-static -lws2_32 -lwsock32 -lsqlite3
WIN_SERVER=bin/winfusion.exe
# C code; currently exclusively from vendored libraries
CSRC=\
vendor/bcrypt/bcrypt.c\
vendor/bcrypt/crypt_blowfish.c\
vendor/bcrypt/crypt_gensalt.c\
vendor/bcrypt/wrapper.c\
CHDR=\
vendor/bcrypt/bcrypt.h\
vendor/bcrypt/crypt_blowfish.h\
vendor/bcrypt/crypt_gensalt.h\
vendor/bcrypt/ow-crypt.h\
vendor/bcrypt/winbcrypt.h\
CXXSRC=\
src/core/CNProtocol.cpp\
src/core/CNShared.cpp\
src/core/Packets.cpp\
src/servers/CNLoginServer.cpp\
src/servers/CNShardServer.cpp\
src/servers/Monitor.cpp\
src/db/init.cpp\
src/db/login.cpp\
src/db/shard.cpp\
src/db/player.cpp\
src/db/email.cpp\
src/sandbox/seccomp.cpp\
src/sandbox/openbsd.cpp\
src/Buffs.cpp\
src/Chat.cpp\
src/CustomCommands.cpp\
src/Entities.cpp\
src/Email.cpp\
src/Eggs.cpp\
src/main.cpp\
src/Missions.cpp\
src/MobAI.cpp\
src/Combat.cpp\
src/Nanos.cpp\
src/Abilities.cpp\
src/Items.cpp\
src/NPCManager.cpp\
src/PlayerManager.cpp\
src/PlayerMovement.cpp\
src/BuiltinCommands.cpp\
src/settings.cpp\
src/Transport.cpp\
src/TableData.cpp\
src/Chunking.cpp\
src/Buddies.cpp\
src/Groups.cpp\
src/Racing.cpp\
src/Vendors.cpp\
src/Trading.cpp\
src/Rand.cpp\
# headers (for timestamp purposes)
CXXHDR=\
src/core/CNProtocol.hpp\
src/core/CNShared.hpp\
src/core/CNStructs.hpp\
src/core/Packets.hpp\
src/core/Defines.hpp\
src/core/Core.hpp\
src/servers/CNLoginServer.hpp\
src/servers/CNShardServer.hpp\
src/servers/Monitor.hpp\
src/db/Database.hpp\
src/db/internal.hpp\
src/sandbox/Sandbox.hpp\
vendor/bcrypt/BCrypt.hpp\
vendor/INIReader.hpp\
vendor/JSON.hpp\
src/Buffs.hpp\
src/Chat.hpp\
src/CustomCommands.hpp\
src/Entities.hpp\
src/Email.hpp\
src/Eggs.hpp\
src/Missions.hpp\
src/MobAI.hpp\
src/Combat.hpp\
src/Nanos.hpp\
src/Abilities.hpp\
src/Items.hpp\
src/NPCManager.hpp\
src/Player.hpp\
src/PlayerManager.hpp\
src/PlayerMovement.hpp\
src/BuiltinCommands.hpp\
src/settings.hpp\
src/Transport.hpp\
src/TableData.hpp\
src/Bucket.hpp\
src/Chunking.hpp\
src/Buddies.hpp\
src/Groups.hpp\
src/Racing.hpp\
src/Vendors.hpp\
src/Trading.hpp\
src/Rand.hpp\
COBJ=$(CSRC:.c=.o)
CXXOBJ=$(CXXSRC:.cpp=.o)
OBJ=$(COBJ) $(CXXOBJ)
HDR=$(CHDR) $(CXXHDR)
all: $(SERVER)
windows: $(SERVER)
nosandbox: $(SERVER)
nolandlock: $(SERVER)
# assign Windows-specific values if targeting Windows
windows : CC=$(WIN_CC)
windows : CXX=$(WIN_CXX)
windows : CFLAGS=$(WIN_CFLAGS)
windows : CXXFLAGS=$(WIN_CXXFLAGS)
windows : LDFLAGS=$(WIN_LDFLAGS)
windows : SERVER=$(WIN_SERVER)
nosandbox : CFLAGS+=-DCONFIG_NOSANDBOX=1
nolandlock : CFLAGS+=-DCONFIG_NOLANDLOCK=1
.SUFFIXES: .o .c .cpp .h .hpp
.c.o:
$(CC) -c $(CFLAGS) -o $@ $<
.cpp.o:
$(CXX) -c $(CXXFLAGS) -o $@ $<
# header timestamps are a prerequisite for OF object files
$(CXXOBJ): $(HDR)
$(SERVER): $(OBJ) $(CHDR) $(CXXHDR)
mkdir -p bin
$(CXX) $(OBJ) $(LDFLAGS) -o $(SERVER)
# compatibility with how cmake injects GIT_VERSION
version.h:
touch version.h
src/main.o: version.h
.PHONY: all windows nosandbox nolandlock clean nuke
# only gets rid of OpenFusion objects, so we don't need to
# recompile the libs every time
clean:
rm -f src/*.o src/*/*.o $(SERVER) $(WIN_SERVER) version.h
# gets rid of all compiled objects, including the libraries
nuke:
rm -f $(OBJ) $(SERVER) $(WIN_SERVER) version.h