1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 20:16:10 +08:00

Sync with upstream (Issue #30).

Recompiled tier1 and mathlib  for all platforms will come in next commit.
This commit is contained in:
Nicholas Hastings
2016-11-30 10:01:15 -05:00
parent 98fe5b5a34
commit 3957adff10
491 changed files with 29846 additions and 10698 deletions

View File

@ -1,5 +1,5 @@
#
# Base makefile for Linux and OSX
# Base makefile for Linux.
#
# !!!!! Note to future editors !!!!!
#
@ -26,6 +26,10 @@ ifneq (,$(findstring clang,$(CXX)))
CLANG_BUILD = 1
endif
ifeq ($(OS),Darwin)
$(error This file should never be used for Mac - use base.xconfig)
endif
ifeq ($(CFG), release)
# With gcc 4.6.3, engine.so went from 7,383,765 to 8,429,109 when building with -O3.
# There also was no speed difference running at 1280x1024. May 2012, mikesart.
@ -46,22 +50,106 @@ endif
# CPPFLAGS == "c/c++ *preprocessor* flags" - not "cee-plus-plus flags"
ARCH_FLAGS =
BUILDING_MULTI_ARCH = 0
# Preserve cflags set in environment
ENV_CFLAGS := $(CFLAGS)
ENV_CXXFLAGS := $(CXXFLAGS)
CPPFLAGS = $(DEFINES) $(addprefix -I, $(abspath $(INCLUDEDIRS) ))
CFLAGS = $(ARCH_FLAGS) $(CPPFLAGS) $(WARN_FLAGS) -fvisibility=$(SymbolVisibility) $(OptimizerLevel) -pipe $(GCC_ExtraCompilerFlags) -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE
BASE_CFLAGS = $(ARCH_FLAGS) $(CPPFLAGS) $(WARN_FLAGS) -fvisibility=$(SymbolVisibility) $(OptimizerLevel) -pipe $(GCC_ExtraCompilerFlags) -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE
CFLAGS = $(BASE_CFLAGS) $(ENV_CFLAGS)
# In -std=gnu++0x mode we get lots of errors about "error: narrowing conversion". -fpermissive
# turns these into warnings in gcc, and -Wno-c++11-narrowing suppresses them entirely in clang 3.1+.
ifeq ($(CLANG_BUILD),1)
CXXFLAGS = $(CFLAGS) -std=gnu++0x -Wno-c++11-narrowing -Wno-dangling-else
CXXFLAGS = $(BASE_CFLAGS) -std=gnu++0x -Wno-c++11-narrowing -Wno-dangling-else $(ENV_CXXFLAGS)
else
CXXFLAGS = $(CFLAGS) -std=gnu++0x -fpermissive
CXXFLAGS = $(BASE_CFLAGS) -std=gnu++0x -fpermissive $(ENV_CXXFLAGS)
endif
DEFINES += -DVPROF_LEVEL=1 -DGNUC -DNO_HOOK_MALLOC -DNO_MALLOC_OVERRIDE
## TODO: This cases build errors in cstrike/bin right now. Need to debug.
# This causes all filesystem interfaces to default to their 64bit versions on
# 32bit systems, which means we don't break on filesystems with inodes > 32bit.
# DEFINES += -D_FILE_OFFSET_BITS=64
LDFLAGS = $(CFLAGS) $(GCC_ExtraLinkerFlags) $(OptimizerLevel)
GENDEP_CXXFLAGS = -MMD -MP -MF $(@:.o=.P)
MAP_FLAGS =
Srv_GAMEOUTPUTFILE =
COPY_DLL_TO_SRV = 0
# We should always specify -Wl,--build-id, as documented at:
# http://linux.die.net/man/1/ld and http://fedoraproject.org/wiki/Releases/FeatureBuildId.http://fedoraproject.org/wiki/Releases/FeatureBuildId
LDFLAGS += -Wl,--build-id
#
# If we should be running in a chroot, check to see if we are. If not, then prefix everything with the
# required chroot
#
ifdef MAKE_CHROOT
export STEAM_RUNTIME_PATH := /usr
ifneq ("$(SCHROOT_CHROOT_NAME)", "$(CHROOT_NAME)")
$(info '$(SCHROOT_CHROOT_NAME)' is not '$(CHROOT_NAME)')
$(error This makefile should be run from within a chroot. 'schroot --chroot $(CHROOT_NAME) -- $(MAKE) $(MAKEFLAGS)')
endif
GCC_VER = -4.8
P4BIN = $(SRCROOT)/devtools/bin/linux/p4
CRYPTOPPDIR=ubuntu12_32_gcc48
else ifeq ($(USE_VALVE_BINDIR),1)
# Using /valve/bin directory.
export STEAM_RUNTIME_PATH ?= /valve
GCC_VER = -4.6
P4BIN = p4
CRYPTOPPDIR=linux32
else
# Not using chroot, use old steam-runtime. (gcc 4.6.3)
export STEAM_RUNTIME_PATH ?= /valve/steam-runtime
GCC_VER =
P4BIN = p4
CRYPTOPPDIR=ubuntu12_32
endif
ifeq ($(TARGET_PLATFORM),linux64)
MARCH_TARGET = core2
else
MARCH_TARGET = pentium4
endif
ifeq ($(USE_VALVE_BINDIR),1)
# On dedicated servers, some plugins depend on global variable symbols in addition to functions.
# So symbols like _Z16ClearMultiDamagev should show up when you do "nm server_srv.so" in TF2.
STRIP_FLAGS =
else
# Linux desktop client (or client/dedicated server in chroot).
STRIP_FLAGS = -x
endif
ifeq ($(CLANG_BUILD),1)
# Clang does not support -mfpmath=sse because it uses whatever
# instruction set extensions are available by default.
SSE_GEN_FLAGS = -msse2
else
SSE_GEN_FLAGS = -msse2 -mfpmath=sse
endif
CCACHE := $(SRCROOT)/devtools/bin/linux/ccache
ifeq ($(origin AR), default)
AR = $(STEAM_RUNTIME_PATH)/bin/ar crs
endif
ifeq ($(origin CC), default)
CC = $(CCACHE) $(STEAM_RUNTIME_PATH)/bin/gcc$(GCC_VER)
endif
ifeq ($(origin CXX), default)
CXX = $(CCACHE) $(STEAM_RUNTIME_PATH)/bin/g++$(GCC_VER)
endif
# Support ccache with clang. Add -Qunused-arguments to avoid excessive warnings due to
# a ccache quirk. Could also upgrade ccache.
# http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
ifeq ($(CLANG_BUILD),1)
CC := $(CCACHE) $(CC) -Qunused-arguments -fcolor-diagnostics
CXX := $(CCACHE) $(CXX) -Qunused-arguments -fcolor-diagnostics
endif
LINK ?= $(CC)
ifeq ($(STEAM_BRANCH),1)
WARN_FLAGS = -Wall -Wextra -Wshadow -Wno-invalid-offsetof
@ -71,141 +159,67 @@ else
WARN_FLAGS += -Wno-unused-variable
WARN_FLAGS += -Wno-unused-but-set-variable
WARN_FLAGS += -Wno-unused-function
endif
ifeq ($(CLANG_BUILD),1)
# Clang specific flags
else
# Gcc specific flags. Need this for gcc 4.8.
# WARN_FLAGS += -Wno-unused-local-typedefs
# WARN_FLAGS += -Wno-unused-function
# WARN_FLAGS += -Wno-unused-result
# WARN_FLAGS += -Wno-narrowing
endif
ifeq ($(CLANG_BUILD),1)
# Clang specific flags
else ifeq ($(GCC_VER),-4.8)
WARN_FLAGS += -Wno-unused-local-typedefs
WARN_FLAGS += -Wno-unused-result
WARN_FLAGS += -Wno-narrowing
# WARN_FLAGS += -Wno-unused-function
endif
WARN_FLAGS += -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers
WARN_FLAGS += -Wno-sign-compare -Wno-reorder -Wno-invalid-offsetof -Wno-float-equal -Werror=return-type
WARN_FLAGS += -fdiagnostics-show-option -Wformat -Wformat-security
ifeq ($(OS),Darwin)
$(error This file should never be used for Mac - use base.xconfig)
ifeq ($(TARGET_PLATFORM),linux64)
# nocona = pentium4 + 64bit + MMX, SSE, SSE2, SSE3 - no SSSE3 (that's three s's - added in core2)
ARCH_FLAGS += -march=$(MARCH_TARGET) -mtune=core2
LD_SO = ld-linux-x86_64.so.2
LIBSTDCXX := $(shell $(CXX) -print-file-name=libstdc++.a)
LIBSTDCXXPIC := $(shell $(CXX) -print-file-name=libstdc++-pic.a)
else
# pentium4 = MMX, SSE, SSE2 - no SSE3 (added in prescott) # -msse3 -mfpmath=sse
ARCH_FLAGS += -m32 -march=$(MARCH_TARGET) -mtune=core2 $(SSE_GEN_FLAGS)
LD_SO = ld-linux.so.2
LIBSTDCXX := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
LIBSTDCXXPIC := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
LDFLAGS += -m32
endif
ifeq ($(OS),Linux)
# We should always specify -Wl,--build-id, as documented at:
# http://linux.die.net/man/1/ld and http://fedoraproject.org/wiki/Releases/FeatureBuildId.http://fedoraproject.org/wiki/Releases/FeatureBuildId
LDFLAGS += -Wl,--build-id
# Set USE_VALVE_BINDIR to build with /Steam/tools/linux in the /valve/bin path.
# Dedicated server uses this.
ifeq ($(USE_VALVE_BINDIR),1)
# dedicated server flags
ifeq ($(TARGET_PLATFORM),linux64)
VALVE_BINDIR = /valve/bin64/
MARCH_TARGET = nocona
else
VALVE_BINDIR = /valve/bin/
MARCH_TARGET = pentium4
endif
STRIP_FLAGS =
else
# linux desktop client flags
VALVE_BINDIR =
# If the steam-runtime is available, use it. We should just default to using it when
# buildbot and everyone has a bit of time to get it installed.
ifneq "$(wildcard /valve/steam-runtime/bin/)" ""
VALVE_BINDIR = /valve/steam-runtime/bin/
endif
GCC_VER =
MARCH_TARGET = pentium4
# On dedicated servers, some plugins depend on global variable symbols in addition to functions.
# So symbols like _Z16ClearMultiDamagev should show up when you do "nm server_srv.so" in TF2.
STRIP_FLAGS = -x
endif
ifeq ($(CLANG_BUILD),1)
# The steam-runtime is incompatible with clang at this point, so disable it
VALVE_BINDIR =
# Clang does not support -mfpmath=sse because it uses whatever
# instruction set extensions are available by default.
SSE_GEN_FLAGS = -msse2
else
SSE_GEN_FLAGS = -msse2 -mfpmath=sse
endif
CCACHE := $(SRCROOT)/devtools/bin/linux/ccache
ifeq ($(origin GCC_VER), undefined)
GCC_VER=-4.6
endif
ifeq ($(origin AR), default)
AR = $(VALVE_BINDIR)ar crs
endif
ifeq ($(origin CC), default)
CC = $(CCACHE) $(VALVE_BINDIR)gcc$(GCC_VER)
endif
ifeq ($(origin CXX), default)
CXX = $(CCACHE) $(VALVE_BINDIR)g++$(GCC_VER)
endif
# Support ccache with clang. Add -Qunused-arguments to avoid excessive warnings due to
# a ccache quirk. Could also upgrade ccache.
# http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
ifeq ($(CLANG_BUILD),1)
CC = $(CCACHE) $(VALVE_BINDIR)clang -Qunused-arguments
CXX = $(CCACHE) $(VALVE_BINDIR)clang++ -Qunused-arguments
endif
LINK ?= $(CC)
ifeq ($(TARGET_PLATFORM),linux64)
# nocona = pentium4 + 64bit + MMX, SSE, SSE2, SSE3 - no SSSE3 (that's three s's - added in core2)
ARCH_FLAGS += -march=$(MARCH_TARGET) -mtune=core2
LD_SO = ld-linux-x86_64.so.2
LIBSTDCXX := $(shell $(CXX) -print-file-name=libstdc++.a)
LIBSTDCXXPIC := $(shell $(CXX) -print-file-name=libstdc++-pic.a)
else
# pentium4 = MMX, SSE, SSE2 - no SSE3 (added in prescott) # -msse3 -mfpmath=sse
ARCH_FLAGS += -m32 -march=$(MARCH_TARGET) -mtune=core2 $(SSE_GEN_FLAGS)
LD_SO = ld-linux.so.2
LIBSTDCXX := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
LIBSTDCXXPIC := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
LDFLAGS += -m32
endif
GEN_SYM ?= $(SRCROOT)/devtools/gendbg.sh
ifeq ($(CFG),release)
STRIP ?= strip $(STRIP_FLAGS) -S
# CFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += -Wl,--gc-sections -Wl,--print-gc-sections
else
STRIP ?= true
endif
VSIGN ?= true
ifeq ($(SOURCE_SDK), 1)
Srv_GAMEOUTPUTFILE := $(GAMEOUTPUTFILE:.so=_srv.so)
COPY_DLL_TO_SRV := 1
endif
LINK_MAP_FLAGS = -Wl,-Map,$(@:.so=).map
SHLIBLDFLAGS = -shared $(LDFLAGS) -Wl,--no-undefined
_WRAP := -Xlinker --wrap=
PATHWRAP = $(_WRAP)fopen $(_WRAP)freopen $(_WRAP)open $(_WRAP)creat $(_WRAP)access $(_WRAP)__xstat \
$(_WRAP)stat $(_WRAP)lstat $(_WRAP)fopen64 $(_WRAP)open64 $(_WRAP)opendir $(_WRAP)__lxstat \
$(_WRAP)chmod $(_WRAP)chown $(_WRAP)lchown $(_WRAP)symlink $(_WRAP)link $(_WRAP)__lxstat64 \
$(_WRAP)mknod $(_WRAP)utimes $(_WRAP)unlink $(_WRAP)rename $(_WRAP)utime $(_WRAP)__xstat64 \
$(_WRAP)mount $(_WRAP)mkfifo $(_WRAP)mkdir $(_WRAP)rmdir $(_WRAP)scandir $(_WRAP)realpath
LIB_START_EXE = $(PATHWRAP) -static-libgcc -Wl,--start-group
LIB_END_EXE = -Wl,--end-group -lm -ldl $(LIBSTDCXX) -lpthread
LIB_START_SHLIB = $(PATHWRAP) -static-libgcc -Wl,--start-group
LIB_END_SHLIB = -Wl,--end-group -lm -ldl $(LIBSTDCXXPIC) -lpthread -l:$(LD_SO) -Wl,--version-script=$(SRCROOT)/devtools/version_script.linux.txt
GEN_SYM ?= $(SRCROOT)/devtools/gendbg.sh
ifeq ($(CFG),release)
STRIP ?= strip $(STRIP_FLAGS) -S
# CFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += -Wl,--gc-sections -Wl,--print-gc-sections
else
STRIP ?= true
endif
VSIGN ?= true
ifeq ($(SOURCE_SDK), 1)
Srv_GAMEOUTPUTFILE := $(GAMEOUTPUTFILE:.so=_srv.so)
COPY_DLL_TO_SRV := 1
endif
LINK_MAP_FLAGS = -Wl,-Map,$(@:.so=).map
SHLIBLDFLAGS = -shared $(LDFLAGS) -Wl,--no-undefined
_WRAP := -Xlinker --wrap=
PATHWRAP = $(_WRAP)fopen $(_WRAP)freopen $(_WRAP)open $(_WRAP)creat $(_WRAP)access $(_WRAP)__xstat \
$(_WRAP)stat $(_WRAP)lstat $(_WRAP)fopen64 $(_WRAP)open64 $(_WRAP)opendir $(_WRAP)__lxstat \
$(_WRAP)chmod $(_WRAP)chown $(_WRAP)lchown $(_WRAP)symlink $(_WRAP)link $(_WRAP)__lxstat64 \
$(_WRAP)mknod $(_WRAP)utimes $(_WRAP)unlink $(_WRAP)rename $(_WRAP)utime $(_WRAP)__xstat64 \
$(_WRAP)mount $(_WRAP)mkfifo $(_WRAP)mkdir $(_WRAP)rmdir $(_WRAP)scandir $(_WRAP)realpath
LIB_START_EXE = $(PATHWRAP) -static-libgcc -Wl,--start-group
LIB_END_EXE = -Wl,--end-group -lm -ldl $(LIBSTDCXX) -lpthread
LIB_START_SHLIB = $(PATHWRAP) -static-libgcc -Wl,--start-group
LIB_END_SHLIB = -Wl,--end-group -lm -ldl $(LIBSTDCXXPIC) -lpthread -l:$(LD_SO) -Wl,--version-script=$(SRCROOT)/devtools/version_script.linux.txt
#
# Profile-directed optimizations.
@ -289,7 +303,7 @@ else
# setting is best, but here is an alternate example:
# export P4_EDIT_CHANGELIST_CMD="echo 1424335"
# ?= means that if P4_EDIT_CHANGELIST_CMD is already set it won't be changed.
P4_EDIT_CHANGELIST_CMD ?= p4 changes -c `p4 client -o | grep ^Client | cut -f 2` -s pending | fgrep 'POSIX Auto Checkout' | cut -d' ' -f 2 | tail -n 1
P4_EDIT_CHANGELIST_CMD ?= $(P4BIN) changes -c `$(P4BIN) client -o | grep ^Client | cut -f 2` -s pending | fgrep 'POSIX Auto Checkout' | cut -d' ' -f 2 | tail -n 1
P4_EDIT_CHANGELIST := $(shell $(P4_EDIT_CHANGELIST_CMD))
endif
ifeq ($(P4_EDIT_CHANGELIST),)
@ -298,13 +312,13 @@ else
# Warning: the behavior of 'echo' is not consistent. In bash you need the "-e" option in order for \n to be
# interpreted as a line-feed, but in dash you do not, and if "-e" is passed along then it is printed, which
# confuses p4. So, if you run this command from the bash shell don't forget to add "-e" to the echo command.
P4_EDIT_CHANGELIST = $(shell echo "Change: new\nDescription: POSIX Auto Checkout" | p4 change -i | cut -f 2 -d ' ')
P4_EDIT_CHANGELIST = $(shell echo -e "Change: new\nDescription: POSIX Auto Checkout" | $(P4BIN) change -i | cut -f 2 -d ' ')
endif
P4_EDIT_START := for f in
P4_EDIT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | p4 -x - edit -c $(P4_EDIT_CHANGELIST); else p4 edit -c $(P4_EDIT_CHANGELIST) $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
P4_EDIT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | $(P4BIN) -x - edit -c $(P4_EDIT_CHANGELIST); else $(P4BIN) edit -c $(P4_EDIT_CHANGELIST) $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
P4_REVERT_START := for f in
P4_REVERT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | p4 -x - revert; else p4 revert $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
P4_REVERT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | $(P4BIN) -x - revert; else $(P4BIN) revert $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
endif
ifeq ($(CONFTYPE),dll)
@ -345,7 +359,7 @@ ifneq "$(OBJ_DIR)" ""
endif
ifneq "$(OUTPUTFILE)" ""
$(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \
echo "p4 revert $(OUTPUTFILE)"; \
echo "$(P4BIN) revert $(OUTPUTFILE)"; \
$(P4_REVERT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END); \
fi;
endif
@ -354,7 +368,7 @@ ifneq "$(OTHER_DEPENDENCIES)" ""
$(QUIET_PREFIX) rm -f $(OTHER_DEPENDENCIES)
endif
ifneq "$(GAMEOUTPUTFILE)" ""
$(QUIET_PREFIX) echo "p4 revert $(GAMEOUTPUTFILE)"
$(QUIET_PREFIX) echo "$(P4BIN) revert $(GAMEOUTPUTFILE)"
$(QUIET_PREFIX) $(P4_REVERT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END)
endif
@ -370,7 +384,7 @@ ifneq "$(OBJ_DIR)" ""
endif
ifneq "$(OUTPUTFILE)" ""
$(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \
echo "p4 edit and rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT)"; \
echo "$(P4BIN) edit and rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT)"; \
$(P4_EDIT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END); \
fi;
$(QUIET_PREFIX) -rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT);
@ -380,7 +394,7 @@ ifneq "$(OTHER_DEPENDENCIES)" ""
$(QUIET_PREFIX) -rm -f $(OTHER_DEPENDENCIES)
endif
ifneq "$(GAMEOUTPUTFILE)" ""
$(QUIET_PREFIX) echo "p4 edit and rm -f $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT)"
$(QUIET_PREFIX) echo "$(P4BIN) edit and rm -f $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT)"
$(QUIET_PREFIX) $(P4_EDIT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END)
$(QUIET_PREFIX) -rm -f $(GAMEOUTPUTFILE)
endif