SourceMod can now be somewhat compiled on OS X for patch sanity testing (bug 3516, r=ds).

This adds the ability for us to change the GCC version we use more flexibly.
This commit is contained in:
David Anderson
2008-12-23 01:33:37 -05:00
parent 58ec9a4f38
commit 1fe38c7473
65 changed files with 599 additions and 149 deletions
+12 -5
View File
@@ -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
+12 -5
View File
@@ -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
+3 -2
View File
@@ -30,7 +30,7 @@
*/
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#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
+10 -2
View File
@@ -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 <errno.h>
#include <unistd.h>
#include <dirent.h>
#include <dlfcn.h>
#include <sys/stat.h>
#if defined PLATFORM_APPLE
#include <sys/syslimits.h>
#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_
+1 -1
View File
@@ -34,7 +34,7 @@
#include <new>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include <assert.h>
enum NodeType
+1 -1
View File
@@ -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)