update makefile for linux and osx

This commit is contained in:
Dmitry 2015-06-06 17:32:59 +03:00
commit 3371058471
2 changed files with 106 additions and 37 deletions

View file

@ -6,51 +6,122 @@
# Additional exceptions apply. For full license details, see LICENSE.txt or visit: # Additional exceptions apply. For full license details, see LICENSE.txt or visit:
# http://yapb.jeefo.net/license # http://yapb.jeefo.net/license
# #
# Based on Makefile written by David "BAILOPAN" Anderson.
#
MODNAME = yapb PROJECT = yapb
SYSTEM = ../source SRC_DIR = ../source
OBJECTS = $(SRC_DIR)/basecode.cpp \
$(SRC_DIR)/manager.cpp \
$(SRC_DIR)/chatlib.cpp \
$(SRC_DIR)/combat.cpp \
$(SRC_DIR)/globals.cpp \
$(SRC_DIR)/interface.cpp \
$(SRC_DIR)/navigate.cpp \
$(SRC_DIR)/netmsg.cpp \
$(SRC_DIR)/support.cpp \
$(SRC_DIR)/waypoint.cpp \
OBJ = ${SYSTEM}/basecode.o \ C_OPT_FLAGS = -O3 -DNDEBUG=1 -ffast-math -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe
${SYSTEM}/botmanager.o \ C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
${SYSTEM}/chatlib.o \ C_GCC4_FLAGS = -fvisibility=hidden
${SYSTEM}/combat.o \ CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
${SYSTEM}/globals.o \ CPP = clang
${SYSTEM}/interface.o \ CPP_OSX = clang
${SYSTEM}/navigate.o \
${SYSTEM}/netmsg.o \
${SYSTEM}/support.o \
${SYSTEM}/waypoint.o \
CCOPT = -w -O3 -m32 -s -DNDEBUG=1 -ffast-math -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe -fvisibility-inlines-hidden -fvisibility=hidden LINK =
CCDEBUG = -ggdb -w -DDEBUG=1 -fpermissive INCLUDE = -I../include -I../include/engine
CFLAGS = $(CCOPT) -I../include/engine -I../include
#CFLAGS = $(CCDEBUG) -I../include/engine -I../include
BASEFLAGS = -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp
CPPFLAGS = ${BASEFLAGS} ${CFLAGS}
OS := $(shell uname -s) OS := $(shell uname -s)
ifeq "$(OS)" "Darwin" ifeq "$(OS)" "Darwin"
CPP=clang CPP = $(CPP_OSX)
SUFFIX=dylib LIB_EXT = dylib
LINK=-m32 -dynamiclib -mmacosx-version-min=10.5 CFLAGS += -DOSX -D_OSX -DPOSIX
CPPLIB=-ldl -lm -lstdc++ LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5
else else
CPP=gcc LIB_EXT = so
SUFFIX=so CFLAGS += -DLINUX -D_LINUX -DPOSIX
LINK=-m32 -shared -static-libgcc LINK += -shared
CPPLIB=-ldl -lm -lsupc++
endif endif
BINARY=${MODNAME}.${SUFFIX} LINK += -m32 -lm -ldl
${MODNAME}: ${OBJ} CFLAGS += -DHAVE_STDINT_H -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp -fno-strict-aliasing -m32 -Wall -Werror -Wno-uninitialized -Wno-unused -Wno-switch -Wno-c++11-compat-deprecated-writable-strings
${CPP} ${LINK} ${OBJ} ${CPPLIB} -o ${BINARY} CPPFLAGS += -Wno-invalid-offsetof -fno-exceptions -fno-rtti
BINARY = $(PROJECT).$(LIB_EXT)
ifeq "$(DEBUG)" "true"
BIN_DIR = debug
CFLAGS += $(C_DEBUG_FLAGS)
else
BIN_DIR = release
CFLAGS += $(C_OPT_FLAGS)
LINK += -s
endif
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
# Clang || GCC >= 4
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
CFLAGS += $(C_GCC4_FLAGS)
CPPFLAGS += $(CPP_GCC4_FLAGS)
endif
ifeq "$(IS_CLANG)" "1"
CFLAGS += -Wno-logical-op-parentheses
else
CFLAGS += -Wno-parentheses
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
# OS is Linux and using clang
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 1)" "1"
LINK += -lgcc_eh
endif
OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $(subst $(SRC_DIR)/,,$@) -c $<
main:
make $(PROJECT)
$(PROJECT): $(OBJ_BIN)
$(CPP) $(INCLUDE) $(subst $(SRC_DIR)/,,$(OBJ_BIN)) $(LINK) -o $(BIN_DIR)/$(BINARY)
debug:
mkdir -p debug
$(MAKE) main DEBUG=true
release:
mkdir -p release
$(MAKE) main DEBUG=false
all: release debug
default: all
clean: clean:
-rm -f ${SYSTEM}/*.o rm -rf release
-rm -f ${BINARY} rm -rf debug
%.o: %.cpp
${CPP} ${CPPFLAGS} -c $< -o $@

View file

@ -3071,8 +3071,6 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
{ "czero", "cs.so", "cs.dylib", "mp.dll", "Counter-Strike: Condition Zero (Newer)", CSV_CZERO }, { "czero", "cs.so", "cs.dylib", "mp.dll", "Counter-Strike: Condition Zero (Newer)", CSV_CZERO },
{ "csv15", "cs_i386.so", "cs.dylib", "mp.dll", "CS 1.5 for Steam", CSV_OLD }, { "csv15", "cs_i386.so", "cs.dylib", "mp.dll", "CS 1.5 for Steam", CSV_OLD },
{ "cs13", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike v1.3", CSV_OLD }, // assume cs13 = cs15 { "cs13", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike v1.3", CSV_OLD }, // assume cs13 = cs15
{ "retrocs", "rcs_i386.so", "cs.dylib", "rcs.dll", "Retro Counter-Strike", CSV_OLD },
{"", "", "", "", 0},
}; };
// get the engine functions from the engine... // get the engine functions from the engine...
@ -3084,7 +3082,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
ModSupport_t *knownMod = NULL; ModSupport_t *knownMod = NULL;
for (int i = 0; s_supportedMods[i].name; i++) for (int i = 0; i < ARRAYSIZE_HLSDK (s_supportedMods); i++)
{ {
ModSupport_t *mod = &s_supportedMods[i]; ModSupport_t *mod = &s_supportedMods[i];