2026-07-13 06:30:42 -03:00
|
|
|
# GLOBAL SETTINGS
|
|
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
MAKEFLAGS := -j$(shell nproc)
|
|
|
|
|
TARGET := spheresvr
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2026-07-13 06:30:42 -03:00
|
|
|
CXX := g++ -std=c++20
|
2026-07-02 04:42:03 -03:00
|
|
|
CC := gcc
|
|
|
|
|
|
2026-07-13 06:30:42 -03:00
|
|
|
|
|
|
|
|
# CODE GENERATION FLAGS
|
|
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
OVERALL_FLAGS := -pipe
|
2026-07-13 06:30:42 -03:00
|
|
|
OPTIMIZATION_FLAGS := -O2 -flto=auto -fno-omit-frame-pointer -fno-strict-aliasing
|
2026-07-02 04:42:03 -03:00
|
|
|
DEBUG_FLAGS :=
|
|
|
|
|
CODE_GEN_FLAGS := -fexceptions -fnon-call-exceptions
|
|
|
|
|
ARCH_FLAGS := -m64 -Dx64
|
|
|
|
|
|
2020-01-13 11:37:56 -03:00
|
|
|
ifdef DEBUG
|
2026-07-13 06:30:42 -03:00
|
|
|
CPPFLAGS := -D_DEBUG
|
2026-07-02 04:42:03 -03:00
|
|
|
DEBUG_FLAGS += -ggdb3
|
2026-07-13 06:30:42 -03:00
|
|
|
else
|
|
|
|
|
CPPFLAGS := -D_THREAD_TRACK_CALLSTACK
|
2016-08-01 08:01:08 -04:00
|
|
|
endif
|
2026-07-13 06:30:42 -03:00
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
ifdef NIGHTLY
|
|
|
|
|
CPPFLAGS += -D_NIGHTLYBUILD
|
2019-02-13 19:40:09 -02:00
|
|
|
endif
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2019-02-13 19:40:09 -02:00
|
|
|
|
2026-07-13 06:30:42 -03:00
|
|
|
# C/C++ FLAGS
|
|
|
|
|
|
|
|
|
|
WARN_CXXFLAGS := -Wall -Wno-register
|
2026-07-02 04:42:03 -03:00
|
|
|
CXXFLAGS := $(OVERALL_FLAGS) $(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) $(CODE_GEN_FLAGS) $(ARCH_FLAGS) $(CPPFLAGS) $(WARN_CXXFLAGS)
|
2026-07-13 06:30:42 -03:00
|
|
|
|
|
|
|
|
WARN_CFLAGS := -Wall -Wno-implicit-function-declaration -Wno-misleading-indentation -Wno-unused-result
|
2026-07-02 04:42:03 -03:00
|
|
|
CFLAGS := $(OVERALL_FLAGS) $(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) $(CODE_GEN_FLAGS) $(ARCH_FLAGS) $(CPPFLAGS) $(WARN_CFLAGS)
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2026-07-13 06:30:42 -03:00
|
|
|
|
|
|
|
|
# LINKER FLAGS
|
|
|
|
|
|
|
|
|
|
WARN_LDFLAGS := -Wno-aggressive-loop-optimizations -Wno-lto-type-mismatch -Wno-return-local-addr
|
|
|
|
|
LDFLAGS := -L/usr/lib/mysql -pthread $(OPTIMIZATION_FLAGS) $(CODE_GEN_FLAGS) $(ARCH_FLAGS) $(WARN_LDFLAGS)
|
|
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
ifndef DEBUG
|
|
|
|
|
LDFLAGS += -s
|
|
|
|
|
endif
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2026-07-13 06:30:42 -03:00
|
|
|
LDLIBS := -lmysqlclient -lpthread -ldl
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# SOURCE FILES
|
|
|
|
|
|
|
|
|
|
SRC := ./src/common/CArray.cpp \
|
|
|
|
|
./src/common/CAssoc.cpp \
|
|
|
|
|
./src/common/CCacheableScriptFile.cpp \
|
|
|
|
|
./src/common/CCSVFile.cpp \
|
|
|
|
|
./src/common/CDataBase.cpp \
|
|
|
|
|
./src/common/CEncrypt.cpp \
|
|
|
|
|
./src/common/CException.cpp \
|
|
|
|
|
./src/common/CExpression.cpp \
|
|
|
|
|
./src/common/CFile.cpp \
|
|
|
|
|
./src/common/CFileList.cpp \
|
|
|
|
|
./src/common/CGrayData.cpp \
|
|
|
|
|
./src/common/CGrayInst.cpp \
|
|
|
|
|
./src/common/CGrayMap.cpp \
|
|
|
|
|
./src/common/CListDefMap.cpp \
|
|
|
|
|
./src/common/CMD5.cpp \
|
|
|
|
|
./src/common/CQueue.cpp \
|
|
|
|
|
./src/common/CRect.cpp \
|
|
|
|
|
./src/common/CRegion.cpp \
|
|
|
|
|
./src/common/CResourceBase.cpp \
|
|
|
|
|
./src/common/CScript.cpp \
|
|
|
|
|
./src/common/CScriptObj.cpp \
|
|
|
|
|
./src/common/CSectorTemplate.cpp \
|
|
|
|
|
./src/common/CSocket.cpp \
|
|
|
|
|
./src/common/CString.cpp \
|
|
|
|
|
./src/common/CTime.cpp \
|
|
|
|
|
./src/common/CVarDefMap.cpp \
|
|
|
|
|
./src/common/CVarFloat.cpp \
|
|
|
|
|
./src/common/graycom.cpp \
|
|
|
|
|
./src/common/libev/wrapper_ev.c \
|
|
|
|
|
./src/common/sqlite/SQLite.cpp \
|
|
|
|
|
./src/common/sqlite/sqlite3.c \
|
|
|
|
|
./src/common/twofish/twofish2.cpp \
|
|
|
|
|
./src/common/zlib/adler32.c \
|
|
|
|
|
./src/common/zlib/compress.c \
|
|
|
|
|
./src/common/zlib/crc32.c \
|
|
|
|
|
./src/common/zlib/deflate.c \
|
|
|
|
|
./src/common/zlib/gzclose.c \
|
|
|
|
|
./src/common/zlib/gzlib.c \
|
|
|
|
|
./src/common/zlib/gzread.c \
|
|
|
|
|
./src/common/zlib/gzwrite.c \
|
|
|
|
|
./src/common/zlib/infback.c \
|
|
|
|
|
./src/common/zlib/inffast.c \
|
|
|
|
|
./src/common/zlib/inflate.c \
|
|
|
|
|
./src/common/zlib/inftrees.c \
|
|
|
|
|
./src/common/zlib/trees.c \
|
|
|
|
|
./src/common/zlib/uncompr.c \
|
|
|
|
|
./src/common/zlib/zutil.c \
|
|
|
|
|
./src/graysvr/CAccount.cpp \
|
2019-02-13 19:40:09 -02:00
|
|
|
./src/graysvr/CBase.cpp \
|
|
|
|
|
./src/graysvr/CChar.cpp \
|
|
|
|
|
./src/graysvr/CCharAct.cpp \
|
|
|
|
|
./src/graysvr/CCharBase.cpp \
|
|
|
|
|
./src/graysvr/CCharFight.cpp \
|
|
|
|
|
./src/graysvr/CCharNPC.cpp \
|
|
|
|
|
./src/graysvr/CCharNPCAct.cpp \
|
|
|
|
|
./src/graysvr/CCharNPCPet.cpp \
|
|
|
|
|
./src/graysvr/CCharNPCStatus.cpp \
|
|
|
|
|
./src/graysvr/CCharSkill.cpp \
|
|
|
|
|
./src/graysvr/CCharSpell.cpp \
|
|
|
|
|
./src/graysvr/CCharStatus.cpp \
|
|
|
|
|
./src/graysvr/CCharUse.cpp \
|
|
|
|
|
./src/graysvr/CChat.cpp \
|
|
|
|
|
./src/graysvr/CClient.cpp \
|
|
|
|
|
./src/graysvr/CClientDialog.cpp \
|
|
|
|
|
./src/graysvr/CClientEvent.cpp \
|
|
|
|
|
./src/graysvr/CClientLog.cpp \
|
|
|
|
|
./src/graysvr/CClientMsg.cpp \
|
|
|
|
|
./src/graysvr/CClientTarg.cpp \
|
|
|
|
|
./src/graysvr/CClientUse.cpp \
|
|
|
|
|
./src/graysvr/CContain.cpp \
|
|
|
|
|
./src/graysvr/CGMPage.cpp \
|
|
|
|
|
./src/graysvr/CItem.cpp \
|
|
|
|
|
./src/graysvr/CItemBase.cpp \
|
|
|
|
|
./src/graysvr/CItemMulti.cpp \
|
|
|
|
|
./src/graysvr/CItemMultiCustom.cpp \
|
|
|
|
|
./src/graysvr/CItemShip.cpp \
|
|
|
|
|
./src/graysvr/CItemSpawn.cpp \
|
|
|
|
|
./src/graysvr/CItemStone.cpp \
|
|
|
|
|
./src/graysvr/CItemVend.cpp \
|
|
|
|
|
./src/graysvr/CLog.cpp \
|
|
|
|
|
./src/graysvr/CObjBase.cpp \
|
|
|
|
|
./src/graysvr/CParty.cpp \
|
|
|
|
|
./src/graysvr/CPathFinder.cpp \
|
|
|
|
|
./src/graysvr/CPingServer.cpp \
|
|
|
|
|
./src/graysvr/CResource.cpp \
|
|
|
|
|
./src/graysvr/CResourceCalc.cpp \
|
|
|
|
|
./src/graysvr/CResourceDef.cpp \
|
|
|
|
|
./src/graysvr/CSector.cpp \
|
|
|
|
|
./src/graysvr/CServer.cpp \
|
|
|
|
|
./src/graysvr/CServRef.cpp \
|
|
|
|
|
./src/graysvr/CUnixTerminal.cpp \
|
|
|
|
|
./src/graysvr/CWebPage.cpp \
|
|
|
|
|
./src/graysvr/CWorld.cpp \
|
|
|
|
|
./src/graysvr/CWorldImport.cpp \
|
|
|
|
|
./src/graysvr/CWorldMap.cpp \
|
|
|
|
|
./src/graysvr/graysvr.cpp \
|
|
|
|
|
./src/network/network.cpp \
|
|
|
|
|
./src/network/packet.cpp \
|
2026-07-13 06:30:42 -03:00
|
|
|
./src/network/receive.cpp \
|
2019-02-13 19:40:09 -02:00
|
|
|
./src/network/send.cpp \
|
2026-07-13 06:30:42 -03:00
|
|
|
./src/sphere/asyncdb.cpp \
|
|
|
|
|
./src/sphere/linuxev.cpp \
|
|
|
|
|
./src/sphere/mutex.cpp \
|
|
|
|
|
./src/sphere/ProfileData.cpp \
|
|
|
|
|
./src/sphere/strings.cpp \
|
|
|
|
|
./src/sphere/threads.cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# OBJECT FILES
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
OBJS := $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRC))) \
|
|
|
|
|
$(patsubst %.c,%.o,$(filter %.c,$(SRC)))
|
|
|
|
|
|
2011-01-25 22:54:46 +00:00
|
|
|
|
2026-07-13 06:30:42 -03:00
|
|
|
# BUILD RULES
|
|
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
.PHONY: all clean flags version
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
all: $(TARGET)
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2018-03-15 17:53:19 -03:00
|
|
|
clean:
|
2026-07-02 04:42:03 -03:00
|
|
|
@rm -f $(TARGET)
|
|
|
|
|
@find . -name "*.o" -type f -delete
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2018-03-01 18:44:28 -03:00
|
|
|
flags:
|
2026-07-13 06:30:42 -03:00
|
|
|
@echo 'C++ compiler: $(CXX)'
|
|
|
|
|
@echo 'C++ flags: $(CXXFLAGS)'
|
|
|
|
|
@echo ''
|
|
|
|
|
@echo 'C compiler: $(CC)'
|
|
|
|
|
@echo 'C flags: $(CFLAGS)'
|
|
|
|
|
@echo ''
|
|
|
|
|
@echo 'Linker flags: $(LDFLAGS)'
|
|
|
|
|
@echo 'Linker libs: $(LDLIBS)'
|
|
|
|
|
@echo ''
|
2026-07-02 04:42:03 -03:00
|
|
|
|
|
|
|
|
version: flags
|
|
|
|
|
@VERSIONING_FILE="./src/common/version.h"; \
|
|
|
|
|
echo "// This file is auto-generated by compiler pre-build event. Do not edit." > "$${VERSIONING_FILE}"; \
|
|
|
|
|
if [ "$$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then \
|
2026-07-13 06:30:42 -03:00
|
|
|
GIT_COMMIT_COUNT=$$(( $$(git rev-list --count HEAD) - 2406 )); \
|
2026-07-02 04:42:03 -03:00
|
|
|
GIT_COMMIT_HASH=$$(git rev-parse --short HEAD); \
|
|
|
|
|
echo "#define GIT_COMMIT_COUNT $${GIT_COMMIT_COUNT}" >> "$${VERSIONING_FILE}"; \
|
|
|
|
|
echo "#define GIT_COMMIT_HASH \"$${GIT_COMMIT_HASH}\"" >> "$${VERSIONING_FILE}"; \
|
|
|
|
|
echo "Current build number: $${GIT_COMMIT_COUNT} (Git hash: $${GIT_COMMIT_HASH})"; \
|
|
|
|
|
else \
|
|
|
|
|
echo "// Versioning disabled (not a git repository)" >> "$${VERSIONING_FILE}"; \
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
$(OBJS): version
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
$(TARGET): $(OBJS)
|
2026-07-13 06:30:42 -03:00
|
|
|
@$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
|
|
|
|
|
@echo ' $(lastword $(MAKEFILE_LIST)) -> $(shell readlink -f $@)'
|
2016-08-01 08:01:08 -04:00
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
%.o: %.cpp
|
|
|
|
|
@echo ' $(notdir $<)'
|
|
|
|
|
@$(CXX) -c $(CXXFLAGS) $< -o $@
|
2009-05-04 19:08:51 +00:00
|
|
|
|
2026-07-02 04:42:03 -03:00
|
|
|
%.o: %.c
|
|
|
|
|
@echo ' $(notdir $<)'
|
|
|
|
|
@$(CC) -c $(CFLAGS) $< -o $@
|