NS/main/source/linux/Makefile

152 lines
4.9 KiB
Makefile
Raw Normal View History

2014-12-16 13:36:27 +00:00
#
2014-12-16 13:36:27 +00:00
# Half-life Makefile for x86 Linux
#
#
2014-12-16 13:36:27 +00:00
OS:=$(shell uname)
HOSTNAME:=$(shell hostname)
ifeq "$(CFG)" ""
CFG=release
endif
SOURCE_DIR=..
BUILD_DIR=$(CFG)
MOD_SRC_DIR=$(SOURCE_DIR)/mod
ENGINE_SRC_DIR=$(SOURCE_DIR)/engine
COMMON_SRC_DIR=$(SOURCE_DIR)/common
PM_SRC_DIR=$(SOURCE_DIR)/pm_shared
GAME_SHARED_SRC_DIR=$(SOURCE_DIR)/game_shared
GAMEDB_SRC_DIR=$(COMMON_SRC_DIR)/gamedb
PUBLIC_SRC_DIR=$(SOURCE_DIR)/public
DBG_SRC_DIR=$(SOURCE_DIR)/dbg
BUILD_OBJ_DIR=$(BUILD_DIR)/obj
ARCH=i386
ELF-GC-DYNSTR=./elf-gc-dynstr
ifeq ($(OS),Linux)
CC="gcc -m32"
CPLUS="g++ -m32"
CPP_LIB:=-L$(shell g++ -m32 -print-file-name=libstdc++.so | xargs dirname) -lstdc++ -ldl -lpthread
endif
ifeq ($(OS),Darwin)
OSXVER := $(shell sw_vers -productVersion)
DEVELOPER_DIR := $(shell /usr/bin/xcode-select -print-path)
ifeq (,$(findstring 10.7, $(OSXVER)))
BUILDING_ON_LION := 0
COMPILER_BIN_DIR := $(DEVELOPER_DIR)/usr/bin
SDK_DIR := $(DEVELOPER_DIR)/SDKs
else
BUILDING_ON_LION := 1
COMPILER_BIN_DIR := $(DEVELOPER_DIR)/Toolchains/XcodeDefault.xctoolchain/usr/bin
SDK_DIR := $(DEVELOPER_DIR)/Platforms/MacOSX.platform/Developer/SDKs
endif
#SDKROOT ?= $(SDK_DIR)/MacOSX10.6.sdk
SDKROOT ?= $(SDK_DIR)/MacOSX10.8.sdk
ARCH_FLAGS ?= -arch i386 -m32 -march=prescott -gdwarf-2 -g2 -Wno-typedef-redefinition -momit-leaf-frame-pointer -mtune=core2
CPP_LIB=-lstdc++ -lpthread
ifeq ($(origin AR), default)
AR = libtool -static -o
endif
ifeq ($(origin CC), default)
CC ="$(COMPILER_BIN_DIR)/clang -Qunused-arguments -isysroot $(SDKROOT) -mmacosx-version-min=10.5 -fasm-blocks -I$(SDKROOT)/usr/include/malloc $(ARCH_FLAGS)"
endif
2018-04-25 06:15:48 +00:00
ifeq ($(origin CPLUS), default)
2014-12-16 13:36:27 +00:00
CPLUS ="$(COMPILER_BIN_DIR)/clang++ -Qunused-arguments -isysroot $(SDKROOT) -mmacosx-version-min=10.5 -fasm-blocks -I$(SDKROOT)/usr/include/malloc $(ARCH_FLAGS)"
endif
2018-04-25 06:15:48 +00:00
LINK ?= $(CPLUS)
2014-12-16 13:36:27 +00:00
endif
CLINK=$(CC)
ifeq "$(CFG)" "release"
ARCH_CFLAGS_I486=-O3 -gdwarf-2 -g2
ARCH_CFLAGS_I686=-O3 -gdwarf-2 -g2
ARCH_CFLAGS_AMD=-O3 -gdwarf-2 -g2
ARCH_CFLAGS_AMD64=-m64 -O3 -gdwarf-2 -g2
else
ARCH_CFLAGS_I486=-gdwarf-2 -g2
ARCH_CFLAGS_I686=-gdwarf-2 -g2
ARCH_CFLAGS_AMD=-gdwarf-2 -g2
ARCH_CFLAGS_AMD64=-m64 -gdwarf-2 -g2
endif
ifeq ($(OS),Linux)
ARCH_CFLAGS_I486+=-march=pentium-m -mfpmath=387
ARCH_CFLAGS_I686+=-march=pentium-m -mfpmath=387
ARCH_CFLAGS_AMD+=-march=k6 -mfpmath=387
endif
ifeq ($(OS),Darwin)
# force 387 for FP math so the precision between win32 and linux and osx match
2018-04-25 06:15:48 +00:00
ARCH_CFLAGS_I486+=-target i386-apple-darwin16.7.0 -DCMAKE_OSX_ARCHITECTURES=i386
ARCH_CFLAGS_I686+=-target i386-apple-darwin16.7.0 -DCMAKE_OSX_ARCHITECTURES=i386
2014-12-16 13:36:27 +00:00
ARCH_CFLAGS_AMD+=-mfpmath=387
endif
ARCH_CFLAGS="$(ARCH_CFLAGS_I486)"
BASE_CFLAGS=-fpermissive -fno-strict-aliasing -DNDEBUG -DPOSIX -D_POSIX -DLINUX -D_LINUX -DGNUC -DHL1 -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -DQUIVER -DQUAKE2 -DVALVE_DLL -D_alloca=alloca -fno-exceptions -fexpensive-optimizations -D_vsnprintf=vsnprintf -DNO_MALLOC_OVERRIDE -Werror=return-type
BASE_CFLAGS+=-w
ifeq ($(OS),Darwin)
2018-04-25 06:15:48 +00:00
BASE_CFLAGS += -DOSX -D_OSX -fvisibility=hidden -DCMAKE_OSX_ARCHITECTURES=i386
2014-12-16 13:36:27 +00:00
else
BASE_CFLAGS+= -DLINUX -D_LINUX
endif
DEDICATED_CFLAGS="-DDEDICATED -DSWDS"
ifeq ($(OS),Darwin)
SHLIBEXT=dylib
SHLIBCFLAGS=
2018-04-25 06:15:48 +00:00
SHLIBLDFLAGS="-shared -gdwarf-2 -g2 -DCMAKE_OSX_ARCHITECTURES=i386 -target i386-apple-darwin16.7.0"
2014-12-16 13:36:27 +00:00
else
SHLIBEXT=so
2014-12-16 13:36:27 +00:00
SHLIBCFLAGS=
SHLIBLDFLAGS="-shared -gdwarf-2 -g2 -Wl,-Map,$@_map.txt"
endif
AR=ar
LIBEXT=a
MAKE+= -j8
MAKE_HL_LIB=$(MAKE) -f Makefile.nsdll
MAKE_hl_cdll=$(MAKE) -f Makefile.hl_cdll
#############################################################################
# SETUP AND BUILD
#############################################################################
2014-12-16 13:36:27 +00:00
all: build_dir targets
2014-12-16 13:36:27 +00:00
TARGETS=
2014-12-16 13:36:27 +00:00
TARGETS+= \
ns \
hl_cdll \
2014-12-16 13:36:27 +00:00
build_dir:
-mkdir $(BUILD_DIR);
cd $(BUILD_DIR)
2014-12-16 13:36:27 +00:00
targets: $(TARGETS)
2014-12-16 13:36:27 +00:00
hl_cdll: build_dir
$(MAKE_hl_cdll) ARCH=i686 CC=$(CC) CPLUS=$(CPLUS) CPP_LIB="$(CPP_LIB)" BUILD_DIR=$(BUILD_DIR) BUILD_OBJ_DIR=$(BUILD_OBJ_DIR) SOURCE_DIR=$(SOURCE_DIR) ENGINE_SRC_DIR=$(ENGINE_SRC_DIR) MOD_SRC_DIR=$(MOD_SRC_DIR) COMMON_SRC_DIR=$(COMMON_SRC_DIR) BASE_CFLAGS="$(BASE_CFLAGS)" PUBLIC_SRC_DIR=$(PUBLIC_SRC_DIR) DBG_SRC_DIR=$(DBG_SRC_DIR) ARCH_CFLAGS="$(ARCH_CFLAGS_I686)" GAME_SHARED_SRC_DIR=$(GAME_SHARED_SRC_DIR) CLINK=$(CLINK) PM_SRC_DIR=$(PM_SRC_DIR) SHLIBEXT=$(SHLIBEXT) SHLIBCFLAGS=$(SHLIBCFLAGS) SHLIBLDFLAGS=$(SHLIBLDFLAGS) CFG=$(CFG) OS=$(OS)
2014-12-16 13:36:27 +00:00
ns: build_dir
$(MAKE_HL_LIB) CC=$(CC) ARCH=$(ARCH) CPP_LIB="$(CPP_LIB)" BUILD_DIR=$(BUILD_DIR) BUILD_OBJ_DIR=$(BUILD_OBJ_DIR) SOURCE_DIR=$(SOURCE_DIR) ENGINE_SRC_DIR=$(ENGINE_SRC_DIR) COMMON_SRC_DIR=$(COMMON_SRC_DIR) PM_SRC_DIR=$(PM_SRC_DIR) GAME_SHARED_SRC_DIR=$(GAME_SHARED_SRC_DIR) GAMEDB_SRC_DIR=$(GAMEDB_SRC_DIR) BASE_CFLAGS="$(BASE_CFLAGS)" SHLIBEXT=$(SHLIBEXT) SHLIBCFLAGS=$(SHLIBCFLAGS) SHLIBLDFLAGS=$(SHLIBLDFLAGS) PUBLIC_SRC_DIR=$(PUBLIC_SRC_DIR) CFG=$(CFG) OS=$(OS) ARCH_CFLAGS="$(ARCH_CFLAGS_I686)"
2014-12-16 13:36:27 +00:00
clean:
-rm -rf $(BUILD_OBJ_DIR)