From adcd18d0bf3b480e2d09624c4f6e2eea12ad3b03 Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Sat, 15 Apr 2017 11:46:32 +0200 Subject: update the Makefile to the latest revision URL: https://github.com/darklegion/tremulous revision: f45fbef604e05144057dec8d1dbfc5d4f5a2a822 --- Makefile | 2474 ++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 1943 insertions(+), 531 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 17e66fc..9ab4227 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,40 @@ # # Tremulous Makefile # -# Nov '98 by Zoid -# -# Loki Hacking by Bernd Kreimeier -# and a little more by Ryan C. Gordon. -# and a little more by Rafael Barrero -# and a little more by the ioq3 cr3w -# and a little more by Tim Angus -# # GNU Make required # -COMPILE_PLATFORM=$(shell uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]') +COMPILE_PLATFORM=$(shell uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]'|sed -e 's/\//_/g') +COMPILE_ARCH=$(shell uname -m | sed -e s/i.86/x86/ | sed -e 's/^arm.*/arm/') + +ifeq ($(COMPILE_PLATFORM),sunos) + # Solaris uname and GNU uname differ + COMPILE_ARCH=$(shell uname -p | sed -e s/i.86/x86/) +endif ifeq ($(COMPILE_PLATFORM),darwin) # Apple does some things a little differently... COMPILE_ARCH=$(shell uname -p | sed -e s/i.86/x86/) -else - COMPILE_ARCH=$(shell uname -m | sed -e s/i.86/x86/) endif -BUILD_GAME_SO = 0 -BUILD_GAME_QVM = 1 +ifndef BUILD_STANDALONE + BUILD_STANDALONE = +endif +ifndef BUILD_CLIENT + BUILD_CLIENT = +endif +ifndef BUILD_SERVER + BUILD_SERVER = +endif +ifndef BUILD_GAME_SO + BUILD_GAME_SO = +endif +ifndef BUILD_GAME_QVM + BUILD_GAME_QVM = +endif +ifndef BUILD_RENDERER_OPENGL2 + BUILD_RENDERER_OPENGL2= +endif ############################################################################# # @@ -34,17 +46,46 @@ BUILD_GAME_QVM = 1 ############################################################################# -include Makefile.local +ifeq ($(COMPILE_PLATFORM),cygwin) + PLATFORM=mingw32 +endif + ifndef PLATFORM PLATFORM=$(COMPILE_PLATFORM) endif export PLATFORM -ifndef ARCH -ARCH=$(COMPILE_ARCH) +ifeq ($(PLATFORM),mingw32) + MINGW=1 +endif +ifeq ($(PLATFORM),mingw64) + MINGW=1 +endif + +ifeq ($(COMPILE_ARCH),i86pc) + COMPILE_ARCH=x86 +endif + +ifeq ($(COMPILE_ARCH),amd64) + COMPILE_ARCH=x86_64 +endif +ifeq ($(COMPILE_ARCH),x64) + COMPILE_ARCH=x86_64 +endif + +ifeq ($(COMPILE_ARCH),powerpc) + COMPILE_ARCH=ppc +endif +ifeq ($(COMPILE_ARCH),powerpc64) + COMPILE_ARCH=ppc64 +endif + +ifeq ($(COMPILE_ARCH),axp) + COMPILE_ARCH=alpha endif -ifeq ($(ARCH),powerpc) - ARCH=ppc +ifndef ARCH +ARCH=$(COMPILE_ARCH) endif export ARCH @@ -59,10 +100,34 @@ else endif export CROSS_COMPILING +ifndef VERSION +VERSION=gpp1 +endif + +ifndef CLIENTBIN +CLIENTBIN=tremulous +endif + +ifndef SERVERBIN +SERVERBIN=tremded +endif + +ifndef BASEGAME +BASEGAME=gpp +endif + +ifndef BASEGAME_CFLAGS +BASEGAME_CFLAGS= +endif + ifndef COPYDIR COPYDIR="/usr/local/games/tremulous" endif +ifndef COPYBINDIR +COPYBINDIR=$(COPYDIR) +endif + ifndef MOUNT_DIR MOUNT_DIR=src endif @@ -71,17 +136,12 @@ ifndef BUILD_DIR BUILD_DIR=build endif -ifndef GENERATE_DEPENDENCIES -GENERATE_DEPENDENCIES=1 -endif - -ifndef USE_CCACHE -USE_CCACHE=0 +ifndef TEMPDIR +TEMPDIR=/tmp endif -export USE_CCACHE -ifndef USE_SDL -USE_SDL=1 +ifndef GENERATE_DEPENDENCIES +GENERATE_DEPENDENCIES=1 endif ifndef USE_OPENAL @@ -89,7 +149,7 @@ USE_OPENAL=1 endif ifndef USE_OPENAL_DLOPEN -USE_OPENAL_DLOPEN=0 +USE_OPENAL_DLOPEN=1 endif ifndef USE_CURL @@ -97,7 +157,7 @@ USE_CURL=1 endif ifndef USE_CURL_DLOPEN - ifeq ($(PLATFORM),mingw32) + ifdef MINGW USE_CURL_DLOPEN=0 else USE_CURL_DLOPEN=1 @@ -108,48 +168,130 @@ ifndef USE_CODEC_VORBIS USE_CODEC_VORBIS=0 endif +ifndef USE_CODEC_OPUS +USE_CODEC_OPUS=1 +endif + +ifndef USE_MUMBLE +USE_MUMBLE=1 +endif + +ifndef USE_VOIP +USE_VOIP=1 +endif + +ifndef USE_FREETYPE +USE_FREETYPE=0 +endif + +ifndef USE_INTERNAL_LIBS +USE_INTERNAL_LIBS=1 +endif + +ifndef USE_INTERNAL_OGG +USE_INTERNAL_OGG=$(USE_INTERNAL_LIBS) +endif + +ifndef USE_INTERNAL_VORBIS +USE_INTERNAL_VORBIS=$(USE_INTERNAL_LIBS) +endif + +ifndef USE_INTERNAL_OPUS +USE_INTERNAL_OPUS=$(USE_INTERNAL_LIBS) +endif + +ifndef USE_INTERNAL_ZLIB +USE_INTERNAL_ZLIB=$(USE_INTERNAL_LIBS) +endif + +ifndef USE_INTERNAL_JPEG +USE_INTERNAL_JPEG=$(USE_INTERNAL_LIBS) +endif + ifndef USE_LOCAL_HEADERS -USE_LOCAL_HEADERS=1 +USE_LOCAL_HEADERS=$(USE_INTERNAL_LIBS) endif ifndef BUILD_MASTER_SERVER BUILD_MASTER_SERVER=0 endif +ifndef USE_RENDERER_DLOPEN +USE_RENDERER_DLOPEN=1 +endif + +ifndef DEBUG_CFLAGS +DEBUG_CFLAGS=-g -O0 +endif + ############################################################################# BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH) BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH) CDIR=$(MOUNT_DIR)/client SDIR=$(MOUNT_DIR)/server -RDIR=$(MOUNT_DIR)/renderer +RCOMMONDIR=$(MOUNT_DIR)/renderercommon +RGL1DIR=$(MOUNT_DIR)/renderergl1 +RGL2DIR=$(MOUNT_DIR)/renderergl2 CMDIR=$(MOUNT_DIR)/qcommon -UDIR=$(MOUNT_DIR)/unix -W32DIR=$(MOUNT_DIR)/win32 +SDLDIR=$(MOUNT_DIR)/sdl +ASMDIR=$(MOUNT_DIR)/asm +SYSDIR=$(MOUNT_DIR)/sys GDIR=$(MOUNT_DIR)/game CGDIR=$(MOUNT_DIR)/cgame NDIR=$(MOUNT_DIR)/null UIDIR=$(MOUNT_DIR)/ui -JPDIR=$(MOUNT_DIR)/jpeg-6 -TOOLSDIR=$(MOUNT_DIR)/tools -SDLHDIR=$(MOUNT_DIR)/SDL12 +JPDIR=$(MOUNT_DIR)/jpeg-8c +OGGDIR=$(MOUNT_DIR)/libogg-1.3.1 +VORBISDIR=$(MOUNT_DIR)/libvorbis-1.3.4 +OPUSDIR=$(MOUNT_DIR)/opus-1.1 +OPUSFILEDIR=$(MOUNT_DIR)/opusfile-0.5 +ZDIR=$(MOUNT_DIR)/zlib +Q3ASMDIR=$(MOUNT_DIR)/tools/asm +LBURGDIR=$(MOUNT_DIR)/tools/lcc/lburg +Q3CPPDIR=$(MOUNT_DIR)/tools/lcc/cpp +Q3LCCETCDIR=$(MOUNT_DIR)/tools/lcc/etc +Q3LCCSRCDIR=$(MOUNT_DIR)/tools/lcc/src +SDLHDIR=$(MOUNT_DIR)/SDL2 LIBSDIR=$(MOUNT_DIR)/libs MASTERDIR=$(MOUNT_DIR)/master - -# extract version info -VERSION=$(shell grep "\#define VERSION_NUMBER" $(CMDIR)/q_shared.h | \ - sed -e 's/[^"]*"\(.*\)"/\1/') - -USE_SVN= -ifeq ($(wildcard .svn),.svn) - SVN_REV=$(shell LANG=C svnversion .) - ifneq ($(SVN_REV),) - SVN_VERSION=$(VERSION)_SVN$(SVN_REV) - USE_SVN=1 +TEMPDIR=/tmp + +bin_path=$(shell which $(1) 2> /dev/null) + +# We won't need this if we only build the server +ifneq ($(BUILD_CLIENT),0) + # set PKG_CONFIG_PATH to influence this, e.g. + # PKG_CONFIG_PATH=/opt/cross/i386-mingw32msvc/lib/pkgconfig + ifneq ($(call bin_path, pkg-config),) + CURL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags libcurl) + CURL_LIBS ?= $(shell pkg-config --silence-errors --libs libcurl) + OPENAL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags openal) + OPENAL_LIBS ?= $(shell pkg-config --silence-errors --libs openal) + SDL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//') + SDL_LIBS ?= $(shell pkg-config --silence-errors --libs sdl2) + else + # assume they're in the system default paths (no -I or -L needed) + CURL_LIBS ?= -lcurl + OPENAL_LIBS ?= -lopenal + endif + # Use sdl2-config if all else fails + ifeq ($(SDL_CFLAGS),) + ifneq ($(call bin_path, sdl2-config),) + SDL_CFLAGS ?= $(shell sdl2-config --cflags) + SDL_LIBS ?= $(shell sdl2-config --libs) + endif endif endif -ifneq ($(USE_SVN),1) - SVN_VERSION=$(VERSION) + +# Add git version info +USE_GIT= +ifeq ($(wildcard .git),.git) + GIT_REV=$(shell git show -s --pretty=format:%h-%ad --date=short) + ifneq ($(GIT_REV),) + VERSION:=$(VERSION)_GIT_$(GIT_REV) + USE_GIT=1 + endif endif @@ -157,121 +299,89 @@ endif # SETUP AND BUILD -- LINUX ############################################################################# -## Defaults -LIB=lib - INSTALL=install MKDIR=mkdir +EXTRA_FILES= +CLIENT_EXTRA_FILES= -ifeq ($(PLATFORM),linux) - - ifeq ($(ARCH),alpha) - ARCH=axp - else - ifeq ($(ARCH),x86_64) - LIB=lib64 - else - ifeq ($(ARCH),ppc64) - LIB=lib64 - else - ifeq ($(ARCH),s390x) - LIB=lib64 - endif - endif - endif - endif - - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes -pipe - - ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL=1 - ifeq ($(USE_OPENAL_DLOPEN),1) - BASE_CFLAGS += -DUSE_OPENAL_DLOPEN=1 - endif - endif - - ifeq ($(USE_CURL),1) - BASE_CFLAGS += -DUSE_CURL=1 - ifeq ($(USE_CURL_DLOPEN),1) - BASE_CFLAGS += -DUSE_CURL_DLOPEN=1 - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - BASE_CFLAGS += -DUSE_CODEC_VORBIS=1 - endif +ifneq (,$(findstring "$(COMPILE_PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu")) + TOOLS_CFLAGS += -DARCH_STRING=\"$(COMPILE_ARCH)\" +endif - ifeq ($(USE_SDL),1) - BASE_CFLAGS += -DUSE_SDL_VIDEO=1 -DUSE_SDL_SOUND=1 $(shell sdl-config --cflags) - else - BASE_CFLAGS += -I/usr/X11R6/include - endif +ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu")) + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -pipe -DUSE_ICON -DARCH_STRING=\\\"$(ARCH)\\\" + CLIENT_CFLAGS += $(SDL_CFLAGS) - OPTIMIZE = -O3 -funroll-loops -fomit-frame-pointer + OPTIMIZEVM = -O3 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math ifeq ($(ARCH),x86_64) - OPTIMIZE = -O3 -fomit-frame-pointer -funroll-loops \ - -falign-loops=2 -falign-jumps=2 -falign-functions=2 \ - -fstrength-reduce - # experimental x86_64 jit compiler! you need GNU as + OPTIMIZEVM = -O3 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math HAVE_VM_COMPILED = true else ifeq ($(ARCH),x86) - OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer \ - -funroll-loops -falign-loops=2 -falign-jumps=2 \ - -falign-functions=2 -fstrength-reduce + OPTIMIZEVM = -O3 -march=i586 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math HAVE_VM_COMPILED=true else ifeq ($(ARCH),ppc) BASE_CFLAGS += -maltivec - HAVE_VM_COMPILED=false + HAVE_VM_COMPILED=true + endif + ifeq ($(ARCH),ppc64) + BASE_CFLAGS += -maltivec + HAVE_VM_COMPILED=true endif + ifeq ($(ARCH),sparc) + OPTIMIZE += -mtune=ultrasparc3 -mv8plus + OPTIMIZEVM += -mtune=ultrasparc3 -mv8plus + HAVE_VM_COMPILED=true + endif + ifeq ($(ARCH),alpha) + # According to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=410555 + # -ffast-math will cause the client to die with SIGFPE on Alpha + OPTIMIZE = $(OPTIMIZEVM) endif endif - - ifneq ($(HAVE_VM_COMPILED),true) - BASE_CFLAGS += -DNO_VM_COMPILED endif - - DEBUG_CFLAGS = $(BASE_CFLAGS) -g -O0 - - RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) SHLIBEXT=so - SHLIBCFLAGS=-fPIC + SHLIBCFLAGS=-fPIC -fvisibility=hidden SHLIBLDFLAGS=-shared $(LDFLAGS) - THREAD_LDFLAGS=-lpthread - LDFLAGS=-ldl -lm + THREAD_LIBS=-lpthread + LIBS=-ldl -lm - ifeq ($(USE_SDL),1) - CLIENT_LDFLAGS=$(shell sdl-config --libs) - else - CLIENT_LDFLAGS=-L/usr/X11R6/$(LIB) -lX11 -lXext -lXxf86dga -lXxf86vm - endif + CLIENT_LIBS=$(SDL_LIBS) + RENDERER_LIBS = $(SDL_LIBS) -lGL ifeq ($(USE_OPENAL),1) ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LDFLAGS += -lopenal + CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) endif endif - + ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += $(CURL_CFLAGS) ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LDFLAGS += -lcurl + CLIENT_LIBS += $(CURL_LIBS) endif endif - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg + ifeq ($(USE_MUMBLE),1) + CLIENT_LIBS += -lrt endif ifeq ($(ARCH),x86) # linux32 make ... BASE_CFLAGS += -m32 - LDFLAGS+=-m32 + else + ifeq ($(ARCH),ppc64) + BASE_CFLAGS += -m64 + endif endif - else # ifeq Linux ############################################################################# @@ -280,123 +390,89 @@ else # ifeq Linux ifeq ($(PLATFORM),darwin) HAVE_VM_COMPILED=true - BASE_CFLAGS= - CLIENT_LDFLAGS= - LDFLAGS= - OPTIMIZE= - ifeq ($(BUILD_MACOSX_UB),ppc) - CC=gcc-3.3 - BASE_CFLAGS += -arch ppc -DSMP \ - -DMAC_OS_X_VERSION_MIN_REQUIRED=1020 -nostdinc \ - -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \ - -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \ - -isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include - # when using the 10.2 SDK we are not allowed the two-level namespace so - # in order to get the OpenAL dlopen() stuff to work without major - # modifications, the controversial -m linker flag must be used. this - # throws a ton of multiply defined errors which cannot be suppressed. - LDFLAGS += -arch ppc \ - -L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \ - -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \ - -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk,-m - ARCH=ppc - - # OS X 10.2 sdk lacks dlopen() so ded would need libSDL anyway - BUILD_SERVER=0 - - # because of a problem with linking on 10.2 this will generate multiply - # defined symbol errors. The errors can be turned into warnings with - # the -m linker flag, but you can't shut up the warnings - USE_OPENAL_DLOPEN=1 - else - ifeq ($(BUILD_MACOSX_UB),x86) - CC=gcc-4.0 - BASE_CFLAGS += -arch i386 -DSMP \ - -mmacosx-version-min=10.4 \ - -DMAC_OS_X_VERSION_MIN_REQUIRED=1040 -nostdinc \ - -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \ - -I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \ - -isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include - LDFLAGS = -arch i386 -mmacosx-version-min=10.4 \ - -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1 \ - -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \ - -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk - ARCH=x86 - BUILD_SERVER=0 - else - # for whatever reason using the headers in the MacOSX SDKs tend to throw - # errors even though they are identical to the system ones which don't - # therefore we shut up warning flags when running the universal build - # script as much as possible. - BASE_CFLAGS += -Wall -Wimplicit -Wstrict-prototypes - endif - endif + LIBS = -framework Cocoa + CLIENT_LIBS= + RENDERER_LIBS= + OPTIMIZEVM= + + BASE_CFLAGS = -Wall -Wimplicit -Wstrict-prototypes -mmacosx-version-min=10.5 \ + -DMAC_OS_X_VERSION_MIN_REQUIRED=1050 ifeq ($(ARCH),ppc) - OPTIMIZE += -faltivec -O3 + BASE_CFLAGS += -arch ppc -faltivec + OPTIMIZEVM += -O3 + endif + ifeq ($(ARCH),ppc64) + BASE_CFLAGS += -arch ppc64 -faltivec endif ifeq ($(ARCH),x86) - OPTIMIZE += -march=prescott -mfpmath=sse + OPTIMIZEVM += -march=prescott -mfpmath=sse # x86 vm will crash without -mstackrealign since MMX instructions will be # used no matter what and they corrupt the frame pointer in VM calls - BASE_CFLAGS += -mstackrealign + BASE_CFLAGS += -arch i386 -m32 -mstackrealign + endif + ifeq ($(ARCH),x86_64) + OPTIMIZEVM += -arch x86_64 -mfpmath=sse endif - BASE_CFLAGS += -fno-strict-aliasing -DMACOS_X -fno-common -pipe + # When compiling on OSX for OSX, we're not cross compiling as far as the + # Makefile is concerned, as target architecture is specified as a compiler + # argument + ifeq ($(COMPILE_PLATFORM),darwin) + CROSS_COMPILING=0 + endif + + ifeq ($(CROSS_COMPILING),1) + ifeq ($(ARCH),x86_64) + CC=x86_64-apple-darwin13-cc + RANLIB=x86_64-apple-darwin13-ranlib + else + ifeq ($(ARCH),x86) + CC=i386-apple-darwin13-cc + RANLIB=i386-apple-darwin13-ranlib + else + $(error Architecture $(ARCH) is not supported when cross compiling) + endif + endif + else + TOOLS_CFLAGS += -DMACOS_X + endif - # Always include debug symbols...you can strip the binary later... - BASE_CFLAGS += -gfull + BASE_CFLAGS += -fno-strict-aliasing -DMACOS_X -fno-common -pipe ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL=1 ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LDFLAGS += -framework OpenAL - else - BASE_CFLAGS += -DUSE_OPENAL_DLOPEN=1 + CLIENT_LIBS += -framework OpenAL endif endif ifeq ($(USE_CURL),1) - BASE_CFLAGS += -DUSE_CURL=1 + CLIENT_CFLAGS += $(CURL_CFLAGS) ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LDFLAGS += -lcurl - else - BASE_CFLAGS += -DUSE_CURL_DLOPEN=1 + CLIENT_LIBS += $(CURL_LIBS) endif endif - ifeq ($(USE_CODEC_VORBIS),1) - BASE_CFLAGS += -DUSE_CODEC_VORBIS=1 - CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg - endif - - ifeq ($(USE_SDL),1) - BASE_CFLAGS += -DUSE_SDL_VIDEO=1 -DUSE_SDL_SOUND=1 -D_THREAD_SAFE=1 \ - -I$(SDLHDIR)/include - # We copy sdlmain before ranlib'ing it so that subversion doesn't think - # the file has been modified by each build. - LIBSDLMAIN=$(B)/libSDLmain.a - LIBSDLMAINSRC=$(LIBSDIR)/macosx/libSDLmain.a - CLIENT_LDFLAGS += -framework Cocoa -framework IOKit -framework OpenGL \ - $(LIBSDIR)/macosx/libSDL-1.2.0.dylib - else - # !!! FIXME: frameworks: OpenGL, Carbon, etc... - #CLIENT_LDFLAGS += -L/usr/X11R6/$(LIB) -lX11 -lXext -lXxf86dga -lXxf86vm - endif - - OPTIMIZE += -falign-loops=16 + BASE_CFLAGS += -D_THREAD_SAFE=1 - ifneq ($(HAVE_VM_COMPILED),true) - BASE_CFLAGS += -DNO_VM_COMPILED + ifeq ($(USE_LOCAL_HEADERS),1) + BASE_CFLAGS += -I$(SDLHDIR)/include endif - DEBUG_CFLAGS = $(BASE_CFLAGS) -g -O0 + # We copy sdlmain before ranlib'ing it so that subversion doesn't think + # the file has been modified by each build. + LIBSDLMAIN=$(B)/libSDL2main.a + LIBSDLMAINSRC=$(LIBSDIR)/macosx/libSDL2main.a + CLIENT_LIBS += -framework IOKit \ + $(LIBSDIR)/macosx/libSDL2-2.0.0.dylib + RENDERER_LIBS += -framework OpenGL $(LIBSDIR)/macosx/libSDL2-2.0.0.dylib + CLIENT_EXTRA_FILES += $(LIBSDIR)/macosx/libSDL2-2.0.0.dylib - RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) + OPTIMIZE = $(OPTIMIZEVM) -ffast-math SHLIBEXT=dylib SHLIBCFLAGS=-fPIC -fno-common - SHLIBLDFLAGS=-dynamiclib $(LDFLAGS) + SHLIBLDFLAGS=-dynamiclib $(LDFLAGS) -Wl,-U,_com_altivec NOTSHLIBCFLAGS=-mdynamic-no-pic @@ -407,39 +483,73 @@ else # ifeq darwin # SETUP AND BUILD -- MINGW32 ############################################################################# -ifeq ($(PLATFORM),mingw32) +ifdef MINGW -ifndef WINDRES -WINDRES=windres -endif + ifeq ($(CROSS_COMPILING),1) + # If CC is already set to something generic, we probably want to use + # something more specific + ifneq ($(findstring $(strip $(CC)),cc gcc),) + CC= + endif - ARCH=x86 + # We need to figure out the correct gcc and windres + ifeq ($(ARCH),x86_64) + MINGW_PREFIXES=amd64-mingw32msvc x86_64-w64-mingw32 + endif + ifeq ($(ARCH),x86) + MINGW_PREFIXES=i586-mingw32msvc i686-w64-mingw32 i686-pc-mingw32 + endif - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes + ifndef CC + CC=$(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), \ + $(call bin_path, $(MINGW_PREFIX)-gcc))) + endif - ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL=1 -DUSE_OPENAL_DLOPEN=1 - endif + ifndef WINDRES + WINDRES=$(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), \ + $(call bin_path, $(MINGW_PREFIX)-windres))) + endif + else + # Some MinGW installations define CC to cc, but don't actually provide cc, + # so check that CC points to a real binary and use gcc if it doesn't + ifeq ($(call bin_path, $(CC)),) + CC=gcc + endif - ifeq ($(USE_CURL),1) - BASE_CFLAGS += -DUSE_CURL=1 - ifneq ($(USE_CURL_DLOPEN),1) - BASE_CFLAGS += -DCURL_STATICLIB + ifndef WINDRES + WINDRES=windres endif endif - ifeq ($(USE_CODEC_VORBIS),1) - BASE_CFLAGS += -DUSE_CODEC_VORBIS=1 + ifeq ($(CC),) + $(error Cannot find a suitable cross compiler for $(PLATFORM)) endif - OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -falign-loops=2 \ - -funroll-loops -falign-jumps=2 -falign-functions=2 -fstrength-reduce + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -DUSE_ICON - HAVE_VM_COMPILED = true + # In the absence of wspiapi.h, require Windows XP or later + ifeq ($(shell test -e $(CMDIR)/wspiapi.h; echo $$?),1) + BASE_CFLAGS += -DWINVER=0x501 + endif - DEBUG_CFLAGS=$(BASE_CFLAGS) -g -O0 + ifeq ($(USE_OPENAL),1) + CLIENT_CFLAGS += $(OPENAL_CFLAGS) + ifneq ($(USE_OPENAL_DLOPEN),1) + CLIENT_LDFLAGS += $(OPENAL_LDFLAGS) + endif + endif - RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) + ifeq ($(ARCH),x86_64) + OPTIMIZEVM = -O3 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math + HAVE_VM_COMPILED = true + endif + ifeq ($(ARCH),x86) + OPTIMIZEVM = -O3 -march=i586 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math + HAVE_VM_COMPILED = true + endif SHLIBEXT=dll SHLIBCFLAGS= @@ -447,29 +557,79 @@ endif BINEXT=.exe - LDFLAGS= -mwindows -lwsock32 -lgdi32 -lwinmm -lole32 - CLIENT_LDFLAGS= + ifeq ($(CROSS_COMPILING),0) + TOOLS_BINEXT=.exe + endif + + ifeq ($(COMPILE_PLATFORM),cygwin) + TOOLS_BINEXT=.exe + TOOLS_CC=$(CC) + endif + + LIBS= -lws2_32 -lwinmm -lpsapi + # clang 3.4 doesn't support this + ifneq ("$(CC)", $(findstring "$(CC)", "clang" "clang++")) + CLIENT_LDFLAGS += -mwindows + endif + CLIENT_LIBS = -lgdi32 -lole32 + RENDERER_LIBS = -lgdi32 -lole32 -lopengl32 + + ifeq ($(USE_FREETYPE),1) + FREETYPE_CFLAGS = -Ifreetype2 + endif ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += $(CURL_CFLAGS) ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LDFLAGS += $(LIBSDIR)/win32/libcurl.a + ifeq ($(USE_LOCAL_HEADERS),1) + CLIENT_CFLAGS += -DCURL_STATICLIB + ifeq ($(ARCH),x86_64) + CLIENT_LIBS += $(LIBSDIR)/win64/libcurl.a + else + CLIENT_LIBS += $(LIBSDIR)/win32/libcurl.a + endif + else + CLIENT_LIBS += $(CURL_LIBS) + endif endif endif - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg - endif - ifeq ($(ARCH),x86) # build 32bit BASE_CFLAGS += -m32 - LDFLAGS+=-m32 + else + BASE_CFLAGS += -m64 endif - BUILD_SERVER = 0 - BUILD_CLIENT_SMP = 0 + # libmingw32 must be linked before libSDLmain + CLIENT_LIBS += -lmingw32 + RENDERER_LIBS += -lmingw32 + + ifeq ($(USE_LOCAL_HEADERS),1) + CLIENT_CFLAGS += -I$(SDLHDIR)/include + ifeq ($(ARCH), x86) + CLIENT_LIBS += $(LIBSDIR)/win32/libSDL2main.a \ + $(LIBSDIR)/win32/libSDL2.dll.a + RENDERER_LIBS += $(LIBSDIR)/win32/libSDL2main.a \ + $(LIBSDIR)/win32/libSDL2.dll.a + SDLDLL=SDL2.dll + CLIENT_EXTRA_FILES += $(LIBSDIR)/win32/SDL2.dll + else + CLIENT_LIBS += $(LIBSDIR)/win64/libSDL264main.a \ + $(LIBSDIR)/win64/libSDL264.dll.a + RENDERER_LIBS += $(LIBSDIR)/win64/libSDL264main.a \ + $(LIBSDIR)/win64/libSDL264.dll.a + SDLDLL=SDL264.dll + CLIENT_EXTRA_FILES += $(LIBSDIR)/win64/SDL264.dll + endif + else + CLIENT_CFLAGS += $(SDL_CFLAGS) + CLIENT_LIBS += $(SDL_LIBS) + RENDERER_LIBS += $(SDL_LIBS) + SDLDLL=SDL2.dll + endif -else # ifeq mingw32 +else # ifdef MINGW ############################################################################# # SETUP AND BUILD -- FREEBSD @@ -477,77 +637,132 @@ else # ifeq mingw32 ifeq ($(PLATFORM),freebsd) - ifneq (,$(findstring alpha,$(shell uname -m))) - ARCH=axp - else #default to x86 - ARCH=x86 - endif #alpha test + # flags + BASE_CFLAGS = $(shell env MACHINE_ARCH=$(ARCH) make -f /dev/null -VCFLAGS) \ + -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON + CLIENT_CFLAGS += $(SDL_CFLAGS) + HAVE_VM_COMPILED = true + OPTIMIZEVM = -O3 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ - -I/usr/X11R6/include + SHLIBEXT=so + SHLIBCFLAGS=-fPIC + SHLIBLDFLAGS=-shared $(LDFLAGS) - DEBUG_CFLAGS=$(BASE_CFLAGS) -g + THREAD_LIBS=-lpthread + # don't need -ldl (FreeBSD) + LIBS=-lm + + CLIENT_LIBS = + CLIENT_LIBS += $(SDL_LIBS) + RENDERER_LIBS = $(SDL_LIBS) -lGL + + # optional features/libraries ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL=1 ifeq ($(USE_OPENAL_DLOPEN),1) - BASE_CFLAGS += -DUSE_OPENAL_DLOPEN=1 + CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) endif endif - ifeq ($(USE_CODEC_VORBIS),1) - BASE_CFLAGS += -DUSE_CODEC_VORBIS=1 + ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += $(CURL_CFLAGS) + ifeq ($(USE_CURL_DLOPEN),1) + CLIENT_LIBS += $(CURL_LIBS) + endif endif - ifeq ($(USE_SDL),1) - BASE_CFLAGS += $(shell sdl11-config --cflags) -DUSE_SDL_VIDEO=1 -DUSE_SDL_SOUND=1 + # cross-compiling tweaks + ifeq ($(ARCH),x86) + ifeq ($(CROSS_COMPILING),1) + BASE_CFLAGS += -m32 + endif endif + ifeq ($(ARCH),x86_64) + ifeq ($(CROSS_COMPILING),1) + BASE_CFLAGS += -m64 + endif + endif +else # ifeq freebsd + +############################################################################# +# SETUP AND BUILD -- OPENBSD +############################################################################# + +ifeq ($(PLATFORM),openbsd) - ifeq ($(ARCH),axp) - BASE_CFLAGS += -DNO_VM_COMPILED - RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -funroll-loops \ - -fomit-frame-pointer -fexpensive-optimizations + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -pipe -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON + CLIENT_CFLAGS += $(SDL_CFLAGS) + + OPTIMIZEVM = -O3 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math + + ifeq ($(ARCH),x86_64) + OPTIMIZEVM = -O3 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math + HAVE_VM_COMPILED = true else ifeq ($(ARCH),x86) - RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -mtune=pentiumpro \ - -march=pentium -fomit-frame-pointer -pipe \ - -falign-loops=2 -falign-jumps=2 -falign-functions=2 \ - -funroll-loops -fstrength-reduce + OPTIMIZEVM = -O3 -march=i586 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math HAVE_VM_COMPILED=true else - BASE_CFLAGS += -DNO_VM_COMPILED + ifeq ($(ARCH),ppc) + BASE_CFLAGS += -maltivec + HAVE_VM_COMPILED=true + endif + ifeq ($(ARCH),ppc64) + BASE_CFLAGS += -maltivec + HAVE_VM_COMPILED=true + endif + ifeq ($(ARCH),sparc64) + OPTIMIZE += -mtune=ultrasparc3 -mv8plus + OPTIMIZEVM += -mtune=ultrasparc3 -mv8plus + HAVE_VM_COMPILED=true + endif + ifeq ($(ARCH),alpha) + # According to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=410555 + # -ffast-math will cause the client to die with SIGFPE on Alpha + OPTIMIZE = $(OPTIMIZEVM) endif endif + endif + + ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += $(CURL_CFLAGS) + USE_CURL_DLOPEN=0 + endif + + # no shm_open on OpenBSD + USE_MUMBLE=0 SHLIBEXT=so SHLIBCFLAGS=-fPIC SHLIBLDFLAGS=-shared $(LDFLAGS) - THREAD_LDFLAGS=-lpthread - # don't need -ldl (FreeBSD) - LDFLAGS=-lm + THREAD_LIBS=-lpthread + LIBS=-lm - CLIENT_LDFLAGS = + CLIENT_LIBS = - ifeq ($(USE_SDL),1) - CLIENT_LDFLAGS += $(shell sdl11-config --libs) - else - CLIENT_LDFLAGS += -L/usr/X11R6/$(LIB) -lGL -lX11 -lXext -lXxf86dga -lXxf86vm - endif + CLIENT_LIBS += $(SDL_LIBS) + RENDERER_LIBS = $(SDL_LIBS) -lGL ifeq ($(USE_OPENAL),1) ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LDFLAGS += $(THREAD_LDFLAGS) -lopenal + CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) endif endif - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg + ifeq ($(USE_CURL),1) + ifneq ($(USE_CURL_DLOPEN),1) + CLIENT_LIBS += $(CURL_LIBS) + endif endif - - -else # ifeq freebsd +else # ifeq openbsd ############################################################################# # SETUP AND BUILD -- NETBSD @@ -555,47 +770,47 @@ else # ifeq freebsd ifeq ($(PLATFORM),netbsd) - ifeq ($(shell uname -m),i386) - ARCH=x86 - endif - - LDFLAGS=-lm + LIBS=-lm SHLIBEXT=so SHLIBCFLAGS=-fPIC SHLIBLDFLAGS=-shared $(LDFLAGS) - THREAD_LDFLAGS=-lpthread + THREAD_LIBS=-lpthread BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes - DEBUG_CFLAGS=$(BASE_CFLAGS) -g - ifneq ($(ARCH),x86) - BASE_CFLAGS += -DNO_VM_COMPILED + ifeq ($(ARCH),x86) + HAVE_VM_COMPILED=true endif BUILD_CLIENT = 0 - BUILD_GAME_QVM = 0 - else # ifeq netbsd ############################################################################# # SETUP AND BUILD -- IRIX ############################################################################# -ifeq ($(PLATFORM),irix) +ifeq ($(PLATFORM),irix64) + LIB=lib + + ARCH=mips - ARCH=mips #default to MIPS + CC = c99 + MKDIR = mkdir -p - BASE_CFLAGS=-Dstricmp=strcasecmp -Xcpluscomm -woff 1185 -mips3 \ - -nostdinc -I. -I$(ROOT)/usr/include -DNO_VM_COMPILED - RELEASE_CFLAGS=$(BASE_CFLAGS) -O3 - DEBUG_CFLAGS=$(BASE_CFLAGS) -g + BASE_CFLAGS=-Dstricmp=strcasecmp -Xcpluscomm -woff 1185 \ + -I. -I$(ROOT)/usr/include + CLIENT_CFLAGS += $(SDL_CFLAGS) + OPTIMIZE = -O3 SHLIBEXT=so SHLIBCFLAGS= SHLIBLDFLAGS=-shared - LDFLAGS=-ldl -lm - CLIENT_LDFLAGS=-L/usr/X11/$(LIB) -lGL -lX11 -lXext -lm + LIBS=-ldl -lm -lgen + # FIXME: The X libraries probably aren't necessary? + CLIENT_LIBS=-L/usr/X11/$(LIB) $(SDL_LIBS) \ + -lX11 -lXext -lm + RENDERER_LIBS = $(SDL_LIBS) -lGL else # ifeq IRIX @@ -610,77 +825,55 @@ ifeq ($(PLATFORM),sunos) MKDIR=gmkdir COPYDIR="/usr/local/share/games/tremulous" - ifneq (,$(findstring i86pc,$(shell uname -m))) - ARCH=x86 - else #default to sparc - ARCH=sparc - endif - ifneq ($(ARCH),x86) ifneq ($(ARCH),sparc) $(error arch $(ARCH) is currently not supported) endif endif + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -pipe -DUSE_ICON + CLIENT_CFLAGS += $(SDL_CFLAGS) - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes -pipe - - ifeq ($(USE_SDL),1) - BASE_CFLAGS += -DUSE_SDL_SOUND=1 $(shell sdl-config --cflags) - else - BASE_CFLAGS += -I/usr/openwin/include - endif - - OPTIMIZE = -O3 -funroll-loops + OPTIMIZEVM = -O3 -funroll-loops ifeq ($(ARCH),sparc) - OPTIMIZE = -O3 -falign-loops=2 \ - -falign-jumps=2 -falign-functions=2 -fstrength-reduce \ - -mtune=ultrasparc -mv8plus -mno-faster-structs \ - -funroll-loops + OPTIMIZEVM += -O3 \ + -fstrength-reduce -falign-functions=2 \ + -mtune=ultrasparc3 -mv8plus -mno-faster-structs + HAVE_VM_COMPILED=true else ifeq ($(ARCH),x86) - OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer \ - -funroll-loops -falign-loops=2 -falign-jumps=2 \ + OPTIMIZEVM += -march=i586 -fomit-frame-pointer \ -falign-functions=2 -fstrength-reduce HAVE_VM_COMPILED=true BASE_CFLAGS += -m32 - LDFLAGS += -m32 - BASE_CFLAGS += -I/usr/X11/include/NVIDIA - endif + CLIENT_CFLAGS += -I/usr/X11/include/NVIDIA + CLIENT_LDFLAGS += -L/usr/X11/lib/NVIDIA -R/usr/X11/lib/NVIDIA endif - - ifneq ($(HAVE_VM_COMPILED),true) - BASE_CFLAGS += -DNO_VM_COMPILED endif - DEBUG_CFLAGS = $(BASE_CFLAGS) -ggdb -O0 - - RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) + OPTIMIZE = $(OPTIMIZEVM) -ffast-math SHLIBEXT=so SHLIBCFLAGS=-fPIC SHLIBLDFLAGS=-shared $(LDFLAGS) - THREAD_LDFLAGS=-lpthread - LDFLAGS=-lsocket -lnsl -ldl -lm + THREAD_LIBS=-lpthread + LIBS=-lsocket -lnsl -ldl -lm BOTCFLAGS=-O0 - ifeq ($(USE_SDL),1) - CLIENT_LDFLAGS=$(shell sdl-config --libs) -L/usr/X11/lib -lGLU -lX11 -lXext - else - CLIENT_LDFLAGS=-L/usr/openwin/$(LIB) -L/usr/X11/lib -lGLU -lX11 -lXext - endif + CLIENT_LIBS +=$(SDL_LIBS) -lX11 -lXext -liconv -lm + RENDERER_LIBS = $(SDL_LIBS) -lGL else # ifeq sunos ############################################################################# # SETUP AND BUILD -- GENERIC ############################################################################# - BASE_CFLAGS=-DNO_VM_COMPILED - DEBUG_CFLAGS=$(BASE_CFLAGS) -g - RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 + BASE_CFLAGS= + OPTIMIZE = -O3 SHLIBEXT=so SHLIBCFLAGS=-fPIC @@ -688,32 +881,170 @@ else # ifeq sunos endif #Linux endif #darwin -endif #mingw32 +endif #MINGW endif #FreeBSD +endif #OpenBSD endif #NetBSD endif #IRIX endif #SunOS +ifndef CC + CC=gcc +endif + +ifndef RANLIB + RANLIB=ranlib +endif + +ifneq ($(HAVE_VM_COMPILED),true) + BASE_CFLAGS += -DNO_VM_COMPILED + BUILD_GAME_QVM=0 +endif + TARGETS = +ifndef FULLBINEXT + FULLBINEXT=.$(ARCH)$(BINEXT) +endif + +ifndef SHLIBNAME + SHLIBNAME=$(ARCH).$(SHLIBEXT) +endif + +ifneq ($(BUILD_SERVER),0) + TARGETS += $(B)/$(SERVERBIN)$(FULLBINEXT) +endif + +ifneq ($(BUILD_CLIENT),0) + ifneq ($(USE_RENDERER_DLOPEN),0) + TARGETS += $(B)/$(CLIENTBIN)$(FULLBINEXT) $(B)/renderer_opengl1_$(SHLIBNAME) + ifneq ($(BUILD_RENDERER_OPENGL2),0) + TARGETS += $(B)/renderer_opengl2_$(SHLIBNAME) + endif + else + TARGETS += $(B)/$(CLIENTBIN)$(FULLBINEXT) + ifneq ($(BUILD_RENDERER_OPENGL2),0) + TARGETS += $(B)/$(CLIENTBIN)_opengl2$(FULLBINEXT) + endif + endif +endif + ifneq ($(BUILD_GAME_SO),0) TARGETS += \ - $(B)/base/cgame$(ARCH).$(SHLIBEXT) \ - $(B)/base/game$(ARCH).$(SHLIBEXT) \ - $(B)/base/ui$(ARCH).$(SHLIBEXT) + $(B)/$(BASEGAME)/cgame$(SHLIBNAME) \ + $(B)/$(BASEGAME)/game$(SHLIBNAME) \ + $(B)/$(BASEGAME)/ui$(SHLIBNAME) endif ifneq ($(BUILD_GAME_QVM),0) - ifneq ($(CROSS_COMPILING),1) - TARGETS += \ - $(B)/base/vm/cgame.qvm \ - $(B)/base/vm/game.qvm \ - $(B)/base/vm/ui.qvm + TARGETS += \ + $(B)/$(BASEGAME)/vm/cgame.qvm \ + $(B)/$(BASEGAME)/vm/game.qvm \ + $(B)/$(BASEGAME)/vm/ui.qvm +endif + +ifeq ($(USE_OPENAL),1) + CLIENT_CFLAGS += -DUSE_OPENAL + ifeq ($(USE_OPENAL_DLOPEN),1) + CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN + endif +endif + +ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += -DUSE_CURL + ifeq ($(USE_CURL_DLOPEN),1) + CLIENT_CFLAGS += -DUSE_CURL_DLOPEN endif endif -ifeq ($(USE_CCACHE),1) - CC := ccache $(CC) +ifeq ($(USE_VOIP),1) + CLIENT_CFLAGS += -DUSE_VOIP + SERVER_CFLAGS += -DUSE_VOIP + NEED_OPUS=1 +endif + +ifeq ($(USE_CODEC_OPUS),1) + CLIENT_CFLAGS += -DUSE_CODEC_OPUS + NEED_OPUS=1 +endif + +ifeq ($(NEED_OPUS),1) + ifeq ($(USE_INTERNAL_OPUS),1) + OPUS_CFLAGS = -DOPUS_BUILD -DHAVE_LRINTF -DFLOATING_POINT -DUSE_ALLOCA \ + -I$(OPUSDIR)/include -I$(OPUSDIR)/celt -I$(OPUSDIR)/silk \ + -I$(OPUSDIR)/silk/float -I$(OPUSFILEDIR)/include + else + OPUS_CFLAGS ?= $(shell pkg-config --silence-errors --cflags opusfile opus || true) + OPUS_LIBS ?= $(shell pkg-config --silence-errors --libs opusfile opus || echo -lopusfile -lopus) + endif + CLIENT_CFLAGS += $(OPUS_CFLAGS) + CLIENT_LIBS += $(OPUS_LIBS) + NEED_OGG=1 +endif + +ifeq ($(USE_CODEC_VORBIS),1) + CLIENT_CFLAGS += -DUSE_CODEC_VORBIS + ifeq ($(USE_INTERNAL_VORBIS),1) + CLIENT_CFLAGS += -I$(VORBISDIR)/include -I$(VORBISDIR)/lib + else + VORBIS_CFLAGS ?= $(shell pkg-config --silence-errors --cflags vorbisfile vorbis || true) + VORBIS_LIBS ?= $(shell pkg-config --silence-errors --libs vorbisfile vorbis || echo -lvorbisfile -lvorbis) + endif + CLIENT_CFLAGS += $(VORBIS_CFLAGS) + CLIENT_LIBS += $(VORBIS_LIBS) + NEED_OGG=1 +endif + +ifeq ($(NEED_OGG),1) + ifeq ($(USE_INTERNAL_OGG),1) + OGG_CFLAGS = -I$(OGGDIR)/include + else + OGG_CFLAGS ?= $(shell pkg-config --silence-errors --cflags ogg || true) + OGG_LIBS ?= $(shell pkg-config --silence-errors --libs ogg || echo -logg) + endif + CLIENT_CFLAGS += $(OGG_CFLAGS) + CLIENT_LIBS += $(OGG_LIBS) +endif + +ifeq ($(USE_RENDERER_DLOPEN),1) + CLIENT_CFLAGS += -DUSE_RENDERER_DLOPEN +endif + +ifeq ($(USE_MUMBLE),1) + CLIENT_CFLAGS += -DUSE_MUMBLE +endif + +ifeq ($(USE_INTERNAL_ZLIB),1) + ZLIB_CFLAGS = -DNO_GZIP -I$(ZDIR) +else + ZLIB_CFLAGS ?= $(shell pkg-config --silence-errors --cflags zlib || true) + ZLIB_LIBS ?= $(shell pkg-config --silence-errors --libs zlib || echo -lz) +endif +BASE_CFLAGS += $(ZLIB_CFLAGS) +LIBS += $(ZLIB_LIBS) + +ifeq ($(USE_INTERNAL_JPEG),1) + BASE_CFLAGS += -DUSE_INTERNAL_JPEG + BASE_CFLAGS += -I$(JPDIR) +else + # IJG libjpeg doesn't have pkg-config, but libjpeg-turbo uses libjpeg.pc; + # we fall back to hard-coded answers if libjpeg.pc is unavailable + JPEG_CFLAGS ?= $(shell pkg-config --silence-errors --cflags libjpeg || true) + JPEG_LIBS ?= $(shell pkg-config --silence-errors --libs libjpeg || echo -ljpeg) + BASE_CFLAGS += $(JPEG_CFLAGS) + RENDERER_LIBS += $(JPEG_LIBS) +endif + +ifeq ($(USE_FREETYPE),1) + FREETYPE_CFLAGS ?= $(shell pkg-config --silence-errors --cflags freetype2 || true) + FREETYPE_LIBS ?= $(shell pkg-config --silence-errors --libs freetype2 || echo -lfreetype) + + BASE_CFLAGS += -DBUILD_FREETYPE $(FREETYPE_CFLAGS) + RENDERER_LIBS += $(FREETYPE_LIBS) +endif + +ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++")) + BASE_CFLAGS += -Qunused-arguments endif ifdef DEFAULT_BASEDIR @@ -721,30 +1052,55 @@ ifdef DEFAULT_BASEDIR endif ifeq ($(USE_LOCAL_HEADERS),1) - BASE_CFLAGS += -DUSE_LOCAL_HEADERS=1 + BASE_CFLAGS += -DUSE_LOCAL_HEADERS +endif + +ifeq ($(BUILD_STANDALONE),1) + BASE_CFLAGS += -DSTANDALONE endif ifeq ($(GENERATE_DEPENDENCIES),1) - BASE_CFLAGS += -MMD + DEPEND_CFLAGS = -MMD +else + DEPEND_CFLAGS = endif -ifeq ($(USE_SVN),1) - BASE_CFLAGS += -DSVN_VERSION=\\\"$(SVN_VERSION)\\\" +ifeq ($(NO_STRIP),1) + STRIP_FLAG = +else + STRIP_FLAG = -s +endif + +BASE_CFLAGS += -DPRODUCT_VERSION=\\\"$(VERSION)\\\" +BASE_CFLAGS += -Wformat=2 -Wno-format-zero-length -Wformat-security -Wno-format-nonliteral +BASE_CFLAGS += -Wstrict-aliasing=2 -Wmissing-format-attribute +BASE_CFLAGS += -Wdisabled-optimization +BASE_CFLAGS += -Werror-implicit-function-declaration + +ifeq ($(V),1) +echo_cmd=@: +Q= +else +echo_cmd=@echo +Q=@ endif -define DO_CC -@echo "CC $<" -@$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -o $@ -c $< +define DO_CC +$(echo_cmd) "CC $<" +$(Q)$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) $(CLIENT_CFLAGS) $(OPTIMIZE) -o $@ -c $< endef -define DO_SMP_CC -@echo "SMP_CC $<" -@$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -DSMP -o $@ -c $< +define DO_REF_CC +$(echo_cmd) "REF_CC $<" +$(Q)$(CC) $(SHLIBCFLAGS) $(CFLAGS) $(CLIENT_CFLAGS) $(OPTIMIZE) -o $@ -c $< endef -define DO_BOT_CC -@echo "BOT_CC $<" -@$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) $(BOTCFLAGS) -DBOTLIB -o $@ -c $< +define DO_REF_STR +$(echo_cmd) "REF_STR $<" +$(Q)rm -f $@ +$(Q)echo "const char *fallbackShader_$(notdir $(basename $<)) =" >> $@ +$(Q)cat $< | sed 's/^/\"/;s/$$/\\n\"/' >> $@ +$(Q)echo ";" >> $@ endef ifeq ($(GENERATE_DEPENDENCIES),1) @@ -752,24 +1108,42 @@ ifeq ($(GENERATE_DEPENDENCIES),1) endif define DO_SHLIB_CC -@echo "SHLIB_CC $<" -@$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< -@$(DO_QVM_DEP) +$(echo_cmd) "SHLIB_CC $<" +$(Q)$(CC) $(BASEGAME_CFLAGS) $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $< +$(Q)$(DO_QVM_DEP) +endef + +define DO_GAME_CC +$(echo_cmd) "GAME_CC $<" +$(Q)$(CC) $(BASEGAME_CFLAGS) -DGAME $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $< +$(Q)$(DO_QVM_DEP) +endef + +define DO_CGAME_CC +$(echo_cmd) "CGAME_CC $<" +$(Q)$(CC) $(BASEGAME_CFLAGS) -DCGAME $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $< +$(Q)$(DO_QVM_DEP) +endef + +define DO_UI_CC +$(echo_cmd) "UI_CC $<" +$(Q)$(CC) $(BASEGAME_CFLAGS) -DUI $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $< +$(Q)$(DO_QVM_DEP) endef define DO_AS -@echo "AS $<" -@$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $< +$(echo_cmd) "AS $<" +$(Q)$(CC) $(CFLAGS) $(OPTIMIZE) -x assembler-with-cpp -o $@ -c $< endef define DO_DED_CC -@echo "DED_CC $<" -@$(CC) $(NOTSHLIBCFLAGS) -DDEDICATED $(CFLAGS) -o $@ -c $< +$(echo_cmd) "DED_CC $<" +$(Q)$(CC) $(NOTSHLIBCFLAGS) -DDEDICATED $(CFLAGS) $(SERVER_CFLAGS) $(OPTIMIZE) -o $@ -c $< endef define DO_WINDRES -@echo "WINDRES $<" -@$(WINDRES) -i $< -o $@ +$(echo_cmd) "WINDRES $<" +$(Q)$(WINDRES) -i $< -o $@ endef @@ -781,110 +1155,984 @@ default: release all: debug release debug: - @$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS)" + @$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(BASE_CFLAGS) $(DEPEND_CFLAGS)" \ + OPTIMIZE="$(DEBUG_CFLAGS)" OPTIMIZEVM="$(DEBUG_CFLAGS)" \ + CLIENT_CFLAGS="$(CLIENT_CFLAGS)" SERVER_CFLAGS="$(SERVER_CFLAGS)" V=$(V) +ifeq ($(BUILD_MASTER_SERVER),1) + $(MAKE) -C $(MASTERDIR) debug +endif release: - @$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS)" + @$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(BASE_CFLAGS) $(DEPEND_CFLAGS)" \ + OPTIMIZE="-DNDEBUG $(OPTIMIZE)" OPTIMIZEVM="-DNDEBUG $(OPTIMIZEVM)" \ + CLIENT_CFLAGS="$(CLIENT_CFLAGS)" SERVER_CFLAGS="$(SERVER_CFLAGS)" V=$(V) +ifeq ($(BUILD_MASTER_SERVER),1) + $(MAKE) -C $(MASTERDIR) release +endif + +ifneq ($(call bin_path, tput),) + TERM_COLUMNS=$(shell if c=`tput cols`; then echo $$(($$c-4)); else echo 76; fi) +else + TERM_COLUMNS=76 +endif + +define ADD_COPY_TARGET +TARGETS += $2 +$2: $1 + $(echo_cmd) "CP $$<" + @cp $1 $2 +endef + +# These functions allow us to generate rules for copying a list of files +# into the base directory of the build; this is useful for bundling libs, +# README files or whatever else +define GENERATE_COPY_TARGETS +$(foreach FILE,$1, \ + $(eval $(call ADD_COPY_TARGET, \ + $(FILE), \ + $(addprefix $(B)/,$(notdir $(FILE)))))) +endef + +$(call GENERATE_COPY_TARGETS,$(EXTRA_FILES)) + +ifneq ($(BUILD_CLIENT),0) + $(call GENERATE_COPY_TARGETS,$(CLIENT_EXTRA_FILES)) +endif + +NAKED_TARGETS=$(shell echo $(TARGETS) | sed -e "s!$(B)/!!g") -# Create the build directories and tools, print out +print_list=-@for i in $(1); \ + do \ + echo " $$i"; \ + done + +ifneq ($(call bin_path, fmt),) + print_wrapped=@echo $(1) | fmt -w $(TERM_COLUMNS) | sed -e "s/^\(.*\)$$/ \1/" +else + print_wrapped=$(print_list) +endif + +# Create the build directories, check libraries and print out # an informational message, then start building -targets: makedirs tools +targets: makedirs @echo "" - @echo "Building Tremulous in $(B):" + @echo "Building in $(B):" + @echo " PLATFORM: $(PLATFORM)" + @echo " ARCH: $(ARCH)" + @echo " VERSION: $(VERSION)" + @echo " COMPILE_PLATFORM: $(COMPILE_PLATFORM)" + @echo " COMPILE_ARCH: $(COMPILE_ARCH)" @echo " CC: $(CC)" +ifeq ($(PLATFORM),mingw32) + @echo " WINDRES: $(WINDRES)" +endif @echo "" @echo " CFLAGS:" - @for i in $(CFLAGS); \ - do \ - echo " $$i"; \ - done + $(call print_wrapped, $(CFLAGS) $(OPTIMIZE)) + @echo "" + @echo " CLIENT_CFLAGS:" + $(call print_wrapped, $(CLIENT_CFLAGS)) + @echo "" + @echo " SERVER_CFLAGS:" + $(call print_wrapped, $(SERVER_CFLAGS)) + @echo "" + @echo " LDFLAGS:" + $(call print_wrapped, $(LDFLAGS)) + @echo "" + @echo " LIBS:" + $(call print_wrapped, $(LIBS)) + @echo "" + @echo " CLIENT_LIBS:" + $(call print_wrapped, $(CLIENT_LIBS)) @echo "" @echo " Output:" - @for i in $(TARGETS); \ - do \ - echo " $$i"; \ - done + $(call print_list, $(NAKED_TARGETS)) @echo "" - @$(MAKE) $(TARGETS) +ifneq ($(TARGETS),) + ifndef DEBUG_MAKEFILE + @$(MAKE) $(TARGETS) $(B).zip V=$(V) + endif +endif + +$(B).zip: $(TARGETS) +ifeq ($(PLATFORM),darwin) + ifdef ARCHIVE + @("./make-macosx-app.sh" release $(ARCH); if [ "$$?" -eq 0 ] && [ -d "$(B)/tremulous.app" ]; then rm -f $@; cd $(B) && zip --symlinks -r9 ../../$@ `find "tremulous.app" -print | sed -e "s!$(B)/!!g"`; else rm -f $@; cd $(B) && zip -r9 ../../$@ $(NAKED_TARGETS); fi) + endif +endif +ifneq ($(PLATFORM),darwin) + ifdef ARCHIVE + @rm -f $@ + @(cd $(B) && zip -r9 ../../$@ $(NAKED_TARGETS)) + endif +endif makedirs: @if [ ! -d $(BUILD_DIR) ];then $(MKDIR) $(BUILD_DIR);fi @if [ ! -d $(B) ];then $(MKDIR) $(B);fi - @if [ ! -d $(B)/base/ ];then $(MKDIR) $(B)/base/;fi - @if [ ! -d $(B)/base/cgame ];then $(MKDIR) $(B)/base/cgame;fi - @if [ ! -d $(B)/base/game ];then $(MKDIR) $(B)/base/game;fi - @if [ ! -d $(B)/base/ui ];then $(MKDIR) $(B)/base/ui;fi - @if [ ! -d $(B)/base/qcommon ];then $(MKDIR) $(B)/base/qcommon;fi - @if [ ! -d $(B)/base/vm ];then $(MKDIR) $(B)/base/vm;fi + @if [ ! -d $(B)/client ];then $(MKDIR) $(B)/client;fi + @if [ ! -d $(B)/client/opus ];then $(MKDIR) $(B)/client/opus;fi + @if [ ! -d $(B)/client/vorbis ];then $(MKDIR) $(B)/client/vorbis;fi + @if [ ! -d $(B)/renderergl1 ];then $(MKDIR) $(B)/renderergl1;fi + @if [ ! -d $(B)/renderergl2 ];then $(MKDIR) $(B)/renderergl2;fi + @if [ ! -d $(B)/renderergl2/glsl ];then $(MKDIR) $(B)/renderergl2/glsl;fi + @if [ ! -d $(B)/ded ];then $(MKDIR) $(B)/ded;fi + @if [ ! -d $(B)/$(BASEGAME) ];then $(MKDIR) $(B)/$(BASEGAME);fi + @if [ ! -d $(B)/$(BASEGAME)/cgame ];then $(MKDIR) $(B)/$(BASEGAME)/cgame;fi + @if [ ! -d $(B)/$(BASEGAME)/game ];then $(MKDIR) $(B)/$(BASEGAME)/game;fi + @if [ ! -d $(B)/$(BASEGAME)/ui ];then $(MKDIR) $(B)/$(BASEGAME)/ui;fi + @if [ ! -d $(B)/$(BASEGAME)/qcommon ];then $(MKDIR) $(B)/$(BASEGAME)/qcommon;fi + @if [ ! -d $(B)/$(BASEGAME)/vm ];then $(MKDIR) $(B)/$(BASEGAME)/vm;fi + @if [ ! -d $(B)/tools ];then $(MKDIR) $(B)/tools;fi + @if [ ! -d $(B)/tools/asm ];then $(MKDIR) $(B)/tools/asm;fi + @if [ ! -d $(B)/tools/etc ];then $(MKDIR) $(B)/tools/etc;fi + @if [ ! -d $(B)/tools/rcc ];then $(MKDIR) $(B)/tools/rcc;fi + @if [ ! -d $(B)/tools/cpp ];then $(MKDIR) $(B)/tools/cpp;fi + @if [ ! -d $(B)/tools/lburg ];then $(MKDIR) $(B)/tools/lburg;fi ############################################################################# # QVM BUILD TOOLS ############################################################################# -Q3LCC=$(TOOLSDIR)/q3lcc$(BINEXT) -Q3ASM=$(TOOLSDIR)/q3asm$(BINEXT) +ifndef TOOLS_CC + # A compiler which probably produces native binaries + TOOLS_CC = gcc +endif -ifeq ($(CROSS_COMPILING),1) -tools: - @echo QVM tools not built when cross-compiling -else -tools: - $(MAKE) -C $(TOOLSDIR)/lcc install - $(MAKE) -C $(TOOLSDIR)/asm install +TOOLS_OPTIMIZE = -g -Wall -fno-strict-aliasing +TOOLS_CFLAGS += $(TOOLS_OPTIMIZE) \ + -DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \ + -I$(Q3LCCSRCDIR) \ + -I$(LBURGDIR) +TOOLS_LIBS = +TOOLS_LDFLAGS = + +ifeq ($(GENERATE_DEPENDENCIES),1) + TOOLS_CFLAGS += -MMD endif +define DO_TOOLS_CC +$(echo_cmd) "TOOLS_CC $<" +$(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) -o $@ -c $< +endef + +define DO_TOOLS_CC_DAGCHECK +$(echo_cmd) "TOOLS_CC_DAGCHECK $<" +$(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) -Wno-unused -o $@ -c $< +endef + +LBURG = $(B)/tools/lburg/lburg$(TOOLS_BINEXT) +DAGCHECK_C = $(B)/tools/rcc/dagcheck.c +Q3RCC = $(B)/tools/q3rcc$(TOOLS_BINEXT) +Q3CPP = $(B)/tools/q3cpp$(TOOLS_BINEXT) +Q3LCC = $(B)/tools/q3lcc$(TOOLS_BINEXT) +Q3ASM = $(B)/tools/q3asm$(TOOLS_BINEXT) + +LBURGOBJ= \ + $(B)/tools/lburg/lburg.o \ + $(B)/tools/lburg/gram.o + +$(B)/tools/lburg/%.o: $(LBURGDIR)/%.c + $(DO_TOOLS_CC) + +$(LBURG): $(LBURGOBJ) + $(echo_cmd) "LD $@" + $(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ $(TOOLS_LIBS) + +Q3RCCOBJ = \ + $(B)/tools/rcc/alloc.o \ + $(B)/tools/rcc/bind.o \ + $(B)/tools/rcc/bytecode.o \ + $(B)/tools/rcc/dag.o \ + $(B)/tools/rcc/dagcheck.o \ + $(B)/tools/rcc/decl.o \ + $(B)/tools/rcc/enode.o \ + $(B)/tools/rcc/error.o \ + $(B)/tools/rcc/event.o \ + $(B)/tools/rcc/expr.o \ + $(B)/tools/rcc/gen.o \ + $(B)/tools/rcc/init.o \ + $(B)/tools/rcc/inits.o \ + $(B)/tools/rcc/input.o \ + $(B)/tools/rcc/lex.o \ + $(B)/tools/rcc/list.o \ + $(B)/tools/rcc/main.o \ + $(B)/tools/rcc/null.o \ + $(B)/tools/rcc/output.o \ + $(B)/tools/rcc/prof.o \ + $(B)/tools/rcc/profio.o \ + $(B)/tools/rcc/simp.o \ + $(B)/tools/rcc/stmt.o \ + $(B)/tools/rcc/string.o \ + $(B)/tools/rcc/sym.o \ + $(B)/tools/rcc/symbolic.o \ + $(B)/tools/rcc/trace.o \ + $(B)/tools/rcc/tree.o \ + $(B)/tools/rcc/types.o + +$(DAGCHECK_C): $(LBURG) $(Q3LCCSRCDIR)/dagcheck.md + $(echo_cmd) "LBURG $(Q3LCCSRCDIR)/dagcheck.md" + $(Q)$(LBURG) $(Q3LCCSRCDIR)/dagcheck.md $@ + +$(B)/tools/rcc/dagcheck.o: $(DAGCHECK_C) + $(DO_TOOLS_CC_DAGCHECK) + +$(B)/tools/rcc/%.o: $(Q3LCCSRCDIR)/%.c + $(DO_TOOLS_CC) + +$(Q3RCC): $(Q3RCCOBJ) + $(echo_cmd) "LD $@" + $(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ $(TOOLS_LIBS) + +Q3CPPOBJ = \ + $(B)/tools/cpp/cpp.o \ + $(B)/tools/cpp/lex.o \ + $(B)/tools/cpp/nlist.o \ + $(B)/tools/cpp/tokens.o \ + $(B)/tools/cpp/macro.o \ + $(B)/tools/cpp/eval.o \ + $(B)/tools/cpp/include.o \ + $(B)/tools/cpp/hideset.o \ + $(B)/tools/cpp/getopt.o \ + $(B)/tools/cpp/unix.o + +$(B)/tools/cpp/%.o: $(Q3CPPDIR)/%.c + $(DO_TOOLS_CC) + +$(Q3CPP): $(Q3CPPOBJ) + $(echo_cmd) "LD $@" + $(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ $(TOOLS_LIBS) + +Q3LCCOBJ = \ + $(B)/tools/etc/lcc.o \ + $(B)/tools/etc/bytecode.o + +$(B)/tools/etc/%.o: $(Q3LCCETCDIR)/%.c + $(DO_TOOLS_CC) + +$(Q3LCC): $(Q3LCCOBJ) $(Q3RCC) $(Q3CPP) + $(echo_cmd) "LD $@" + $(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $(Q3LCCOBJ) $(TOOLS_LIBS) + define DO_Q3LCC -@echo "Q3LCC $<" -@$(Q3LCC) -o $@ $< +$(echo_cmd) "Q3LCC $<" +$(Q)$(Q3LCC) $(BASEGAME_CFLAGS) -o $@ $< endef +define DO_CGAME_Q3LCC +$(echo_cmd) "CGAME_Q3LCC $<" +$(Q)$(Q3LCC) $(BASEGAME_CFLAGS) -DCGAME -o $@ $< +endef + +define DO_GAME_Q3LCC +$(echo_cmd) "GAME_Q3LCC $<" +$(Q)$(Q3LCC) $(BASEGAME_CFLAGS) -DGAME -o $@ $< +endef + +define DO_UI_Q3LCC +$(echo_cmd) "UI_Q3LCC $<" +$(Q)$(Q3LCC) $(BASEGAME_CFLAGS) -DUI -o $@ $< +endef + + +Q3ASMOBJ = \ + $(B)/tools/asm/q3asm.o \ + $(B)/tools/asm/cmdlib.o + +$(B)/tools/asm/%.o: $(Q3ASMDIR)/%.c + $(DO_TOOLS_CC) + +$(Q3ASM): $(Q3ASMOBJ) + $(echo_cmd) "LD $@" + $(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ $(TOOLS_LIBS) + + +############################################################################# +# CLIENT/SERVER +############################################################################# + +Q3OBJ = \ + $(B)/client/cl_cgame.o \ + $(B)/client/cl_cin.o \ + $(B)/client/cl_console.o \ + $(B)/client/cl_input.o \ + $(B)/client/cl_keys.o \ + $(B)/client/cl_main.o \ + $(B)/client/cl_net_chan.o \ + $(B)/client/cl_parse.o \ + $(B)/client/cl_scrn.o \ + $(B)/client/cl_ui.o \ + $(B)/client/cl_avi.o \ + \ + $(B)/client/cm_load.o \ + $(B)/client/cm_patch.o \ + $(B)/client/cm_polylib.o \ + $(B)/client/cm_test.o \ + $(B)/client/cm_trace.o \ + \ + $(B)/client/cmd.o \ + $(B)/client/common.o \ + $(B)/client/cvar.o \ + $(B)/client/files.o \ + $(B)/client/md4.o \ + $(B)/client/md5.o \ + $(B)/client/msg.o \ + $(B)/client/net_chan.o \ + $(B)/client/net_ip.o \ + $(B)/client/huffman.o \ + $(B)/client/parse.o \ + \ + $(B)/client/snd_adpcm.o \ + $(B)/client/snd_dma.o \ + $(B)/client/snd_mem.o \ + $(B)/client/snd_mix.o \ + $(B)/client/snd_wavelet.o \ + \ + $(B)/client/snd_main.o \ + $(B)/client/snd_codec.o \ + $(B)/client/snd_codec_wav.o \ + $(B)/client/snd_codec_ogg.o \ + $(B)/client/snd_codec_opus.o \ + \ + $(B)/client/qal.o \ + $(B)/client/snd_openal.o \ + \ + $(B)/client/cl_curl.o \ + \ + $(B)/client/sv_ccmds.o \ + $(B)/client/sv_client.o \ + $(B)/client/sv_game.o \ + $(B)/client/sv_init.o \ + $(B)/client/sv_main.o \ + $(B)/client/sv_net_chan.o \ + $(B)/client/sv_snapshot.o \ + $(B)/client/sv_world.o \ + \ + $(B)/client/q_math.o \ + $(B)/client/q_shared.o \ + \ + $(B)/client/unzip.o \ + $(B)/client/ioapi.o \ + $(B)/client/puff.o \ + $(B)/client/vm.o \ + $(B)/client/vm_interpreted.o \ + \ + \ + $(B)/client/sdl_input.o \ + $(B)/client/sdl_snd.o \ + \ + $(B)/client/con_log.o \ + $(B)/client/sys_main.o + +ifdef MINGW + Q3OBJ += \ + $(B)/client/con_passive.o +else + Q3OBJ += \ + $(B)/client/con_tty.o +endif + +Q3R2OBJ = \ + $(B)/renderergl2/tr_animation.o \ + $(B)/renderergl2/tr_backend.o \ + $(B)/renderergl2/tr_bsp.o \ + $(B)/renderergl2/tr_cmds.o \ + $(B)/renderergl2/tr_curve.o \ + $(B)/renderergl2/tr_dsa.o \ + $(B)/renderergl2/tr_extramath.o \ + $(B)/renderergl2/tr_extensions.o \ + $(B)/renderergl2/tr_fbo.o \ + $(B)/renderergl2/tr_flares.o \ + $(B)/renderergl2/tr_font.o \ + $(B)/renderergl2/tr_glsl.o \ + $(B)/renderergl2/tr_image.o \ + $(B)/renderergl2/tr_image_bmp.o \ + $(B)/renderergl2/tr_image_jpg.o \ + $(B)/renderergl2/tr_image_pcx.o \ + $(B)/renderergl2/tr_image_png.o \ + $(B)/renderergl2/tr_image_tga.o \ + $(B)/renderergl2/tr_image_dds.o \ + $(B)/renderergl2/tr_init.o \ + $(B)/renderergl2/tr_light.o \ + $(B)/renderergl2/tr_main.o \ + $(B)/renderergl2/tr_marks.o \ + $(B)/renderergl2/tr_mesh.o \ + $(B)/renderergl2/tr_model.o \ + $(B)/renderergl2/tr_model_iqm.o \ + $(B)/renderergl2/tr_noise.o \ + $(B)/renderergl2/tr_postprocess.o \ + $(B)/renderergl2/tr_scene.o \ + $(B)/renderergl2/tr_shade.o \ + $(B)/renderergl2/tr_shade_calc.o \ + $(B)/renderergl2/tr_shader.o \ + $(B)/renderergl2/tr_shadows.o \ + $(B)/renderergl2/tr_sky.o \ + $(B)/renderergl2/tr_surface.o \ + $(B)/renderergl2/tr_vbo.o \ + $(B)/renderergl2/tr_world.o \ + \ + $(B)/renderergl1/sdl_gamma.o \ + $(B)/renderergl1/sdl_glimp.o + +Q3R2STRINGOBJ = \ + $(B)/renderergl2/glsl/bokeh_fp.o \ + $(B)/renderergl2/glsl/bokeh_vp.o \ + $(B)/renderergl2/glsl/calclevels4x_fp.o \ + $(B)/renderergl2/glsl/calclevels4x_vp.o \ + $(B)/renderergl2/glsl/depthblur_fp.o \ + $(B)/renderergl2/glsl/depthblur_vp.o \ + $(B)/renderergl2/glsl/dlight_fp.o \ + $(B)/renderergl2/glsl/dlight_vp.o \ + $(B)/renderergl2/glsl/down4x_fp.o \ + $(B)/renderergl2/glsl/down4x_vp.o \ + $(B)/renderergl2/glsl/fogpass_fp.o \ + $(B)/renderergl2/glsl/fogpass_vp.o \ + $(B)/renderergl2/glsl/generic_fp.o \ + $(B)/renderergl2/glsl/generic_vp.o \ + $(B)/renderergl2/glsl/lightall_fp.o \ + $(B)/renderergl2/glsl/lightall_vp.o \ + $(B)/renderergl2/glsl/pshadow_fp.o \ + $(B)/renderergl2/glsl/pshadow_vp.o \ + $(B)/renderergl2/glsl/shadowfill_fp.o \ + $(B)/renderergl2/glsl/shadowfill_vp.o \ + $(B)/renderergl2/glsl/shadowmask_fp.o \ + $(B)/renderergl2/glsl/shadowmask_vp.o \ + $(B)/renderergl2/glsl/ssao_fp.o \ + $(B)/renderergl2/glsl/ssao_vp.o \ + $(B)/renderergl2/glsl/texturecolor_fp.o \ + $(B)/renderergl2/glsl/texturecolor_vp.o \ + $(B)/renderergl2/glsl/tonemap_fp.o \ + $(B)/renderergl2/glsl/tonemap_vp.o + +Q3ROBJ = \ + $(B)/renderergl1/tr_animation.o \ + $(B)/renderergl1/tr_backend.o \ + $(B)/renderergl1/tr_bsp.o \ + $(B)/renderergl1/tr_cmds.o \ + $(B)/renderergl1/tr_curve.o \ + $(B)/renderergl1/tr_flares.o \ + $(B)/renderergl1/tr_font.o \ + $(B)/renderergl1/tr_image.o \ + $(B)/renderergl1/tr_image_bmp.o \ + $(B)/renderergl1/tr_image_jpg.o \ + $(B)/renderergl1/tr_image_pcx.o \ + $(B)/renderergl1/tr_image_png.o \ + $(B)/renderergl1/tr_image_tga.o \ + $(B)/renderergl1/tr_init.o \ + $(B)/renderergl1/tr_light.o \ + $(B)/renderergl1/tr_main.o \ + $(B)/renderergl1/tr_marks.o \ + $(B)/renderergl1/tr_mesh.o \ + $(B)/renderergl1/tr_model.o \ + $(B)/renderergl1/tr_model_iqm.o \ + $(B)/renderergl1/tr_noise.o \ + $(B)/renderergl1/tr_scene.o \ + $(B)/renderergl1/tr_shade.o \ + $(B)/renderergl1/tr_shade_calc.o \ + $(B)/renderergl1/tr_shader.o \ + $(B)/renderergl1/tr_shadows.o \ + $(B)/renderergl1/tr_sky.o \ + $(B)/renderergl1/tr_surface.o \ + $(B)/renderergl1/tr_world.o \ + \ + $(B)/renderergl1/sdl_gamma.o \ + $(B)/renderergl1/sdl_glimp.o + +ifneq ($(USE_RENDERER_DLOPEN), 0) + Q3ROBJ += \ + $(B)/renderergl1/q_shared.o \ + $(B)/renderergl1/puff.o \ + $(B)/renderergl1/q_math.o \ + $(B)/renderergl1/tr_subs.o + + Q3R2OBJ += \ + $(B)/renderergl1/q_shared.o \ + $(B)/renderergl1/puff.o \ + $(B)/renderergl1/q_math.o \ + $(B)/renderergl1/tr_subs.o +endif + +ifneq ($(USE_INTERNAL_JPEG),0) + JPGOBJ = \ + $(B)/renderergl1/jaricom.o \ + $(B)/renderergl1/jcapimin.o \ + $(B)/renderergl1/jcapistd.o \ + $(B)/renderergl1/jcarith.o \ + $(B)/renderergl1/jccoefct.o \ + $(B)/renderergl1/jccolor.o \ + $(B)/renderergl1/jcdctmgr.o \ + $(B)/renderergl1/jchuff.o \ + $(B)/renderergl1/jcinit.o \ + $(B)/renderergl1/jcmainct.o \ + $(B)/renderergl1/jcmarker.o \ + $(B)/renderergl1/jcmaster.o \ + $(B)/renderergl1/jcomapi.o \ + $(B)/renderergl1/jcparam.o \ + $(B)/renderergl1/jcprepct.o \ + $(B)/renderergl1/jcsample.o \ + $(B)/renderergl1/jctrans.o \ + $(B)/renderergl1/jdapimin.o \ + $(B)/renderergl1/jdapistd.o \ + $(B)/renderergl1/jdarith.o \ + $(B)/renderergl1/jdatadst.o \ + $(B)/renderergl1/jdatasrc.o \ + $(B)/renderergl1/jdcoefct.o \ + $(B)/renderergl1/jdcolor.o \ + $(B)/renderergl1/jddctmgr.o \ + $(B)/renderergl1/jdhuff.o \ + $(B)/renderergl1/jdinput.o \ + $(B)/renderergl1/jdmainct.o \ + $(B)/renderergl1/jdmarker.o \ + $(B)/renderergl1/jdmaster.o \ + $(B)/renderergl1/jdmerge.o \ + $(B)/renderergl1/jdpostct.o \ + $(B)/renderergl1/jdsample.o \ + $(B)/renderergl1/jdtrans.o \ + $(B)/renderergl1/jerror.o \ + $(B)/renderergl1/jfdctflt.o \ + $(B)/renderergl1/jfdctfst.o \ + $(B)/renderergl1/jfdctint.o \ + $(B)/renderergl1/jidctflt.o \ + $(B)/renderergl1/jidctfst.o \ + $(B)/renderergl1/jidctint.o \ + $(B)/renderergl1/jmemmgr.o \ + $(B)/renderergl1/jmemnobs.o \ + $(B)/renderergl1/jquant1.o \ + $(B)/renderergl1/jquant2.o \ + $(B)/renderergl1/jutils.o +endif + +ifeq ($(ARCH),x86) + Q3OBJ += \ + $(B)/client/snd_mixa.o \ + $(B)/client/matha.o \ + $(B)/client/snapvector.o \ + $(B)/client/ftola.o +endif +ifeq ($(ARCH),x86_64) + Q3OBJ += \ + $(B)/client/snapvector.o \ + $(B)/client/ftola.o +endif + +ifeq ($(NEED_OPUS),1) +ifeq ($(USE_INTERNAL_OPUS),1) +Q3OBJ += \ + $(B)/client/opus/analysis.o \ + $(B)/client/opus/mlp.o \ + $(B)/client/opus/mlp_data.o \ + $(B)/client/opus/opus.o \ + $(B)/client/opus/opus_decoder.o \ + $(B)/client/opus/opus_encoder.o \ + $(B)/client/opus/opus_multistream.o \ + $(B)/client/opus/opus_multistream_encoder.o \ + $(B)/client/opus/opus_multistream_decoder.o \ + $(B)/client/opus/repacketizer.o \ + \ + $(B)/client/opus/bands.o \ + $(B)/client/opus/celt.o \ + $(B)/client/opus/cwrs.o \ + $(B)/client/opus/entcode.o \ + $(B)/client/opus/entdec.o \ + $(B)/client/opus/entenc.o \ + $(B)/client/opus/kiss_fft.o \ + $(B)/client/opus/laplace.o \ + $(B)/client/opus/mathops.o \ + $(B)/client/opus/mdct.o \ + $(B)/client/opus/modes.o \ + $(B)/client/opus/pitch.o \ + $(B)/client/opus/celt_encoder.o \ + $(B)/client/opus/celt_decoder.o \ + $(B)/client/opus/celt_lpc.o \ + $(B)/client/opus/quant_bands.o \ + $(B)/client/opus/rate.o \ + $(B)/client/opus/vq.o \ + \ + $(B)/client/opus/CNG.o \ + $(B)/client/opus/code_signs.o \ + $(B)/client/opus/init_decoder.o \ + $(B)/client/opus/decode_core.o \ + $(B)/client/opus/decode_frame.o \ + $(B)/client/opus/decode_parameters.o \ + $(B)/client/opus/decode_indices.o \ + $(B)/client/opus/decode_pulses.o \ + $(B)/client/opus/decoder_set_fs.o \ + $(B)/client/opus/dec_API.o \ + $(B)/client/opus/enc_API.o \ + $(B)/client/opus/encode_indices.o \ + $(B)/client/opus/encode_pulses.o \ + $(B)/client/opus/gain_quant.o \ + $(B)/client/opus/interpolate.o \ + $(B)/client/opus/LP_variable_cutoff.o \ + $(B)/client/opus/NLSF_decode.o \ + $(B)/client/opus/NSQ.o \ + $(B)/client/opus/NSQ_del_dec.o \ + $(B)/client/opus/PLC.o \ + $(B)/client/opus/shell_coder.o \ + $(B)/client/opus/tables_gain.o \ + $(B)/client/opus/tables_LTP.o \ + $(B)/client/opus/tables_NLSF_CB_NB_MB.o \ + $(B)/client/opus/tables_NLSF_CB_WB.o \ + $(B)/client/opus/tables_other.o \ + $(B)/client/opus/tables_pitch_lag.o \ + $(B)/client/opus/tables_pulses_per_block.o \ + $(B)/client/opus/VAD.o \ + $(B)/client/opus/control_audio_bandwidth.o \ + $(B)/client/opus/quant_LTP_gains.o \ + $(B)/client/opus/VQ_WMat_EC.o \ + $(B)/client/opus/HP_variable_cutoff.o \ + $(B)/client/opus/NLSF_encode.o \ + $(B)/client/opus/NLSF_VQ.o \ + $(B)/client/opus/NLSF_unpack.o \ + $(B)/client/opus/NLSF_del_dec_quant.o \ + $(B)/client/opus/process_NLSFs.o \ + $(B)/client/opus/stereo_LR_to_MS.o \ + $(B)/client/opus/stereo_MS_to_LR.o \ + $(B)/client/opus/check_control_input.o \ + $(B)/client/opus/control_SNR.o \ + $(B)/client/opus/init_encoder.o \ + $(B)/client/opus/control_codec.o \ + $(B)/client/opus/A2NLSF.o \ + $(B)/client/opus/ana_filt_bank_1.o \ + $(B)/client/opus/biquad_alt.o \ + $(B)/client/opus/bwexpander_32.o \ + $(B)/client/opus/bwexpander.o \ + $(B)/client/opus/debug.o \ + $(B)/client/opus/decode_pitch.o \ + $(B)/client/opus/inner_prod_aligned.o \ + $(B)/client/opus/lin2log.o \ + $(B)/client/opus/log2lin.o \ + $(B)/client/opus/LPC_analysis_filter.o \ + $(B)/client/opus/LPC_inv_pred_gain.o \ + $(B)/client/opus/table_LSF_cos.o \ + $(B)/client/opus/NLSF2A.o \ + $(B)/client/opus/NLSF_stabilize.o \ + $(B)/client/opus/NLSF_VQ_weights_laroia.o \ + $(B)/client/opus/pitch_est_tables.o \ + $(B)/client/opus/resampler.o \ + $(B)/client/opus/resampler_down2_3.o \ + $(B)/client/opus/resampler_down2.o \ + $(B)/client/opus/resampler_private_AR2.o \ + $(B)/client/opus/resampler_private_down_FIR.o \ + $(B)/client/opus/resampler_private_IIR_FIR.o \ + $(B)/client/opus/resampler_private_up2_HQ.o \ + $(B)/client/opus/resampler_rom.o \ + $(B)/client/opus/sigm_Q15.o \ + $(B)/client/opus/sort.o \ + $(B)/client/opus/sum_sqr_shift.o \ + $(B)/client/opus/stereo_decode_pred.o \ + $(B)/client/opus/stereo_encode_pred.o \ + $(B)/client/opus/stereo_find_predictor.o \ + $(B)/client/opus/stereo_quant_pred.o \ + \ + $(B)/client/opus/apply_sine_window_FLP.o \ + $(B)/client/opus/corrMatrix_FLP.o \ + $(B)/client/opus/encode_frame_FLP.o \ + $(B)/client/opus/find_LPC_FLP.o \ + $(B)/client/opus/find_LTP_FLP.o \ + $(B)/client/opus/find_pitch_lags_FLP.o \ + $(B)/client/opus/find_pred_coefs_FLP.o \ + $(B)/client/opus/LPC_analysis_filter_FLP.o \ + $(B)/client/opus/LTP_analysis_filter_FLP.o \ + $(B)/client/opus/LTP_scale_ctrl_FLP.o \ + $(B)/client/opus/noise_shape_analysis_FLP.o \ + $(B)/client/opus/prefilter_FLP.o \ + $(B)/client/opus/process_gains_FLP.o \ + $(B)/client/opus/regularize_correlations_FLP.o \ + $(B)/client/opus/residual_energy_FLP.o \ + $(B)/client/opus/solve_LS_FLP.o \ + $(B)/client/opus/warped_autocorrelation_FLP.o \ + $(B)/client/opus/wrappers_FLP.o \ + $(B)/client/opus/autocorrelation_FLP.o \ + $(B)/client/opus/burg_modified_FLP.o \ + $(B)/client/opus/bwexpander_FLP.o \ + $(B)/client/opus/energy_FLP.o \ + $(B)/client/opus/inner_product_FLP.o \ + $(B)/client/opus/k2a_FLP.o \ + $(B)/client/opus/levinsondurbin_FLP.o \ + $(B)/client/opus/LPC_inv_pred_gain_FLP.o \ + $(B)/client/opus/pitch_analysis_core_FLP.o \ + $(B)/client/opus/scale_copy_vector_FLP.o \ + $(B)/client/opus/scale_vector_FLP.o \ + $(B)/client/opus/schur_FLP.o \ + $(B)/client/opus/sort_FLP.o \ + \ + $(B)/client/http.o \ + $(B)/client/info.o \ + $(B)/client/internal.o \ + $(B)/client/opusfile.o \ + $(B)/client/stream.o \ + $(B)/client/wincerts.o +endif +endif + +ifeq ($(NEED_OGG),1) +ifeq ($(USE_INTERNAL_OGG),1) +Q3OBJ += \ + $(B)/client/bitwise.o \ + $(B)/client/framing.o +endif +endif + +ifeq ($(USE_CODEC_VORBIS),1) +ifeq ($(USE_INTERNAL_VORBIS),1) +Q3OBJ += \ + $(B)/client/vorbis/analysis.o \ + $(B)/client/vorbis/bitrate.o \ + $(B)/client/vorbis/block.o \ + $(B)/client/vorbis/codebook.o \ + $(B)/client/vorbis/envelope.o \ + $(B)/client/vorbis/floor0.o \ + $(B)/client/vorbis/floor1.o \ + $(B)/client/vorbis/info.o \ + $(B)/client/vorbis/lookup.o \ + $(B)/client/vorbis/lpc.o \ + $(B)/client/vorbis/lsp.o \ + $(B)/client/vorbis/mapping0.o \ + $(B)/client/vorbis/mdct.o \ + $(B)/client/vorbis/psy.o \ + $(B)/client/vorbis/registry.o \ + $(B)/client/vorbis/res0.o \ + $(B)/client/vorbis/smallft.o \ + $(B)/client/vorbis/sharedbook.o \ + $(B)/client/vorbis/synthesis.o \ + $(B)/client/vorbis/vorbisfile.o \ + $(B)/client/vorbis/window.o +endif +endif + +ifeq ($(USE_INTERNAL_ZLIB),1) +Q3OBJ += \ + $(B)/client/adler32.o \ + $(B)/client/crc32.o \ + $(B)/client/inffast.o \ + $(B)/client/inflate.o \ + $(B)/client/inftrees.o \ + $(B)/client/zutil.o +endif + +ifeq ($(HAVE_VM_COMPILED),true) + ifneq ($(findstring $(ARCH),x86 x86_64),) + Q3OBJ += \ + $(B)/client/vm_x86.o + endif + ifneq ($(findstring $(ARCH),ppc ppc64),) + Q3OBJ += $(B)/client/vm_powerpc.o $(B)/client/vm_powerpc_asm.o + endif + ifeq ($(ARCH),sparc) + Q3OBJ += $(B)/client/vm_sparc.o + endif +endif + +ifdef MINGW + Q3OBJ += \ + $(B)/client/win_resource.o \ + $(B)/client/sys_win32.o +else + Q3OBJ += \ + $(B)/client/sys_unix.o +endif + +ifeq ($(PLATFORM),darwin) + Q3OBJ += \ + $(B)/client/sys_osx.o +endif + +ifeq ($(USE_MUMBLE),1) + Q3OBJ += \ + $(B)/client/libmumblelink.o +endif + +ifneq ($(USE_RENDERER_DLOPEN),0) +$(B)/$(CLIENTBIN)$(FULLBINEXT): $(Q3OBJ) $(LIBSDLMAIN) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) \ + -o $@ $(Q3OBJ) \ + $(LIBSDLMAIN) $(CLIENT_LIBS) $(LIBS) + +$(B)/renderer_opengl1_$(SHLIBNAME): $(Q3ROBJ) $(JPGOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3ROBJ) $(JPGOBJ) \ + $(THREAD_LIBS) $(LIBSDLMAIN) $(RENDERER_LIBS) $(LIBS) + +$(B)/renderer_opengl2_$(SHLIBNAME): $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ) \ + $(THREAD_LIBS) $(LIBSDLMAIN) $(RENDERER_LIBS) $(LIBS) +else +$(B)/$(CLIENTBIN)$(FULLBINEXT): $(Q3OBJ) $(Q3ROBJ) $(JPGOBJ) $(LIBSDLMAIN) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) \ + -o $@ $(Q3OBJ) $(Q3ROBJ) $(JPGOBJ) \ + $(LIBSDLMAIN) $(CLIENT_LIBS) $(RENDERER_LIBS) $(LIBS) + +$(B)/$(CLIENTBIN)_opengl2$(FULLBINEXT): $(Q3OBJ) $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ) $(LIBSDLMAIN) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) \ + -o $@ $(Q3OBJ) $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ) \ + $(LIBSDLMAIN) $(CLIENT_LIBS) $(RENDERER_LIBS) $(LIBS) +endif + +ifneq ($(strip $(LIBSDLMAIN)),) +ifneq ($(strip $(LIBSDLMAINSRC)),) +$(LIBSDLMAIN) : $(LIBSDLMAINSRC) + cp $< $@ + $(RANLIB) $@ +endif +endif + + + +############################################################################# +# DEDICATED SERVER +############################################################################# + +Q3DOBJ = \ + $(B)/ded/sv_client.o \ + $(B)/ded/sv_ccmds.o \ + $(B)/ded/sv_game.o \ + $(B)/ded/sv_init.o \ + $(B)/ded/sv_main.o \ + $(B)/ded/sv_net_chan.o \ + $(B)/ded/sv_snapshot.o \ + $(B)/ded/sv_world.o \ + \ + $(B)/ded/cm_load.o \ + $(B)/ded/cm_patch.o \ + $(B)/ded/cm_polylib.o \ + $(B)/ded/cm_test.o \ + $(B)/ded/cm_trace.o \ + $(B)/ded/cmd.o \ + $(B)/ded/common.o \ + $(B)/ded/cvar.o \ + $(B)/ded/files.o \ + $(B)/ded/md4.o \ + $(B)/ded/msg.o \ + $(B)/ded/net_chan.o \ + $(B)/ded/net_ip.o \ + $(B)/ded/huffman.o \ + $(B)/ded/parse.o \ + \ + $(B)/ded/q_math.o \ + $(B)/ded/q_shared.o \ + \ + $(B)/ded/unzip.o \ + $(B)/ded/ioapi.o \ + $(B)/ded/vm.o \ + $(B)/ded/vm_interpreted.o \ + \ + $(B)/ded/null_client.o \ + $(B)/ded/null_input.o \ + $(B)/ded/null_snddma.o \ + \ + $(B)/ded/con_log.o \ + $(B)/ded/sys_main.o + +ifeq ($(ARCH),x86) + Q3DOBJ += \ + $(B)/ded/matha.o \ + $(B)/ded/snapvector.o \ + $(B)/ded/ftola.o +endif +ifeq ($(ARCH),x86_64) + Q3DOBJ += \ + $(B)/ded/snapvector.o \ + $(B)/ded/ftola.o +endif + +ifeq ($(USE_INTERNAL_ZLIB),1) +Q3DOBJ += \ + $(B)/ded/adler32.o \ + $(B)/ded/crc32.o \ + $(B)/ded/inffast.o \ + $(B)/ded/inflate.o \ + $(B)/ded/inftrees.o \ + $(B)/ded/zutil.o +endif + +ifeq ($(HAVE_VM_COMPILED),true) + ifneq ($(findstring $(ARCH),x86 x86_64),) + Q3DOBJ += \ + $(B)/ded/vm_x86.o + endif + ifneq ($(findstring $(ARCH),ppc ppc64),) + Q3DOBJ += $(B)/ded/vm_powerpc.o $(B)/ded/vm_powerpc_asm.o + endif + ifeq ($(ARCH),sparc) + Q3DOBJ += $(B)/ded/vm_sparc.o + endif +endif + +ifdef MINGW + Q3DOBJ += \ + $(B)/ded/win_resource.o \ + $(B)/ded/sys_win32.o \ + $(B)/ded/con_win32.o +else + Q3DOBJ += \ + $(B)/ded/sys_unix.o \ + $(B)/ded/con_tty.o +endif + +ifeq ($(PLATFORM),darwin) + Q3DOBJ += \ + $(B)/ded/sys_osx.o +endif + +$(B)/$(SERVERBIN)$(FULLBINEXT): $(Q3DOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(Q3DOBJ) $(LIBS) + + + ############################################################################# ## TREMULOUS CGAME ############################################################################# CGOBJ_ = \ - $(B)/base/cgame/cg_main.o \ - $(B)/base/game/bg_misc.o \ - $(B)/base/game/bg_pmove.o \ - $(B)/base/game/bg_slidemove.o \ - $(B)/base/cgame/cg_consolecmds.o \ - $(B)/base/cgame/cg_buildable.o \ - $(B)/base/cgame/cg_animation.o \ - $(B)/base/cgame/cg_animmapobj.o \ - $(B)/base/cgame/cg_draw.o \ - $(B)/base/cgame/cg_drawtools.o \ - $(B)/base/cgame/cg_ents.o \ - $(B)/base/cgame/cg_event.o \ - $(B)/base/cgame/cg_marks.o \ - $(B)/base/cgame/cg_players.o \ - $(B)/base/cgame/cg_playerstate.o \ - $(B)/base/cgame/cg_predict.o \ - $(B)/base/cgame/cg_servercmds.o \ - $(B)/base/cgame/cg_snapshot.o \ - $(B)/base/cgame/cg_view.o \ - $(B)/base/cgame/cg_weapons.o \ - $(B)/base/cgame/cg_mem.o \ - $(B)/base/cgame/cg_scanner.o \ - $(B)/base/cgame/cg_attachment.o \ - $(B)/base/cgame/cg_trails.o \ - $(B)/base/cgame/cg_particles.o \ - $(B)/base/cgame/cg_ptr.o \ - $(B)/base/cgame/cg_tutorial.o \ - $(B)/base/ui/ui_shared.o \ + $(B)/$(BASEGAME)/cgame/cg_main.o \ + $(B)/$(BASEGAME)/cgame/bg_misc.o \ + $(B)/$(BASEGAME)/cgame/bg_pmove.o \ + $(B)/$(BASEGAME)/cgame/bg_slidemove.o \ + $(B)/$(BASEGAME)/cgame/bg_lib.o \ + $(B)/$(BASEGAME)/cgame/bg_alloc.o \ + $(B)/$(BASEGAME)/cgame/bg_voice.o \ + $(B)/$(BASEGAME)/cgame/cg_consolecmds.o \ + $(B)/$(BASEGAME)/cgame/cg_buildable.o \ + $(B)/$(BASEGAME)/cgame/cg_animation.o \ + $(B)/$(BASEGAME)/cgame/cg_animmapobj.o \ + $(B)/$(BASEGAME)/cgame/cg_draw.o \ + $(B)/$(BASEGAME)/cgame/cg_drawtools.o \ + $(B)/$(BASEGAME)/cgame/cg_ents.o \ + $(B)/$(BASEGAME)/cgame/cg_event.o \ + $(B)/$(BASEGAME)/cgame/cg_marks.o \ + $(B)/$(BASEGAME)/cgame/cg_players.o \ + $(B)/$(BASEGAME)/cgame/cg_playerstate.o \ + $(B)/$(BASEGAME)/cgame/cg_predict.o \ + $(B)/$(BASEGAME)/cgame/cg_servercmds.o \ + $(B)/$(BASEGAME)/cgame/cg_snapshot.o \ + $(B)/$(BASEGAME)/cgame/cg_view.o \ + $(B)/$(BASEGAME)/cgame/cg_weapons.o \ + $(B)/$(BASEGAME)/cgame/cg_scanner.o \ + $(B)/$(BASEGAME)/cgame/cg_attachment.o \ + $(B)/$(BASEGAME)/cgame/cg_trails.o \ + $(B)/$(BASEGAME)/cgame/cg_particles.o \ + $(B)/$(BASEGAME)/cgame/cg_tutorial.o \ + $(B)/$(BASEGAME)/cgame/ui_shared.o \ \ - $(B)/base/qcommon/q_math.o \ - $(B)/base/qcommon/q_shared.o + $(B)/$(BASEGAME)/qcommon/q_math.o \ + $(B)/$(BASEGAME)/qcommon/q_shared.o -CGOBJ = $(CGOBJ_) $(B)/base/cgame/cg_syscalls.o -CGVMOBJ = $(CGOBJ_:%.o=%.asm) $(B)/base/game/bg_lib.asm +CGOBJ = $(CGOBJ_) $(B)/$(BASEGAME)/cgame/cg_syscalls.o +CGVMOBJ = $(CGOBJ_:%.o=%.asm) -$(B)/base/cgame$(ARCH).$(SHLIBEXT) : $(CGOBJ) - @echo "LD $@" - @$(CC) $(SHLIBLDFLAGS) -o $@ $(CGOBJ) +$(B)/$(BASEGAME)/cgame$(SHLIBNAME): $(CGOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(CGOBJ) -$(B)/base/vm/cgame.qvm: $(CGVMOBJ) $(CGDIR)/cg_syscalls.asm - @echo "Q3ASM $@" - @$(Q3ASM) -o $@ $(CGVMOBJ) $(CGDIR)/cg_syscalls.asm +$(B)/$(BASEGAME)/vm/cgame.qvm: $(CGVMOBJ) $(CGDIR)/cg_syscalls.asm $(Q3ASM) + $(echo_cmd) "Q3ASM $@" + $(Q)$(Q3ASM) -o $@ $(CGVMOBJ) $(CGDIR)/cg_syscalls.asm @@ -893,45 +2141,47 @@ $(B)/base/vm/cgame.qvm: $(CGVMOBJ) $(CGDIR)/cg_syscalls.asm ############################################################################# GOBJ_ = \ - $(B)/base/game/g_main.o \ - $(B)/base/game/bg_misc.o \ - $(B)/base/game/bg_pmove.o \ - $(B)/base/game/bg_slidemove.o \ - $(B)/base/game/g_mem.o \ - $(B)/base/game/g_active.o \ - $(B)/base/game/g_client.o \ - $(B)/base/game/g_cmds.o \ - $(B)/base/game/g_combat.o \ - $(B)/base/game/g_physics.o \ - $(B)/base/game/g_buildable.o \ - $(B)/base/game/g_misc.o \ - $(B)/base/game/g_missile.o \ - $(B)/base/game/g_mover.o \ - $(B)/base/game/g_session.o \ - $(B)/base/game/g_spawn.o \ - $(B)/base/game/g_svcmds.o \ - $(B)/base/game/g_target.o \ - $(B)/base/game/g_team.o \ - $(B)/base/game/g_trigger.o \ - $(B)/base/game/g_utils.o \ - $(B)/base/game/g_maprotation.o \ - $(B)/base/game/g_ptr.o \ - $(B)/base/game/g_weapon.o \ - $(B)/base/game/g_admin.o \ + $(B)/$(BASEGAME)/game/g_main.o \ + $(B)/$(BASEGAME)/game/bg_misc.o \ + $(B)/$(BASEGAME)/game/bg_pmove.o \ + $(B)/$(BASEGAME)/game/bg_slidemove.o \ + $(B)/$(BASEGAME)/game/bg_lib.o \ + $(B)/$(BASEGAME)/game/bg_alloc.o \ + $(B)/$(BASEGAME)/game/bg_voice.o \ + $(B)/$(BASEGAME)/game/g_active.o \ + $(B)/$(BASEGAME)/game/g_client.o \ + $(B)/$(BASEGAME)/game/g_cmds.o \ + $(B)/$(BASEGAME)/game/g_combat.o \ + $(B)/$(BASEGAME)/game/g_physics.o \ + $(B)/$(BASEGAME)/game/g_buildable.o \ + $(B)/$(BASEGAME)/game/g_misc.o \ + $(B)/$(BASEGAME)/game/g_missile.o \ + $(B)/$(BASEGAME)/game/g_mover.o \ + $(B)/$(BASEGAME)/game/g_session.o \ + $(B)/$(BASEGAME)/game/g_spawn.o \ + $(B)/$(BASEGAME)/game/g_svcmds.o \ + $(B)/$(BASEGAME)/game/g_target.o \ + $(B)/$(BASEGAME)/game/g_team.o \ + $(B)/$(BASEGAME)/game/g_trigger.o \ + $(B)/$(BASEGAME)/game/g_utils.o \ + $(B)/$(BASEGAME)/game/g_maprotation.o \ + $(B)/$(BASEGAME)/game/g_weapon.o \ + $(B)/$(BASEGAME)/game/g_admin.o \ + $(B)/$(BASEGAME)/game/g_namelog.o \ \ - $(B)/base/qcommon/q_math.o \ - $(B)/base/qcommon/q_shared.o + $(B)/$(BASEGAME)/qcommon/q_math.o \ + $(B)/$(BASEGAME)/qcommon/q_shared.o -GOBJ = $(GOBJ_) $(B)/base/game/g_syscalls.o -GVMOBJ = $(GOBJ_:%.o=%.asm) $(B)/base/game/bg_lib.asm +GOBJ = $(GOBJ_) $(B)/$(BASEGAME)/game/g_syscalls.o +GVMOBJ = $(GOBJ_:%.o=%.asm) -$(B)/base/game$(ARCH).$(SHLIBEXT) : $(GOBJ) - @echo "LD $@" - @$(CC) $(SHLIBLDFLAGS) -o $@ $(GOBJ) +$(B)/$(BASEGAME)/game$(SHLIBNAME): $(GOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(GOBJ) -$(B)/base/vm/game.qvm: $(GVMOBJ) $(GDIR)/g_syscalls.asm - @echo "Q3ASM $@" - @$(Q3ASM) -o $@ $(GVMOBJ) $(GDIR)/g_syscalls.asm +$(B)/$(BASEGAME)/vm/game.qvm: $(GVMOBJ) $(GDIR)/g_syscalls.asm $(Q3ASM) + $(echo_cmd) "Q3ASM $@" + $(Q)$(Q3ASM) -o $@ $(GVMOBJ) $(GDIR)/g_syscalls.asm @@ -940,58 +2190,200 @@ $(B)/base/vm/game.qvm: $(GVMOBJ) $(GDIR)/g_syscalls.asm ############################################################################# UIOBJ_ = \ - $(B)/base/ui/ui_main.o \ - $(B)/base/ui/ui_atoms.o \ - $(B)/base/ui/ui_players.o \ - $(B)/base/ui/ui_shared.o \ - $(B)/base/ui/ui_gameinfo.o \ + $(B)/$(BASEGAME)/ui/ui_main.o \ + $(B)/$(BASEGAME)/ui/ui_atoms.o \ + $(B)/$(BASEGAME)/ui/ui_shared.o \ + $(B)/$(BASEGAME)/ui/ui_gameinfo.o \ \ - $(B)/base/game/bg_misc.o \ - $(B)/base/qcommon/q_math.o \ - $(B)/base/qcommon/q_shared.o + $(B)/$(BASEGAME)/ui/bg_misc.o \ + $(B)/$(BASEGAME)/ui/bg_lib.o \ + $(B)/$(BASEGAME)/qcommon/q_math.o \ + $(B)/$(BASEGAME)/qcommon/q_shared.o + +UIOBJ = $(UIOBJ_) $(B)/$(BASEGAME)/ui/ui_syscalls.o +UIVMOBJ = $(UIOBJ_:%.o=%.asm) + +$(B)/$(BASEGAME)/ui$(SHLIBNAME): $(UIOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(UIOBJ) + +$(B)/$(BASEGAME)/vm/ui.qvm: $(UIVMOBJ) $(UIDIR)/ui_syscalls.asm $(Q3ASM) + $(echo_cmd) "Q3ASM $@" + $(Q)$(Q3ASM) -o $@ $(UIVMOBJ) $(UIDIR)/ui_syscalls.asm + + + +############################################################################# +## CLIENT/SERVER RULES +############################################################################# + +$(B)/client/%.o: $(ASMDIR)/%.s + $(DO_AS) + +# k8 so inline assembler knows about SSE +$(B)/client/%.o: $(ASMDIR)/%.c + $(DO_CC) -march=k8 + +$(B)/client/%.o: $(CDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(SDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(CMDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(SPEEXDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(OGGDIR)/src/%.c + $(DO_CC) + +$(B)/client/vorbis/%.o: $(VORBISDIR)/lib/%.c + $(DO_CC) + +$(B)/client/opus/%.o: $(OPUSDIR)/src/%.c + $(DO_CC) + +$(B)/client/opus/%.o: $(OPUSDIR)/celt/%.c + $(DO_CC) + +$(B)/client/opus/%.o: $(OPUSDIR)/silk/%.c + $(DO_CC) + +$(B)/client/opus/%.o: $(OPUSDIR)/silk/float/%.c + $(DO_CC) + +$(B)/client/%.o: $(OPUSFILEDIR)/src/%.c + $(DO_CC) + +$(B)/client/%.o: $(ZDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(SDLDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(SYSDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(SYSDIR)/%.m + $(DO_CC) + +$(B)/client/%.o: $(SYSDIR)/%.rc + $(DO_WINDRES) + + +$(B)/renderergl1/%.o: $(CMDIR)/%.c + $(DO_REF_CC) + +$(B)/renderergl1/%.o: $(SDLDIR)/%.c + $(DO_REF_CC) + +$(B)/renderergl1/%.o: $(JPDIR)/%.c + $(DO_REF_CC) + +$(B)/renderergl1/%.o: $(RCOMMONDIR)/%.c + $(DO_REF_CC) + +$(B)/renderergl1/%.o: $(RGL1DIR)/%.c + $(DO_REF_CC) + +$(B)/renderergl2/glsl/%.c: $(RGL2DIR)/glsl/%.glsl + $(DO_REF_STR) + +$(B)/renderergl2/glsl/%.o: $(B)/renderergl2/glsl/%.c + $(DO_REF_CC) -UIOBJ = $(UIOBJ_) $(B)/base/ui/ui_syscalls.o -UIVMOBJ = $(UIOBJ_:%.o=%.asm) $(B)/base/game/bg_lib.asm +$(B)/renderergl2/%.o: $(RCOMMONDIR)/%.c + $(DO_REF_CC) -$(B)/base/ui$(ARCH).$(SHLIBEXT) : $(UIOBJ) - @echo "LD $@" - @$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(UIOBJ) +$(B)/renderergl2/%.o: $(RGL2DIR)/%.c + $(DO_REF_CC) -$(B)/base/vm/ui.qvm: $(UIVMOBJ) $(UIDIR)/ui_syscalls.asm - @echo "Q3ASM $@" - @$(Q3ASM) -o $@ $(UIVMOBJ) $(UIDIR)/ui_syscalls.asm +$(B)/ded/%.o: $(ASMDIR)/%.s + $(DO_AS) + +# k8 so inline assembler knows about SSE +$(B)/ded/%.o: $(ASMDIR)/%.c + $(DO_CC) -march=k8 + +$(B)/ded/%.o: $(SDIR)/%.c + $(DO_DED_CC) + +$(B)/ded/%.o: $(CMDIR)/%.c + $(DO_DED_CC) + +$(B)/ded/%.o: $(ZDIR)/%.c + $(DO_DED_CC) + +$(B)/ded/%.o: $(SYSDIR)/%.c + $(DO_DED_CC) + +$(B)/ded/%.o: $(SYSDIR)/%.m + $(DO_DED_CC) + +$(B)/ded/%.o: $(SYSDIR)/%.rc + $(DO_WINDRES) + +$(B)/ded/%.o: $(NDIR)/%.c + $(DO_DED_CC) + +# Extra dependencies to ensure the git version is incorporated +ifeq ($(USE_GIT),1) + $(B)/client/cl_console.o : .git/index + $(B)/client/common.o : .git/index + $(B)/ded/common.o : .git/index +endif ############################################################################# ## GAME MODULE RULES ############################################################################# -$(B)/base/cgame/%.o: $(CGDIR)/%.c - $(DO_SHLIB_CC) +$(B)/$(BASEGAME)/cgame/bg_%.o: $(GDIR)/bg_%.c + $(DO_CGAME_CC) -$(B)/base/cgame/%.asm: $(CGDIR)/%.c - $(DO_Q3LCC) +$(B)/$(BASEGAME)/cgame/ui_%.o: $(UIDIR)/ui_%.c + $(DO_CGAME_CC) +$(B)/$(BASEGAME)/cgame/%.o: $(CGDIR)/%.c + $(DO_CGAME_CC) -$(B)/base/game/%.o: $(GDIR)/%.c - $(DO_SHLIB_CC) +$(B)/$(BASEGAME)/cgame/bg_%.asm: $(GDIR)/bg_%.c $(Q3LCC) + $(DO_CGAME_Q3LCC) -$(B)/base/game/%.asm: $(GDIR)/%.c - $(DO_Q3LCC) +$(B)/$(BASEGAME)/cgame/ui_%.asm: $(UIDIR)/ui_%.c $(Q3LCC) + $(DO_CGAME_Q3LCC) +$(B)/$(BASEGAME)/cgame/%.asm: $(CGDIR)/%.c $(Q3LCC) + $(DO_CGAME_Q3LCC) -$(B)/base/ui/%.o: $(UIDIR)/%.c - $(DO_SHLIB_CC) -$(B)/base/ui/%.asm: $(UIDIR)/%.c - $(DO_Q3LCC) +$(B)/$(BASEGAME)/game/%.o: $(GDIR)/%.c + $(DO_GAME_CC) + +$(B)/$(BASEGAME)/game/%.asm: $(GDIR)/%.c $(Q3LCC) + $(DO_GAME_Q3LCC) + + +$(B)/$(BASEGAME)/ui/bg_%.o: $(GDIR)/bg_%.c + $(DO_UI_CC) +$(B)/$(BASEGAME)/ui/%.o: $(UIDIR)/%.c + $(DO_UI_CC) -$(B)/base/qcommon/%.o: $(CMDIR)/%.c +$(B)/$(BASEGAME)/ui/bg_%.asm: $(GDIR)/bg_%.c $(Q3LCC) + $(DO_UI_Q3LCC) + +$(B)/$(BASEGAME)/ui/%.asm: $(UIDIR)/%.c $(Q3LCC) + $(DO_UI_Q3LCC) + + +$(B)/$(BASEGAME)/qcommon/%.o: $(CMDIR)/%.c $(DO_SHLIB_CC) -$(B)/base/qcommon/%.asm: $(CMDIR)/%.c +$(B)/$(BASEGAME)/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) $(DO_Q3LCC) @@ -999,15 +2391,14 @@ $(B)/base/qcommon/%.asm: $(CMDIR)/%.c # MISC ############################################################################# -clean: clean-debug clean-release - @$(MAKE) clean2 +OBJ = $(Q3OBJ) $(Q3ROBJ) $(Q3R2OBJ) $(Q3DOBJ) $(JPGOBJ) \ + $(GOBJ) $(CGOBJ) $(UIOBJ) \ + $(GVMOBJ) $(CGVMOBJ) $(UIVMOBJ) +TOOLSOBJ = $(LBURGOBJ) $(Q3CPPOBJ) $(Q3RCCOBJ) $(Q3LCCOBJ) $(Q3ASMOBJ) +STRINGOBJ = $(Q3R2STRINGOBJ) -clean2: - @echo "CLEAN $(B)" - @if [ -d $(B) ];then (find $(B) -name '*.d' -exec rm {} \;)fi - @rm -f $(GOBJ) $(CGOBJ) $(UIOBJ) \ - $(GVMOBJ) $(CGVMOBJ) $(UIVMOBJ) - @rm -f $(TARGETS) +clean: clean-debug clean-release + @$(MAKE) -C $(MASTERDIR) clean clean-debug: @$(MAKE) clean2 B=$(BD) @@ -1015,29 +2406,50 @@ clean-debug: clean-release: @$(MAKE) clean2 B=$(BR) -toolsclean: - @$(MAKE) -C $(TOOLSDIR)/asm clean uninstall - @$(MAKE) -C $(TOOLSDIR)/lcc clean uninstall +clean2: + @echo "CLEAN $(B)" + @rm -f $(OBJ) + @rm -f $(OBJ_D_FILES) + @rm -f $(STRINGOBJ) + @rm -f $(TARGETS) + +toolsclean: toolsclean-debug toolsclean-release + +toolsclean-debug: + @$(MAKE) toolsclean2 B=$(BD) + +toolsclean-release: + @$(MAKE) toolsclean2 B=$(BR) + +toolsclean2: + @echo "TOOLS_CLEAN $(B)" + @rm -f $(TOOLSOBJ) + @rm -f $(TOOLSOBJ_D_FILES) + @rm -f $(LBURG) $(DAGCHECK_C) $(Q3RCC) $(Q3CPP) $(Q3LCC) $(Q3ASM) distclean: clean toolsclean @rm -rf $(BUILD_DIR) dist: - rm -rf tremulous-$(SVN_VERSION) - svn export . tremulous-$(SVN_VERSION) - tar --owner=root --group=root --force-local -cjf tremulous-$(SVN_VERSION).tar.bz2 tremulous-$(SVN_VERSION) - rm -rf tremulous-$(SVN_VERSION) + git archive --format zip --output $(CLIENTBIN)-$(VERSION).zip HEAD ############################################################################# # DEPENDENCIES ############################################################################# -D_FILES=$(shell find . -name '*.d') - -ifneq ($(strip $(D_FILES)),) - include $(D_FILES) +ifneq ($(B),) + OBJ_D_FILES=$(filter %.d,$(OBJ:%.o=%.d)) + TOOLSOBJ_D_FILES=$(filter %.d,$(TOOLSOBJ:%.o=%.d)) + -include $(OBJ_D_FILES) $(TOOLSOBJ_D_FILES) endif -.PHONY: all clean clean2 clean-debug clean-release \ - debug default dist distclean makedirs release \ - targets tools toolsclean +.PHONY: all clean clean2 clean-debug clean-release copyfiles \ + debug default dist distclean makedirs \ + release targets \ + toolsclean toolsclean2 toolsclean-debug toolsclean-release \ + $(OBJ_D_FILES) $(TOOLSOBJ_D_FILES) + +# If the target name contains "clean", don't do a parallel build +ifneq ($(findstring clean, $(MAKECMDGOALS)),) +.NOTPARALLEL: +endif -- cgit