From a62aeb36d8fe857b4d691cb108d2861aa6a5414b Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Sat, 25 Aug 2012 11:32:33 -0500 Subject: [PATCH] Updated sample extension makefiles for CS:GO on Mac OS X (bug 5459, r=psychonic). --- public/mms_sample_ext/Makefile | 35 ++++++++++++++++++++++++++++++---- public/sample_ext/Makefile | 35 ++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/public/mms_sample_ext/Makefile b/public/mms_sample_ext/Makefile index 84b02f7a..acc7b9cf 100644 --- a/public/mms_sample_ext/Makefile +++ b/public/mms_sample_ext/Makefile @@ -27,6 +27,7 @@ C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden CPP = gcc +CPP_OSX = clang ########################## ### SDK CONFIGURATIONS ### @@ -116,7 +117,7 @@ INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB) CFLAGS += -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC -Wall -Werror \ - -Wno-switch -Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 + -Wno-overloaded-virtual -Wno-switch -Wno-unused -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti ################################################ @@ -134,8 +135,9 @@ else endif ifeq "$(OS)" "Darwin" + CPP = $(CPP_OSX) LIB_EXT = dylib - CFLAGS += -isysroot /Developer/SDKs/MacOSX10.5.sdk + CFLAGS += -DOSX -D_OSX LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5 else LIB_EXT = so @@ -143,12 +145,37 @@ else LINK += -shared endif -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" +IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0") + +ifeq "$(IS_CLANG)" "1" + CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/") + CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/") +else + CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1) + CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3) +endif + +# If not clang +ifeq "$(IS_CLANG)" "0" + CFLAGS += -mfpmath=sse +endif + +# Clang || GCC >= 4 +ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif +# Clang >= 3 || GCC >= 4.7 +ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1" + CFLAGS += -Wno-delete-non-virtual-dtor +endif + +# OS is Linux and not using clang +ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1" + LINK += -static-libgcc +endif + OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) # This will break if we include other Makefiles, but is fine for now. It allows diff --git a/public/sample_ext/Makefile b/public/sample_ext/Makefile index 268ec4ea..a73a3188 100644 --- a/public/sample_ext/Makefile +++ b/public/sample_ext/Makefile @@ -35,6 +35,7 @@ C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden CPP = gcc +CPP_OSX = clang ########################## ### SDK CONFIGURATIONS ### @@ -129,7 +130,7 @@ LINK += -m32 -lm -ldl CFLAGS += -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC -Wall -Werror \ - -Wno-switch -Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 + -Wno-overloaded-virtual -Wno-switch -Wno-unused -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti ################################################ @@ -151,8 +152,9 @@ ifeq "$(USEMETA)" "true" endif ifeq "$(OS)" "Darwin" + CPP = $(CPP_OSX) LIB_EXT = dylib - CFLAGS += -isysroot /Developer/SDKs/MacOSX10.5.sdk + CFLAGS += -DOSX -D_OSX LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5 else LIB_EXT = so @@ -160,12 +162,37 @@ else LINK += -shared endif -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" +IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0") + +ifeq "$(IS_CLANG)" "1" + CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/") + CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/") +else + CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1) + CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3) +endif + +# If not clang +ifeq "$(IS_CLANG)" "0" + CFLAGS += -mfpmath=sse +endif + +# Clang || GCC >= 4 +ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1" CFLAGS += $(C_GCC4_FLAGS) CPPFLAGS += $(CPP_GCC4_FLAGS) endif +# Clang >= 3 || GCC >= 4.7 +ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1" + CFLAGS += -Wno-delete-non-virtual-dtor +endif + +# OS is Linux and not using clang +ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1" + LINK += -static-libgcc +endif + OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) # This will break if we include other Makefiles, but is fine for now. It allows