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:
@@ -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
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "sc.h"
|
||||
#include "memfile.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _INCLUDE_MEMFILE_H
|
||||
#define _INCLUDE_MEMFILE_H
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct memfile_s
|
||||
{
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
|
||||
#if defined __FreeBSD__
|
||||
#include <sys/endian.h>
|
||||
#elif defined __APPLE__
|
||||
#include <machine/endian.h>
|
||||
#elif defined LINUX
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
# include <stdlib.h>
|
||||
#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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "sc.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include "sp_file.h"
|
||||
#include "memfile.h"
|
||||
|
||||
|
||||
+12
-5
@@ -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
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sp_vm_api.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#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);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include "jit_x86.h"
|
||||
#include "opcode_helpers.h"
|
||||
#include "x86_macros.h"
|
||||
|
||||
Reference in New Issue
Block a user