diff --git a/core/CDataPack.cpp b/core/CDataPack.cpp index 99d15694..59352c92 100644 --- a/core/CDataPack.cpp +++ b/core/CDataPack.cpp @@ -29,7 +29,7 @@ * Version: $Id$ */ -#include +#include #include #include "CDataPack.h" diff --git a/core/CellArray.h b/core/CellArray.h index c5ec78b0..5aa4332f 100644 --- a/core/CellArray.h +++ b/core/CellArray.h @@ -29,7 +29,7 @@ * Version: $Id$ */ -#include +#include #include extern HandleType_t htCellArray; diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index 68aeccf8..4b79c29a 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -44,7 +44,7 @@ #ifdef PLATFORM_WINDOWS ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file"); -#elif defined PLATFORM_LINUX +#elif defined PLATFORM_LINUX || defined PLATFORM_APPLE ConVar sm_corecfgfile("sm_corecfgfile", "addons/sourcemod/configs/core.cfg", 0, "SourceMod core configuration file"); #endif @@ -275,7 +275,7 @@ inline bool IsPathSepChar(char c) { #if defined PLATFORM_WINDOWS return (c == '\\' || c == '/'); -#elif defined PLATFORM_LINUX +#elif defined PLATFORM_LINUX || defined PLATFORM_POSIX return (c == '/'); #endif } diff --git a/core/GameConfigs.cpp b/core/GameConfigs.cpp index 788e31a9..726c1744 100644 --- a/core/GameConfigs.cpp +++ b/core/GameConfigs.cpp @@ -73,6 +73,9 @@ char g_GameName[256] = {'$', '\0'}; #elif defined PLATFORM_LINUX #define PLATFORM_NAME "linux" #define PLATFORM_SERVER_BINARY "server_i486.so" +#elif defined PLATFORM_APPLE +#define PLATFORM_NAME "undef" +#define PLATFORM_SERVER_BINARY "undef.dylib" #endif struct TempSigInfo diff --git a/core/LibrarySys.cpp b/core/LibrarySys.cpp index 7d33b918..b7395d7a 100644 --- a/core/LibrarySys.cpp +++ b/core/LibrarySys.cpp @@ -138,7 +138,7 @@ bool CDirectory::IsEntryDirectory() { #if defined PLATFORM_WINDOWS return ((m_fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY); -#elif defined PLATFORM_LINUX +#elif defined PLATFORM_POSIX char temppath[PLATFORM_MAX_PATH]; snprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName()); return g_LibSys.IsPathDirectory(temppath); @@ -160,7 +160,7 @@ const char *CDirectory::GetEntryName() { #if defined PLATFORM_WINDOWS return m_fd.cFileName; -#elif defined PLATFORM_LINUX +#elif defined PLATFORM_POSIX return ep ? ep->d_name : ""; #endif } @@ -174,7 +174,7 @@ bool CDirectory::IsValid() { #if defined PLATFORM_WINDOWS return (m_dir != INVALID_HANDLE_VALUE); -#elif defined PLATFORM_LINUX +#elif defined PLATFORM_POSIX return (m_dir != NULL); #endif } @@ -214,7 +214,7 @@ bool LibrarySystem::IsPathFile(const char *path) } return true; -#elif defined PLATFORM_LINUX +#elif defined PLATFORM_POSIX struct stat s; if (stat(path, &s) != 0) diff --git a/core/Makefile b/core/Makefile index 38ea2128..5d8fc20a 100644 --- a/core/Makefile +++ b/core/Makefile @@ -43,7 +43,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" diff --git a/core/md5.cpp b/core/md5.cpp index a5c899ef..8738c6df 100644 --- a/core/md5.cpp +++ b/core/md5.cpp @@ -201,11 +201,7 @@ char *MD5::hex_digest(){ int i; char *s= new char[33]; - if (!finalized){ -/* cerr << "MD5::hex_digest: Can't get digest if you haven't "<< - "finalized the digest!" < -#include +#include #include "sm_memtable.h" BaseMemTable::BaseMemTable(unsigned int init_size) diff --git a/core/sm_queue.h b/core/sm_queue.h index 4d438ad5..ff46a583 100644 --- a/core/sm_queue.h +++ b/core/sm_queue.h @@ -33,7 +33,7 @@ #define _INCLUDE_SM_QUEUE_H #include -#include +#include #include using namespace SourceHook; diff --git a/core/smn_adt_array.cpp b/core/smn_adt_array.cpp index 08852eb0..a03309bb 100644 --- a/core/smn_adt_array.cpp +++ b/core/smn_adt_array.cpp @@ -29,7 +29,7 @@ * Version: $Id$ */ -#include +#include #include "sm_globals.h" #include "sm_stringutil.h" #include "CellArray.h" diff --git a/core/smn_adt_stack.cpp b/core/smn_adt_stack.cpp index 0bf4cb68..5fd1db79 100644 --- a/core/smn_adt_stack.cpp +++ b/core/smn_adt_stack.cpp @@ -29,7 +29,7 @@ * Version: $Id$ */ -#include +#include #include "sm_globals.h" #include "sm_stringutil.h" #include "CellArray.h" diff --git a/core/smn_adt_trie.cpp b/core/smn_adt_trie.cpp index 19ef31a3..623e2dd6 100644 --- a/core/smn_adt_trie.cpp +++ b/core/smn_adt_trie.cpp @@ -29,7 +29,7 @@ * Version: $Id$ */ -#include +#include #include "sm_globals.h" #include "sm_stringutil.h" #include "HandleSys.h" diff --git a/core/smn_core.cpp b/core/smn_core.cpp index e75ae368..91acfa66 100644 --- a/core/smn_core.cpp +++ b/core/smn_core.cpp @@ -418,6 +418,9 @@ static cell_t GetSysTickCount(IPluginContext *pContext, const cell_t *params) fticks -= r; } return (cell_t)fticks; +#elif defined PLATFORM_APPLE + assert(false); + return 0; #endif } diff --git a/core/smn_string.cpp b/core/smn_string.cpp index 3aa5dc6b..e708280b 100644 --- a/core/smn_string.cpp +++ b/core/smn_string.cpp @@ -40,7 +40,7 @@ inline const char *_strstr(const char *str, const char *substr) { #ifdef PLATFORM_WINDOWS return strstr(str, substr); -#elif defined PLATFORM_LINUX +#elif defined PLATFORM_LINUX || defined PLATFORM_APPLE return (const char *)strstr(str, substr); #endif } diff --git a/extensions/bintools/Makefile b/extensions/bintools/Makefile index bcd84c29..d7f69d0f 100644 --- a/extensions/bintools/Makefile +++ b/extensions/bintools/Makefile @@ -26,7 +26,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -61,7 +61,7 @@ else -I$(SMSDK)/public/jit/x86 -I$(SMSDK)/public/sourcepawn endif -LINK += -static-libgcc +LINK += -m32 -ldl -lm CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -mfpmath=sse \ @@ -84,14 +84,21 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp @@ -112,7 +119,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true @@ -123,3 +130,4 @@ clean: check rm -rf $(BIN_DIR)/*.o rm -rf $(BIN_DIR)/sdk/*.o rm -rf $(BIN_DIR)/$(BINARY) + diff --git a/extensions/bintools/sdk/smsdk_ext.cpp b/extensions/bintools/sdk/smsdk_ext.cpp index db14af69..6404a919 100644 --- a/extensions/bintools/sdk/smsdk_ext.cpp +++ b/extensions/bintools/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -79,6 +79,24 @@ IThreader *threader = NULL; #if defined SMEXT_ENABLE_LIBSYS ILibrarySys *libsys = NULL; #endif +#if defined SMEXT_ENABLE_PLUGINSYS +SourceMod::IPluginManager *plsys; +#endif +#if defined SMEXT_ENABLE_MENUS +IMenuManager *menus = NULL; +#endif +#if defined SMEXT_ENABLE_ADMINSYS +IAdminSystem *adminsys = NULL; +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS +ITextParsers *textparsers = NULL; +#endif +#if defined SMEXT_ENABLE_USERMSGS +IUserMessages *usermsgs = NULL; +#endif +#if defined SMEXT_ENABLE_TRANSLATOR +ITranslator *translator = NULL; +#endif /** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() @@ -149,6 +167,24 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_LIBSYS SM_GET_IFACE(LIBRARYSYS, libsys); #endif +#if defined SMEXT_ENABLE_PLUGINSYS + SM_GET_IFACE(PLUGINSYSTEM, plsys); +#endif +#if defined SMEXT_ENABLE_MENUS + SM_GET_IFACE(MENUMANAGER, menus); +#endif +#if defined SMEXT_ENABLE_ADMINSYS + SM_GET_IFACE(ADMINSYS, adminsys); +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS + SM_GET_IFACE(TEXTPARSERS, textparsers); +#endif +#if defined SMEXT_ENABLE_USERMSGS + SM_GET_IFACE(USERMSGS, usermsgs); +#endif +#if defined SMEXT_ENABLE_TRANSLATOR + SM_GET_IFACE(TRANSLATOR, translator); +#endif if (SDK_OnLoad(error, maxlength, late)) { @@ -256,7 +292,11 @@ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) { +#if defined METAMOD_PLAPI_VERSION + if (name && !strcmp(name, METAMOD_PLAPI_NAME)) +#else if (name && !strcmp(name, PLAPI_NAME)) +#endif { if (code) { @@ -277,8 +317,13 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); +#if !defined METAMOD_PLAPI_VERSION GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#else + GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); + GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#endif m_SourceMMLoaded = true; @@ -389,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -414,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/extensions/clientprefs/Makefile b/extensions/clientprefs/Makefile index 74c1c915..6a25ab71 100644 --- a/extensions/clientprefs/Makefile +++ b/extensions/clientprefs/Makefile @@ -26,7 +26,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -61,7 +61,7 @@ else -I$(MMSOURCE17)/core/sourcehook endif -LINK += -static-libgcc +LINK += -m32 -ldl -lm CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ @@ -84,14 +84,21 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp @@ -112,7 +119,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/extensions/clientprefs/sdk/smsdk_ext.cpp b/extensions/clientprefs/sdk/smsdk_ext.cpp index 865f536e..6404a919 100644 --- a/extensions/clientprefs/sdk/smsdk_ext.cpp +++ b/extensions/clientprefs/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -434,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -459,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/extensions/cstrike/Makefile b/extensions/cstrike/Makefile index df1fc6a2..8af4f349 100644 --- a/extensions/cstrike/Makefile +++ b/extensions/cstrike/Makefile @@ -26,7 +26,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -61,7 +61,7 @@ else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif -LINK += -static-libgcc +LINK += -m32 -ldl -lm CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -mfpmath=sse \ @@ -84,6 +84,15 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) @@ -111,7 +120,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/extensions/cstrike/sdk/smsdk_ext.cpp b/extensions/cstrike/sdk/smsdk_ext.cpp index 37733333..6404a919 100644 --- a/extensions/cstrike/sdk/smsdk_ext.cpp +++ b/extensions/cstrike/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -79,9 +79,24 @@ IThreader *threader = NULL; #if defined SMEXT_ENABLE_LIBSYS ILibrarySys *libsys = NULL; #endif +#if defined SMEXT_ENABLE_PLUGINSYS +SourceMod::IPluginManager *plsys; +#endif +#if defined SMEXT_ENABLE_MENUS +IMenuManager *menus = NULL; +#endif +#if defined SMEXT_ENABLE_ADMINSYS +IAdminSystem *adminsys = NULL; +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS +ITextParsers *textparsers = NULL; +#endif #if defined SMEXT_ENABLE_USERMSGS IUserMessages *usermsgs = NULL; #endif +#if defined SMEXT_ENABLE_TRANSLATOR +ITranslator *translator = NULL; +#endif /** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() @@ -152,9 +167,24 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_LIBSYS SM_GET_IFACE(LIBRARYSYS, libsys); #endif +#if defined SMEXT_ENABLE_PLUGINSYS + SM_GET_IFACE(PLUGINSYSTEM, plsys); +#endif +#if defined SMEXT_ENABLE_MENUS + SM_GET_IFACE(MENUMANAGER, menus); +#endif +#if defined SMEXT_ENABLE_ADMINSYS + SM_GET_IFACE(ADMINSYS, adminsys); +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS + SM_GET_IFACE(TEXTPARSERS, textparsers); +#endif #if defined SMEXT_ENABLE_USERMSGS SM_GET_IFACE(USERMSGS, usermsgs); #endif +#if defined SMEXT_ENABLE_TRANSLATOR + SM_GET_IFACE(TRANSLATOR, translator); +#endif if (SDK_OnLoad(error, maxlength, late)) { @@ -262,7 +292,11 @@ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) { +#if defined METAMOD_PLAPI_VERSION if (name && !strcmp(name, METAMOD_PLAPI_NAME)) +#else + if (name && !strcmp(name, PLAPI_NAME)) +#endif { if (code) { @@ -283,8 +317,13 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); +#if !defined METAMOD_PLAPI_VERSION + GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); + GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#else GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#endif m_SourceMMLoaded = true; @@ -395,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -420,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/extensions/geoip/Makefile b/extensions/geoip/Makefile index ff77b74c..131c5c03 100644 --- a/extensions/geoip/Makefile +++ b/extensions/geoip/Makefile @@ -26,7 +26,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -60,7 +60,7 @@ else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif -LINK += -static-libgcc +LINK += -m32 -ldl -lm CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -mfpmath=sse \ @@ -83,14 +83,21 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp @@ -111,7 +118,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/extensions/geoip/sdk/smsdk_ext.cpp b/extensions/geoip/sdk/smsdk_ext.cpp index db14af69..6404a919 100644 --- a/extensions/geoip/sdk/smsdk_ext.cpp +++ b/extensions/geoip/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -79,6 +79,24 @@ IThreader *threader = NULL; #if defined SMEXT_ENABLE_LIBSYS ILibrarySys *libsys = NULL; #endif +#if defined SMEXT_ENABLE_PLUGINSYS +SourceMod::IPluginManager *plsys; +#endif +#if defined SMEXT_ENABLE_MENUS +IMenuManager *menus = NULL; +#endif +#if defined SMEXT_ENABLE_ADMINSYS +IAdminSystem *adminsys = NULL; +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS +ITextParsers *textparsers = NULL; +#endif +#if defined SMEXT_ENABLE_USERMSGS +IUserMessages *usermsgs = NULL; +#endif +#if defined SMEXT_ENABLE_TRANSLATOR +ITranslator *translator = NULL; +#endif /** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() @@ -149,6 +167,24 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_LIBSYS SM_GET_IFACE(LIBRARYSYS, libsys); #endif +#if defined SMEXT_ENABLE_PLUGINSYS + SM_GET_IFACE(PLUGINSYSTEM, plsys); +#endif +#if defined SMEXT_ENABLE_MENUS + SM_GET_IFACE(MENUMANAGER, menus); +#endif +#if defined SMEXT_ENABLE_ADMINSYS + SM_GET_IFACE(ADMINSYS, adminsys); +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS + SM_GET_IFACE(TEXTPARSERS, textparsers); +#endif +#if defined SMEXT_ENABLE_USERMSGS + SM_GET_IFACE(USERMSGS, usermsgs); +#endif +#if defined SMEXT_ENABLE_TRANSLATOR + SM_GET_IFACE(TRANSLATOR, translator); +#endif if (SDK_OnLoad(error, maxlength, late)) { @@ -256,7 +292,11 @@ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) { +#if defined METAMOD_PLAPI_VERSION + if (name && !strcmp(name, METAMOD_PLAPI_NAME)) +#else if (name && !strcmp(name, PLAPI_NAME)) +#endif { if (code) { @@ -277,8 +317,13 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); +#if !defined METAMOD_PLAPI_VERSION GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#else + GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); + GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#endif m_SourceMMLoaded = true; @@ -389,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -414,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/extensions/mysql/Makefile b/extensions/mysql/Makefile index fc597251..7352f702 100644 --- a/extensions/mysql/Makefile +++ b/extensions/mysql/Makefile @@ -30,7 +30,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -65,7 +65,7 @@ else -I$(MYSQL)/include endif -LINK += $(MYSQL)/lib/libmysqlclient_r.a -lz -static-libgcc -lpthread +LINK += $(MYSQL)/lib/libmysqlclient_r.a -lz -lpthread CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ @@ -94,7 +94,14 @@ ifeq "$(GCC_VERSION)" "4" CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) @@ -117,7 +124,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/extensions/mysql/sdk/smsdk_ext.cpp b/extensions/mysql/sdk/smsdk_ext.cpp index db14af69..6404a919 100644 --- a/extensions/mysql/sdk/smsdk_ext.cpp +++ b/extensions/mysql/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -79,6 +79,24 @@ IThreader *threader = NULL; #if defined SMEXT_ENABLE_LIBSYS ILibrarySys *libsys = NULL; #endif +#if defined SMEXT_ENABLE_PLUGINSYS +SourceMod::IPluginManager *plsys; +#endif +#if defined SMEXT_ENABLE_MENUS +IMenuManager *menus = NULL; +#endif +#if defined SMEXT_ENABLE_ADMINSYS +IAdminSystem *adminsys = NULL; +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS +ITextParsers *textparsers = NULL; +#endif +#if defined SMEXT_ENABLE_USERMSGS +IUserMessages *usermsgs = NULL; +#endif +#if defined SMEXT_ENABLE_TRANSLATOR +ITranslator *translator = NULL; +#endif /** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() @@ -149,6 +167,24 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_LIBSYS SM_GET_IFACE(LIBRARYSYS, libsys); #endif +#if defined SMEXT_ENABLE_PLUGINSYS + SM_GET_IFACE(PLUGINSYSTEM, plsys); +#endif +#if defined SMEXT_ENABLE_MENUS + SM_GET_IFACE(MENUMANAGER, menus); +#endif +#if defined SMEXT_ENABLE_ADMINSYS + SM_GET_IFACE(ADMINSYS, adminsys); +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS + SM_GET_IFACE(TEXTPARSERS, textparsers); +#endif +#if defined SMEXT_ENABLE_USERMSGS + SM_GET_IFACE(USERMSGS, usermsgs); +#endif +#if defined SMEXT_ENABLE_TRANSLATOR + SM_GET_IFACE(TRANSLATOR, translator); +#endif if (SDK_OnLoad(error, maxlength, late)) { @@ -256,7 +292,11 @@ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) { +#if defined METAMOD_PLAPI_VERSION + if (name && !strcmp(name, METAMOD_PLAPI_NAME)) +#else if (name && !strcmp(name, PLAPI_NAME)) +#endif { if (code) { @@ -277,8 +317,13 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); +#if !defined METAMOD_PLAPI_VERSION GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#else + GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); + GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#endif m_SourceMMLoaded = true; @@ -389,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -414,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/extensions/regex/Makefile b/extensions/regex/Makefile index 39983d09..5b057128 100644 --- a/extensions/regex/Makefile +++ b/extensions/regex/Makefile @@ -26,7 +26,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -60,7 +60,7 @@ else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(MMSOURCE17)/core/sourcehook endif -LINK += lib_linux/libpcre.a -static-libgcc +LINK += -m32 -ldl -lm CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -mfpmath=sse \ @@ -83,14 +83,21 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += lib_darwin_x86/libpcre.a -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += lib_linux/libpcre.a -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp @@ -111,7 +118,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/extensions/regex/sdk/smsdk_ext.cpp b/extensions/regex/sdk/smsdk_ext.cpp index bf027ac5..6404a919 100644 --- a/extensions/regex/sdk/smsdk_ext.cpp +++ b/extensions/regex/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -94,6 +94,9 @@ ITextParsers *textparsers = NULL; #if defined SMEXT_ENABLE_USERMSGS IUserMessages *usermsgs = NULL; #endif +#if defined SMEXT_ENABLE_TRANSLATOR +ITranslator *translator = NULL; +#endif /** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() @@ -179,6 +182,9 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_USERMSGS SM_GET_IFACE(USERMSGS, usermsgs); #endif +#if defined SMEXT_ENABLE_TRANSLATOR + SM_GET_IFACE(TRANSLATOR, translator); +#endif if (SDK_OnLoad(error, maxlength, late)) { @@ -311,7 +317,7 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); -#if defined METAMOD_PLAPI_VERSION +#if !defined METAMOD_PLAPI_VERSION GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); #else @@ -428,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -453,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/extensions/sdktools/Makefile b/extensions/sdktools/Makefile index 8ed4c6f0..125c2565 100644 --- a/extensions/sdktools/Makefile +++ b/extensions/sdktools/Makefile @@ -29,7 +29,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -64,7 +64,7 @@ else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif -LINK += -static-libgcc +LINK += -m32 -ldl -lm CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ @@ -87,6 +87,15 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) @@ -115,7 +124,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/extensions/sdktools/detours.h b/extensions/sdktools/detours.h index ab7a30c6..a028e3a4 100644 --- a/extensions/sdktools/detours.h +++ b/extensions/sdktools/detours.h @@ -32,7 +32,7 @@ #ifndef _INCLUDE_SOURCEMOD_DETOURS_H_ #define _INCLUDE_SOURCEMOD_DETOURS_H_ -#if defined PLATFORM_LINUX +#if defined PLATFORM_POSIX #include #define PAGE_SIZE 4096 #define ALIGN(ar) ((long)ar & ~(PAGE_SIZE-1)) diff --git a/extensions/sdktools/sdk/smsdk_ext.cpp b/extensions/sdktools/sdk/smsdk_ext.cpp index a823d1b2..6404a919 100644 --- a/extensions/sdktools/sdk/smsdk_ext.cpp +++ b/extensions/sdktools/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -82,6 +82,21 @@ ILibrarySys *libsys = NULL; #if defined SMEXT_ENABLE_PLUGINSYS SourceMod::IPluginManager *plsys; #endif +#if defined SMEXT_ENABLE_MENUS +IMenuManager *menus = NULL; +#endif +#if defined SMEXT_ENABLE_ADMINSYS +IAdminSystem *adminsys = NULL; +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS +ITextParsers *textparsers = NULL; +#endif +#if defined SMEXT_ENABLE_USERMSGS +IUserMessages *usermsgs = NULL; +#endif +#if defined SMEXT_ENABLE_TRANSLATOR +ITranslator *translator = NULL; +#endif /** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() @@ -155,6 +170,21 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_PLUGINSYS SM_GET_IFACE(PLUGINSYSTEM, plsys); #endif +#if defined SMEXT_ENABLE_MENUS + SM_GET_IFACE(MENUMANAGER, menus); +#endif +#if defined SMEXT_ENABLE_ADMINSYS + SM_GET_IFACE(ADMINSYS, adminsys); +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS + SM_GET_IFACE(TEXTPARSERS, textparsers); +#endif +#if defined SMEXT_ENABLE_USERMSGS + SM_GET_IFACE(USERMSGS, usermsgs); +#endif +#if defined SMEXT_ENABLE_TRANSLATOR + SM_GET_IFACE(TRANSLATOR, translator); +#endif if (SDK_OnLoad(error, maxlength, late)) { @@ -262,7 +292,11 @@ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) { +#if defined METAMOD_PLAPI_VERSION if (name && !strcmp(name, METAMOD_PLAPI_NAME)) +#else + if (name && !strcmp(name, PLAPI_NAME)) +#endif { if (code) { @@ -283,8 +317,13 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); +#if !defined METAMOD_PLAPI_VERSION + GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); + GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#else GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#endif m_SourceMMLoaded = true; @@ -395,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -420,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/extensions/sqlite/Makefile b/extensions/sqlite/Makefile index d492167b..260b3a06 100644 --- a/extensions/sqlite/Makefile +++ b/extensions/sqlite/Makefile @@ -46,7 +46,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -80,7 +80,7 @@ else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(MMSOURCE17)/core/sourcehook endif -LINK += -static-libgcc -lpthread +LINK += -lpthread -m32 -ldl -lm CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \ @@ -104,14 +104,21 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o) @@ -138,7 +145,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/extensions/sqlite/driver/SqDriver.cpp b/extensions/sqlite/driver/SqDriver.cpp index 397fed5b..5380394b 100644 --- a/extensions/sqlite/driver/SqDriver.cpp +++ b/extensions/sqlite/driver/SqDriver.cpp @@ -151,7 +151,7 @@ inline bool IsPathSepChar(char c) { #if defined PLATFORM_WINDOWS return (c == '\\' || c == '/'); -#elif defined PLATFORM_LINUX +#elif defined PLATFORM_LINUX || defined PLATFORM_APPLE return (c == '/'); #endif } diff --git a/extensions/sqlite/driver/SqResults.cpp b/extensions/sqlite/driver/SqResults.cpp index 0809ab6a..f4c2215b 100644 --- a/extensions/sqlite/driver/SqResults.cpp +++ b/extensions/sqlite/driver/SqResults.cpp @@ -343,7 +343,7 @@ bool SqResults::IsNull(unsigned int columnId) return (field->type == SQLITE_NULL); } -unsigned int SqResults::GetDataSize(unsigned int columnId) +size_t SqResults::GetDataSize(unsigned int columnId) { SqField *field = GetField(columnId); if (!field) diff --git a/extensions/sqlite/sdk/sm_memtable.cpp b/extensions/sqlite/sdk/sm_memtable.cpp index 8f18b136..e13cd891 100644 --- a/extensions/sqlite/sdk/sm_memtable.cpp +++ b/extensions/sqlite/sdk/sm_memtable.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "sm_memtable.h" BaseMemTable::BaseMemTable(unsigned int init_size) diff --git a/extensions/sqlite/sdk/smsdk_ext.cpp b/extensions/sqlite/sdk/smsdk_ext.cpp index c504da48..6404a919 100644 --- a/extensions/sqlite/sdk/smsdk_ext.cpp +++ b/extensions/sqlite/sdk/smsdk_ext.cpp @@ -28,8 +28,9 @@ * * Version: $Id$ */ + #include -#include +#include #include "smsdk_ext.h" /** @@ -78,6 +79,24 @@ IThreader *threader = NULL; #if defined SMEXT_ENABLE_LIBSYS ILibrarySys *libsys = NULL; #endif +#if defined SMEXT_ENABLE_PLUGINSYS +SourceMod::IPluginManager *plsys; +#endif +#if defined SMEXT_ENABLE_MENUS +IMenuManager *menus = NULL; +#endif +#if defined SMEXT_ENABLE_ADMINSYS +IAdminSystem *adminsys = NULL; +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS +ITextParsers *textparsers = NULL; +#endif +#if defined SMEXT_ENABLE_USERMSGS +IUserMessages *usermsgs = NULL; +#endif +#if defined SMEXT_ENABLE_TRANSLATOR +ITranslator *translator = NULL; +#endif /** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() @@ -148,6 +167,24 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_LIBSYS SM_GET_IFACE(LIBRARYSYS, libsys); #endif +#if defined SMEXT_ENABLE_PLUGINSYS + SM_GET_IFACE(PLUGINSYSTEM, plsys); +#endif +#if defined SMEXT_ENABLE_MENUS + SM_GET_IFACE(MENUMANAGER, menus); +#endif +#if defined SMEXT_ENABLE_ADMINSYS + SM_GET_IFACE(ADMINSYS, adminsys); +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS + SM_GET_IFACE(TEXTPARSERS, textparsers); +#endif +#if defined SMEXT_ENABLE_USERMSGS + SM_GET_IFACE(USERMSGS, usermsgs); +#endif +#if defined SMEXT_ENABLE_TRANSLATOR + SM_GET_IFACE(TRANSLATOR, translator); +#endif if (SDK_OnLoad(error, maxlength, late)) { @@ -255,7 +292,11 @@ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) { +#if defined METAMOD_PLAPI_VERSION + if (name && !strcmp(name, METAMOD_PLAPI_NAME)) +#else if (name && !strcmp(name, PLAPI_NAME)) +#endif { if (code) { @@ -276,8 +317,13 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); +#if !defined METAMOD_PLAPI_VERSION GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#else + GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); + GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#endif m_SourceMMLoaded = true; @@ -388,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -413,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/extensions/tf2/CDetour/detourhelpers.h b/extensions/tf2/CDetour/detourhelpers.h index c043cb2c..aea6faa0 100644 --- a/extensions/tf2/CDetour/detourhelpers.h +++ b/extensions/tf2/CDetour/detourhelpers.h @@ -32,7 +32,7 @@ #ifndef _INCLUDE_SOURCEMOD_DETOURHELPERS_H_ #define _INCLUDE_SOURCEMOD_DETOURHELPERS_H_ -#if defined PLATFORM_LINUX +#if defined PLATFORM_POSIX #include #define PAGE_SIZE 4096 #define ALIGN(ar) ((long)ar & ~(PAGE_SIZE-1)) @@ -52,7 +52,7 @@ struct patch_t inline void ProtectMemory(void *addr, int length, int prot) { -#if defined PLATFORM_LINUX +#if defined PLATFORM_POSIX void *addr2 = (void *)ALIGN(addr); mprotect(addr2, sysconf(_SC_PAGESIZE), prot); #elif defined PLATFORM_WINDOWS diff --git a/extensions/tf2/Makefile b/extensions/tf2/Makefile index deded0d7..88b3401b 100644 --- a/extensions/tf2/Makefile +++ b/extensions/tf2/Makefile @@ -27,7 +27,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -62,7 +62,7 @@ else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif -LINK += -static-libgcc +LINK += -m32 -ldl -lm CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ @@ -85,14 +85,21 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp @@ -114,7 +121,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/extensions/tf2/sdk/smsdk_ext.cpp b/extensions/tf2/sdk/smsdk_ext.cpp index 37733333..6404a919 100644 --- a/extensions/tf2/sdk/smsdk_ext.cpp +++ b/extensions/tf2/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -79,9 +79,24 @@ IThreader *threader = NULL; #if defined SMEXT_ENABLE_LIBSYS ILibrarySys *libsys = NULL; #endif +#if defined SMEXT_ENABLE_PLUGINSYS +SourceMod::IPluginManager *plsys; +#endif +#if defined SMEXT_ENABLE_MENUS +IMenuManager *menus = NULL; +#endif +#if defined SMEXT_ENABLE_ADMINSYS +IAdminSystem *adminsys = NULL; +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS +ITextParsers *textparsers = NULL; +#endif #if defined SMEXT_ENABLE_USERMSGS IUserMessages *usermsgs = NULL; #endif +#if defined SMEXT_ENABLE_TRANSLATOR +ITranslator *translator = NULL; +#endif /** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() @@ -152,9 +167,24 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_LIBSYS SM_GET_IFACE(LIBRARYSYS, libsys); #endif +#if defined SMEXT_ENABLE_PLUGINSYS + SM_GET_IFACE(PLUGINSYSTEM, plsys); +#endif +#if defined SMEXT_ENABLE_MENUS + SM_GET_IFACE(MENUMANAGER, menus); +#endif +#if defined SMEXT_ENABLE_ADMINSYS + SM_GET_IFACE(ADMINSYS, adminsys); +#endif +#if defined SMEXT_ENABLE_TEXTPARSERS + SM_GET_IFACE(TEXTPARSERS, textparsers); +#endif #if defined SMEXT_ENABLE_USERMSGS SM_GET_IFACE(USERMSGS, usermsgs); #endif +#if defined SMEXT_ENABLE_TRANSLATOR + SM_GET_IFACE(TRANSLATOR, translator); +#endif if (SDK_OnLoad(error, maxlength, late)) { @@ -262,7 +292,11 @@ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) { +#if defined METAMOD_PLAPI_VERSION if (name && !strcmp(name, METAMOD_PLAPI_NAME)) +#else + if (name && !strcmp(name, PLAPI_NAME)) +#endif { if (code) { @@ -283,8 +317,13 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); +#if !defined METAMOD_PLAPI_VERSION + GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); + GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#else GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#endif m_SourceMMLoaded = true; @@ -395,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -420,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/extensions/topmenus/Makefile b/extensions/topmenus/Makefile index 9f8635b8..711c0e0c 100644 --- a/extensions/topmenus/Makefile +++ b/extensions/topmenus/Makefile @@ -27,7 +27,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -62,7 +62,7 @@ else -I$(MMSOURCE17)/core/sourcehook endif -LINK += -static-libgcc +LINK += -m32 -ldl -lm CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ @@ -85,14 +85,21 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp @@ -113,7 +120,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/extensions/topmenus/sdk/sm_memtable.cpp b/extensions/topmenus/sdk/sm_memtable.cpp index 8f18b136..e13cd891 100644 --- a/extensions/topmenus/sdk/sm_memtable.cpp +++ b/extensions/topmenus/sdk/sm_memtable.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "sm_memtable.h" BaseMemTable::BaseMemTable(unsigned int init_size) diff --git a/extensions/topmenus/sdk/smsdk_ext.cpp b/extensions/topmenus/sdk/smsdk_ext.cpp index 852361b1..6404a919 100644 --- a/extensions/topmenus/sdk/smsdk_ext.cpp +++ b/extensions/topmenus/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -91,6 +91,12 @@ IAdminSystem *adminsys = NULL; #if defined SMEXT_ENABLE_TEXTPARSERS ITextParsers *textparsers = NULL; #endif +#if defined SMEXT_ENABLE_USERMSGS +IUserMessages *usermsgs = NULL; +#endif +#if defined SMEXT_ENABLE_TRANSLATOR +ITranslator *translator = NULL; +#endif /** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() @@ -173,6 +179,12 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_TEXTPARSERS SM_GET_IFACE(TEXTPARSERS, textparsers); #endif +#if defined SMEXT_ENABLE_USERMSGS + SM_GET_IFACE(USERMSGS, usermsgs); +#endif +#if defined SMEXT_ENABLE_TRANSLATOR + SM_GET_IFACE(TRANSLATOR, translator); +#endif if (SDK_OnLoad(error, maxlength, late)) { @@ -280,7 +292,11 @@ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) { +#if defined METAMOD_PLAPI_VERSION + if (name && !strcmp(name, METAMOD_PLAPI_NAME)) +#else if (name && !strcmp(name, PLAPI_NAME)) +#endif { if (code) { @@ -301,8 +317,13 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); +#if !defined METAMOD_PLAPI_VERSION GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#else + GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); + GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); +#endif m_SourceMMLoaded = true; @@ -413,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -438,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/knight/shared/KePlatform.h b/knight/shared/KePlatform.h index 775355cb..a4a9f3cf 100644 --- a/knight/shared/KePlatform.h +++ b/knight/shared/KePlatform.h @@ -18,6 +18,8 @@ #if defined linux #define KE_PLATFORM_LINUX +#elif defined __APPLE__ +#define KE_PLATFORM_APPLE #else #error "TODO" #endif diff --git a/loader/Makefile b/loader/Makefile index 106368c2..23a1d276 100644 --- a/loader/Makefile +++ b/loader/Makefile @@ -19,9 +19,9 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc -LINK = -static-libgcc +LINK = -m32 -ldl -lm INCLUDE = -I$(MMSOURCE17)/core -I$(MMSOURCE17)/core/sourcehook @@ -42,14 +42,21 @@ else CFLAGS += $(C_OPT_FLAGS) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT)_i486.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT)_i486.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp @@ -60,7 +67,7 @@ all: $(MAKE) -f Makefile loader loader: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/loader/loader.cpp b/loader/loader.cpp index bb5f5ee9..b276d077 100644 --- a/loader/loader.cpp +++ b/loader/loader.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #if defined _MSC_VER #define DLL_EXPORT extern "C" __declspec(dllexport) @@ -119,7 +119,7 @@ METAMOD_PLUGIN *_GetPluginPtr(const char *path, int fail_api) if (!(g_hCore=openlib(path))) { -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ UTIL_Format(s_FailPlugin.error_buffer, sizeof(s_FailPlugin.error_buffer), "%s", @@ -289,7 +289,7 @@ __attribute__((destructor)) static void gcc_fini() #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } diff --git a/public/mms_sample_ext/Makefile b/public/mms_sample_ext/Makefile index 8d55d366..8f8328bc 100644 --- a/public/mms_sample_ext/Makefile +++ b/public/mms_sample_ext/Makefile @@ -23,7 +23,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -46,7 +46,7 @@ ifeq "$(ENGINE)" "orangebox" override ENGSET = true endif -LINK = vstdlib_i486.so tier0_i486.so -static-libgcc +LINK = vstdlib_i486.so tier0_i486.so -m32 -ldl -lm INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK) -I$(SMSDK)/jit -I$(SMSDK)/jit/x86 \ @@ -69,14 +69,21 @@ else CFLAGS += $(C_OPT_FLAGS) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT)_i486.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT)_i486.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp @@ -95,7 +102,7 @@ check: fi mms_ext: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/public/sample_ext/Makefile b/public/sample_ext/Makefile index ea256b8c..ff6d679f 100644 --- a/public/sample_ext/Makefile +++ b/public/sample_ext/Makefile @@ -26,7 +26,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc override ENGSET = false ifeq "$(ENGINE)" "original" @@ -60,7 +60,7 @@ else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif -LINK += -static-libgcc +LINK += -m32 -lm -ldl CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ @@ -83,14 +83,21 @@ ifeq "$(USEMETA)" "true" BIN_DIR := $(BIN_DIR).$(ENGINE) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).ext.dylib +else + LINK += -static-libgcc -shared + BINARY = $(PROJECT).ext.so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp @@ -111,7 +118,7 @@ check: fi extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/public/sample_ext/sdk/smsdk_ext.cpp b/public/sample_ext/sdk/smsdk_ext.cpp index 865f536e..6404a919 100644 --- a/public/sample_ext/sdk/smsdk_ext.cpp +++ b/public/sample_ext/sdk/smsdk_ext.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "smsdk_ext.h" /** @@ -434,7 +434,7 @@ bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t max #endif /* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } @@ -459,3 +459,4 @@ void operator delete[](void * ptr) free(ptr); } #endif + diff --git a/public/sm_platform.h b/public/sm_platform.h index 50928e61..8f23b7a0 100644 --- a/public/sm_platform.h +++ b/public/sm_platform.h @@ -60,14 +60,21 @@ #if defined _MSC_VER && _MSC_VER >= 1400 #define SUBPLATFORM_SECURECRT #endif -#elif defined __linux__ -#define PLATFORM_LINUX +#elif defined __linux__ || defined __APPLE__ +#if defined __linux__ +# define PLATFORM_LINUX +#elif defined __APPLE__ +# define PLATFORM_APPLE +#endif #define PLATFORM_POSIX #include #include #include #include #include +#if defined PLATFORM_APPLE +#include +#endif #define PLATFORM_MAX_PATH PATH_MAX #define PLATFORM_LIB_EXT "so" #define PLATFORM_SEP_CHAR '/' @@ -80,3 +87,4 @@ #endif #endif //_INCLUDE_SOURCEMOD_PLATFORM_H_ + diff --git a/public/sm_trie_tpl.h b/public/sm_trie_tpl.h index 61b8f1e5..d0576929 100644 --- a/public/sm_trie_tpl.h +++ b/public/sm_trie_tpl.h @@ -34,7 +34,7 @@ #include #include -#include +#include #include enum NodeType diff --git a/public/sourcepawn/sp_file_headers.h b/public/sourcepawn/sp_file_headers.h index d1a411a8..151cc953 100644 --- a/public/sourcepawn/sp_file_headers.h +++ b/public/sourcepawn/sp_file_headers.h @@ -60,7 +60,7 @@ #define SPFILE_VERSION 0x0102 /**< File format version */ //:TODO: better compiler/nix support -#if defined __linux__ +#if defined __GNUC__ #pragma pack(1) /* structures must be packed (byte-aligned) */ #else #pragma pack(push) diff --git a/sourcepawn/compiler/Makefile b/sourcepawn/compiler/Makefile index 8e34d115..4524a374 100644 --- a/sourcepawn/compiler/Makefile +++ b/sourcepawn/compiler/Makefile @@ -24,7 +24,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -fomit-fram C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc LINK = -lgcc -static-libgcc @@ -61,7 +61,7 @@ all: $(MAKE) -f Makefile compiler compiler: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -ldl -lm -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/sourcepawn/compiler/libpawnc.c b/sourcepawn/compiler/libpawnc.c index ddaf7498..3331335b 100644 --- a/sourcepawn/compiler/libpawnc.c +++ b/sourcepawn/compiler/libpawnc.c @@ -26,7 +26,6 @@ #include #include #include -#include #include "sc.h" #include "memfile.h" diff --git a/sourcepawn/compiler/memfile.h b/sourcepawn/compiler/memfile.h index 7f953f20..8fbf38a7 100644 --- a/sourcepawn/compiler/memfile.h +++ b/sourcepawn/compiler/memfile.h @@ -1,7 +1,7 @@ #ifndef _INCLUDE_MEMFILE_H #define _INCLUDE_MEMFILE_H -#include +#include typedef struct memfile_s { diff --git a/sourcepawn/compiler/osdefs.h b/sourcepawn/compiler/osdefs.h index 7a6768c2..49ec2dca 100644 --- a/sourcepawn/compiler/osdefs.h +++ b/sourcepawn/compiler/osdefs.h @@ -48,6 +48,8 @@ #if defined __FreeBSD__ #include +#elif defined __APPLE__ + #include #elif defined LINUX #include #endif diff --git a/sourcepawn/compiler/sclinux.h b/sourcepawn/compiler/sclinux.h index f22497a8..868539ea 100644 --- a/sourcepawn/compiler/sclinux.h +++ b/sourcepawn/compiler/sclinux.h @@ -34,7 +34,7 @@ # include #endif -#if defined __OpenBSD__ || defined __FreeBSD__ +#if defined __OpenBSD__ || defined __FreeBSD__ || defined __APPLE__ # define __BYTE_ORDER BYTE_ORDER # define __LITTLE_ENDIAN LITTLE_ENDIAN # define __BIG_ENDIAN BIG_ENDIAN diff --git a/sourcepawn/compiler/sctracker.c b/sourcepawn/compiler/sctracker.c index e0617c47..7b20ab1b 100644 --- a/sourcepawn/compiler/sctracker.c +++ b/sourcepawn/compiler/sctracker.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include "sc.h" diff --git a/sourcepawn/compiler/sp_file.c b/sourcepawn/compiler/sp_file.c index a83d290d..e5d6addb 100644 --- a/sourcepawn/compiler/sp_file.c +++ b/sourcepawn/compiler/sp_file.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include "sp_file.h" #include "memfile.h" diff --git a/sourcepawn/jit/Makefile b/sourcepawn/jit/Makefile index e1c429f7..a26a48b8 100644 --- a/sourcepawn/jit/Makefile +++ b/sourcepawn/jit/Makefile @@ -42,9 +42,9 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc -LINK = -static-libgcc +LINK = -m32 -ldl -lm INCLUDE = -I. -I.. -I$(SMSDK)/public -I$(SMSDK)/public/jit -I$(SMSDK)/public/jit/x86 \ -I$(SMSDK)/public/sourcepawn -I$(MMSOURCE17)/core/sourcehook -I$(SMSDK)/knight/shared -Ix86 @@ -66,14 +66,21 @@ else CFLAGS += $(C_OPT_FLAGS) endif +OS := $(shell uname -s) +ifeq "$(OS)" "Darwin" + LINK += -dynamiclib + BINARY = $(PROJECT).dylib +else + LINK += -static-libgcc-shared + BINARY = $(PROJECT).so +endif + GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) ifeq "$(GCC_VERSION)" "4" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).so - OBJ_LINUX := $(OBJECTS:../../knight/shared/%.cpp=$(BIN_DIR)/knight/%.o) OBJ_LINUX := $(OBJ_LINUX:%.cpp=$(BIN_DIR)/%.o) OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o) @@ -96,7 +103,7 @@ all: $(MAKE) -f Makefile jit jit: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/sourcepawn/jit/dll_exports.cpp b/sourcepawn/jit/dll_exports.cpp index 91a80743..36305d9a 100644 --- a/sourcepawn/jit/dll_exports.cpp +++ b/sourcepawn/jit/dll_exports.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "x86/jit_x86.h" #include "dll_exports.h" #include "sp_vm_engine.h" @@ -48,7 +48,7 @@ EXPORTFUNC ISourcePawnEngine2 *GetSourcePawnEngine2() return &g_engine2; } -#if defined __linux__ +#if defined __linux__ || defined __APPLE__ extern "C" void __cxa_pure_virtual(void) { } diff --git a/sourcepawn/jit/sp_vm_engine.cpp b/sourcepawn/jit/sp_vm_engine.cpp index dc300d69..c1ed750f 100644 --- a/sourcepawn/jit/sp_vm_engine.cpp +++ b/sourcepawn/jit/sp_vm_engine.cpp @@ -29,7 +29,7 @@ * Version: $Id$ */ -#include +#include #include #include #include "sp_vm_types.h" @@ -111,7 +111,11 @@ void *SourcePawnEngine::ExecAlloc(size_t size) #if defined WIN32 return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); #elif defined __GNUC__ +# if defined __APPLE__ + void *base = valloc(size); +# else void *base = memalign(sysconf(_SC_PAGESIZE), size); +# endif if (mprotect(base, size, PROT_READ|PROT_WRITE|PROT_EXEC) != 0) { free(base); diff --git a/sourcepawn/jit/x86/opcode_helpers.cpp b/sourcepawn/jit/x86/opcode_helpers.cpp index 30311202..cf42433b 100644 --- a/sourcepawn/jit/x86/opcode_helpers.cpp +++ b/sourcepawn/jit/x86/opcode_helpers.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include "jit_x86.h" #include "opcode_helpers.h" #include "x86_macros.h" diff --git a/tools/builder/LinuxBuilder.cs b/tools/builder/LinuxBuilder.cs index 1fac9619..4e091020 100644 --- a/tools/builder/LinuxBuilder.cs +++ b/tools/builder/LinuxBuilder.cs @@ -60,19 +60,18 @@ namespace builder File.Delete(binpath); } - string makefile_args = ""; + string makefile_args = "CPP=gcc-4.1 "; if (lib.build_mode == BuildMode.BuildMode_Episode1) { - makefile_args = null; } else if (lib.build_mode == BuildMode.BuildMode_Episode2) { - makefile_args = "ENGINE=\"orangebox\""; + makefile_args += "ENGINE=\"orangebox\" "; } else if (lib.build_mode == BuildMode.BuildMode_OldMetamod) { - makefile_args = "ENGINE=\"original\""; + makefile_args += "ENGINE=\"original\" "; } /* Clean the project first */ diff --git a/tools/crc32/build.sh b/tools/crc32/build.sh index 62b2891c..91a988f5 100755 --- a/tools/crc32/build.sh +++ b/tools/crc32/build.sh @@ -1,2 +1,2 @@ -g++ -I../../core ../../core/sm_crc32.cpp main.cpp -ocrc32 +g++ -I../../core ../../core/sm_crc32.cpp main.cpp -o crc32 diff --git a/tools/daemon/Makefile b/tools/daemon/Makefile index 28ab2826..10259556 100644 --- a/tools/daemon/Makefile +++ b/tools/daemon/Makefile @@ -16,7 +16,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc BINARY = smupdated @@ -65,7 +65,7 @@ all: $(MAKE) -f Makefile sourcemod sourcemod: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -lstdc++ -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -lstdc++ -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/tools/gamedata_md5/Makefile b/tools/gamedata_md5/Makefile index a73b8558..9a964388 100644 --- a/tools/gamedata_md5/Makefile +++ b/tools/gamedata_md5/Makefile @@ -16,7 +16,7 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc-4.1 +CPP = gcc BINARY = gamedatamd5 @@ -63,7 +63,7 @@ all: $(MAKE) -f Makefile sourcemod sourcemod: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -lstdc++ -o$(BIN_DIR)/$(BINARY) + $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -lstdc++ -o $(BIN_DIR)/$(BINARY) debug: $(MAKE) -f Makefile all DEBUG=true diff --git a/tools/gamedata_md5/sm_memtable.cpp b/tools/gamedata_md5/sm_memtable.cpp index 8f18b136..e13cd891 100644 --- a/tools/gamedata_md5/sm_memtable.cpp +++ b/tools/gamedata_md5/sm_memtable.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "sm_memtable.h" BaseMemTable::BaseMemTable(unsigned int init_size)