2020-12-06 04:25:23 +00:00
|
|
|
GIT_VERSION!=git describe --tags
|
|
|
|
|
2020-08-28 18:02:03 +00:00
|
|
|
CC=clang
|
2020-08-20 17:03:15 +00:00
|
|
|
CXX=clang++
|
|
|
|
# -w suppresses all warnings (the part that's commented out helps me find memory leaks, it ruins performance though!)
|
2020-09-24 01:12:24 +00:00
|
|
|
# If compiling with ASAN, invoke like this: $ LSAN_OPTIONS=suppressions=suppr.txt bin/fusion
|
2021-12-15 05:02:23 +00:00
|
|
|
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
|
2020-08-20 17:03:15 +00:00
|
|
|
# specifies the name of our exectuable
|
|
|
|
SERVER=bin/fusion
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2020-08-21 17:38:45 +00:00
|
|
|
# assign protocol version
|
|
|
|
# this can be overriden by ex. make PROTOCOL_VERSION=728
|
|
|
|
PROTOCOL_VERSION?=104
|
|
|
|
|
2020-08-20 17:03:15 +00:00
|
|
|
# Windows-specific
|
2020-08-28 18:02:03 +00:00
|
|
|
WIN_CC=x86_64-w64-mingw32-gcc
|
2020-08-20 17:03:15 +00:00
|
|
|
WIN_CXX=x86_64-w64-mingw32-g++
|
2021-12-15 05:02:23 +00:00
|
|
|
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
|
2020-08-20 17:03:15 +00:00
|
|
|
WIN_SERVER=bin/winfusion.exe
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2021-03-16 01:06:54 +00:00
|
|
|
# C code; currently exclusively from vendored libraries
|
2020-08-28 20:44:29 +00:00
|
|
|
CSRC=\
|
2021-03-12 17:50:21 +00:00
|
|
|
vendor/bcrypt/bcrypt.c\
|
|
|
|
vendor/bcrypt/crypt_blowfish.c\
|
|
|
|
vendor/bcrypt/crypt_gensalt.c\
|
|
|
|
vendor/bcrypt/wrapper.c\
|
2020-08-28 18:02:03 +00:00
|
|
|
|
2021-03-16 01:06:54 +00:00
|
|
|
CHDR=\
|
|
|
|
vendor/bcrypt/bcrypt.h\
|
|
|
|
vendor/bcrypt/crypt_blowfish.h\
|
|
|
|
vendor/bcrypt/crypt_gensalt.h\
|
|
|
|
vendor/bcrypt/ow-crypt.h\
|
|
|
|
vendor/bcrypt/winbcrypt.h\
|
|
|
|
|
2020-08-28 20:44:29 +00:00
|
|
|
CXXSRC=\
|
2021-03-17 19:07:40 +00:00
|
|
|
src/core/CNProtocol.cpp\
|
|
|
|
src/core/CNShared.cpp\
|
|
|
|
src/core/Packets.cpp\
|
|
|
|
src/servers/CNLoginServer.cpp\
|
|
|
|
src/servers/CNShardServer.cpp\
|
|
|
|
src/servers/Monitor.cpp\
|
2021-03-16 01:06:54 +00:00
|
|
|
src/db/init.cpp\
|
|
|
|
src/db/login.cpp\
|
|
|
|
src/db/shard.cpp\
|
|
|
|
src/db/player.cpp\
|
|
|
|
src/db/email.cpp\
|
2021-11-04 02:12:11 +00:00
|
|
|
src/sandbox/seccomp.cpp\
|
2021-12-15 04:05:16 +00:00
|
|
|
src/sandbox/openbsd.cpp\
|
2022-07-17 06:33:57 +00:00
|
|
|
src/Buffs.cpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Chat.cpp\
|
2021-03-12 19:07:26 +00:00
|
|
|
src/CustomCommands.cpp\
|
2021-03-21 01:42:45 +00:00
|
|
|
src/Entities.cpp\
|
2021-03-16 01:06:54 +00:00
|
|
|
src/Email.cpp\
|
2021-03-17 21:28:24 +00:00
|
|
|
src/Eggs.cpp\
|
2020-08-20 17:03:15 +00:00
|
|
|
src/main.cpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Missions.cpp\
|
2021-03-13 22:55:16 +00:00
|
|
|
src/MobAI.cpp\
|
|
|
|
src/Combat.cpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Nanos.cpp\
|
2021-03-13 20:22:29 +00:00
|
|
|
src/Abilities.cpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Items.cpp\
|
2020-08-20 17:03:15 +00:00
|
|
|
src/NPCManager.cpp\
|
|
|
|
src/PlayerManager.cpp\
|
2021-03-12 22:44:21 +00:00
|
|
|
src/PlayerMovement.cpp\
|
2021-03-12 22:18:00 +00:00
|
|
|
src/BuiltinCommands.cpp\
|
2020-08-20 17:03:15 +00:00
|
|
|
src/settings.cpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Transport.cpp\
|
2020-09-09 17:06:22 +00:00
|
|
|
src/TableData.cpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Chunking.cpp\
|
|
|
|
src/Buddies.cpp\
|
|
|
|
src/Groups.cpp\
|
|
|
|
src/Racing.cpp\
|
2021-04-16 17:28:59 +00:00
|
|
|
src/Vendors.cpp\
|
2021-03-13 02:09:36 +00:00
|
|
|
src/Trading.cpp\
|
2021-03-28 20:57:43 +00:00
|
|
|
src/Rand.cpp\
|
2020-08-20 17:03:15 +00:00
|
|
|
|
|
|
|
# headers (for timestamp purposes)
|
2020-08-28 20:44:29 +00:00
|
|
|
CXXHDR=\
|
2021-03-17 19:07:40 +00:00
|
|
|
src/core/CNProtocol.hpp\
|
|
|
|
src/core/CNShared.hpp\
|
|
|
|
src/core/CNStructs.hpp\
|
2021-03-19 01:32:07 +00:00
|
|
|
src/core/Packets.hpp\
|
2021-03-17 19:07:40 +00:00
|
|
|
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\
|
2021-11-04 02:12:11 +00:00
|
|
|
src/sandbox/Sandbox.hpp\
|
2021-03-12 17:50:21 +00:00
|
|
|
vendor/bcrypt/BCrypt.hpp\
|
|
|
|
vendor/INIReader.hpp\
|
|
|
|
vendor/JSON.hpp\
|
2022-07-17 06:33:57 +00:00
|
|
|
src/Buffs.hpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Chat.hpp\
|
2021-03-12 19:07:26 +00:00
|
|
|
src/CustomCommands.hpp\
|
2021-03-21 01:42:45 +00:00
|
|
|
src/Entities.hpp\
|
2021-03-16 01:06:54 +00:00
|
|
|
src/Email.hpp\
|
2021-03-17 21:28:24 +00:00
|
|
|
src/Eggs.hpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Missions.hpp\
|
2021-03-13 22:55:16 +00:00
|
|
|
src/MobAI.hpp\
|
|
|
|
src/Combat.hpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Nanos.hpp\
|
2021-03-13 20:22:29 +00:00
|
|
|
src/Abilities.hpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Items.hpp\
|
2020-08-20 17:03:15 +00:00
|
|
|
src/NPCManager.hpp\
|
|
|
|
src/Player.hpp\
|
|
|
|
src/PlayerManager.hpp\
|
2021-03-12 22:44:21 +00:00
|
|
|
src/PlayerMovement.hpp\
|
2021-03-12 22:18:00 +00:00
|
|
|
src/BuiltinCommands.hpp\
|
2020-08-20 17:03:15 +00:00
|
|
|
src/settings.hpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Transport.hpp\
|
2020-09-09 17:06:22 +00:00
|
|
|
src/TableData.hpp\
|
2024-10-29 03:49:34 +00:00
|
|
|
src/Bucket.hpp\
|
2021-03-16 22:29:13 +00:00
|
|
|
src/Chunking.hpp\
|
|
|
|
src/Buddies.hpp\
|
|
|
|
src/Groups.hpp\
|
|
|
|
src/Racing.hpp\
|
2021-04-16 17:28:59 +00:00
|
|
|
src/Vendors.hpp\
|
2021-03-13 02:09:36 +00:00
|
|
|
src/Trading.hpp\
|
2021-03-28 20:57:43 +00:00
|
|
|
src/Rand.hpp\
|
2020-08-20 17:03:15 +00:00
|
|
|
|
2020-08-28 20:44:29 +00:00
|
|
|
COBJ=$(CSRC:.c=.o)
|
|
|
|
CXXOBJ=$(CXXSRC:.cpp=.o)
|
2020-08-28 18:02:03 +00:00
|
|
|
|
2020-08-28 20:44:29 +00:00
|
|
|
OBJ=$(COBJ) $(CXXOBJ)
|
2020-08-20 17:03:15 +00:00
|
|
|
|
2020-08-31 16:10:01 +00:00
|
|
|
HDR=$(CHDR) $(CXXHDR)
|
|
|
|
|
2020-08-20 17:03:15 +00:00
|
|
|
all: $(SERVER)
|
|
|
|
|
|
|
|
windows: $(SERVER)
|
2024-10-12 13:42:26 +00:00
|
|
|
nosandbox: $(SERVER)
|
2024-10-12 20:04:06 +00:00
|
|
|
nolandlock: $(SERVER)
|
2024-10-12 13:42:26 +00:00
|
|
|
|
2020-08-21 17:38:45 +00:00
|
|
|
# assign Windows-specific values if targeting Windows
|
2020-08-28 18:02:03 +00:00
|
|
|
windows : CC=$(WIN_CC)
|
2020-08-20 17:03:15 +00:00
|
|
|
windows : CXX=$(WIN_CXX)
|
2020-08-28 20:44:29 +00:00
|
|
|
windows : CFLAGS=$(WIN_CFLAGS)
|
2020-08-20 17:03:15 +00:00
|
|
|
windows : CXXFLAGS=$(WIN_CXXFLAGS)
|
|
|
|
windows : LDFLAGS=$(WIN_LDFLAGS)
|
|
|
|
windows : SERVER=$(WIN_SERVER)
|
2020-09-16 18:12:12 +00:00
|
|
|
|
2024-10-12 13:42:26 +00:00
|
|
|
nosandbox : CFLAGS+=-DCONFIG_NOSANDBOX=1
|
2024-10-12 20:04:06 +00:00
|
|
|
nolandlock : CFLAGS+=-DCONFIG_NOLANDLOCK=1
|
2024-10-12 13:42:26 +00:00
|
|
|
|
2021-12-15 05:02:23 +00:00
|
|
|
.SUFFIXES: .o .c .cpp .h .hpp
|
2020-08-28 18:02:03 +00:00
|
|
|
|
2020-08-31 16:10:01 +00:00
|
|
|
.c.o:
|
2020-08-28 20:44:29 +00:00
|
|
|
$(CC) -c $(CFLAGS) -o $@ $<
|
|
|
|
|
2020-08-31 16:10:01 +00:00
|
|
|
.cpp.o:
|
2020-08-20 17:03:15 +00:00
|
|
|
$(CXX) -c $(CXXFLAGS) -o $@ $<
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2020-08-31 16:10:01 +00:00
|
|
|
# header timestamps are a prerequisite for OF object files
|
2021-11-06 05:00:37 +00:00
|
|
|
$(CXXOBJ): $(HDR)
|
2020-08-31 16:10:01 +00:00
|
|
|
|
2020-08-28 20:44:29 +00:00
|
|
|
$(SERVER): $(OBJ) $(CHDR) $(CXXHDR)
|
2020-08-20 17:03:15 +00:00
|
|
|
mkdir -p bin
|
|
|
|
$(CXX) $(OBJ) $(LDFLAGS) -o $(SERVER)
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2020-09-16 18:12:12 +00:00
|
|
|
# compatibility with how cmake injects GIT_VERSION
|
|
|
|
version.h:
|
|
|
|
touch version.h
|
|
|
|
|
|
|
|
src/main.o: version.h
|
|
|
|
|
2024-10-12 20:04:06 +00:00
|
|
|
.PHONY: all windows nosandbox nolandlock clean nuke
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2020-08-30 21:55:17 +00:00
|
|
|
# only gets rid of OpenFusion objects, so we don't need to
|
|
|
|
# recompile the libs every time
|
2020-08-20 17:03:15 +00:00
|
|
|
clean:
|
2021-03-16 01:06:54 +00:00
|
|
|
rm -f src/*.o src/*/*.o $(SERVER) $(WIN_SERVER) version.h
|
2020-08-30 21:55:17 +00:00
|
|
|
|
|
|
|
# gets rid of all compiled objects, including the libraries
|
|
|
|
nuke:
|
2020-09-16 18:12:12 +00:00
|
|
|
rm -f $(OBJ) $(SERVER) $(WIN_SERVER) version.h
|