From 79670de4d78c6b6cd1e449aad985ac8dc4438b4e Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Thu, 18 Jun 2015 14:16:53 +0200 Subject: use system libraries more properly; introduce a dependency on Minizip remove the USE_LOCAL_HEADERS option (it was broken anyway) --- GNUmakefile | 97 +++++++++++++++++++-------------------- src/client/cl_curl.h | 6 +-- src/client/qal.h | 15 +----- src/qcommon/files.c | 2 +- src/renderercommon/qgl.h | 6 +-- src/renderercommon/tr_image_jpg.c | 4 -- src/renderergl2/tr_extensions.c | 6 +-- src/sdl/sdl_gamma.c | 6 +-- src/sdl/sdl_glimp.c | 6 +-- src/sdl/sdl_input.c | 6 +-- src/sdl/sdl_snd.c | 6 +-- src/sys/sys_loadlib.h | 9 +--- src/sys/sys_main.c | 9 +--- 13 files changed, 60 insertions(+), 118 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 0a888d1c..f432cc88 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -210,12 +210,12 @@ ifndef USE_INTERNAL_ZLIB USE_INTERNAL_ZLIB=$(USE_INTERNAL_LIBS) endif -ifndef USE_INTERNAL_JPEG -USE_INTERNAL_JPEG=$(USE_INTERNAL_LIBS) +ifndef USE_INTERNAL_MINIZIP +USE_INTERNAL_MINIZIP=$(USE_INTERNAL_LIBS) endif -ifndef USE_LOCAL_HEADERS -USE_LOCAL_HEADERS=$(USE_INTERNAL_LIBS) +ifndef USE_INTERNAL_JPEG +USE_INTERNAL_JPEG=$(USE_INTERNAL_LIBS) endif ifndef BUILD_MASTER_SERVER @@ -254,6 +254,7 @@ VORBISDIR=$(MOUNT_DIR)/libvorbis-1.3.4 OPUSDIR=$(MOUNT_DIR)/opus-1.1 OPUSFILEDIR=$(MOUNT_DIR)/opusfile-0.5 ZDIR=$(MOUNT_DIR)/zlib +MINIZIPDIR=$(DEP_DIR)/minizip Q3ASMDIR=$(MOUNT_DIR)/tools/asm LBURGDIR=$(MOUNT_DIR)/tools/lcc/lburg Q3CPPDIR=$(MOUNT_DIR)/tools/lcc/cpp @@ -365,6 +366,7 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu") RENDERER_LIBS = $(SDL_LIBS) -lGL ifeq ($(USE_OPENAL),1) + CLIENT_CFLAGS += $(OPENAL_CFLAGS) ifneq ($(USE_OPENAL_DLOPEN),1) CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) endif @@ -448,6 +450,7 @@ ifeq ($(PLATFORM),darwin) BASE_CFLAGS += -fno-strict-aliasing -DMACOS_X -fno-common -pipe ifeq ($(USE_OPENAL),1) + CLIENT_CFLAGS += $(OPENAL_CFLAGS) ifneq ($(USE_OPENAL_DLOPEN),1) CLIENT_LIBS += -framework OpenAL endif @@ -462,10 +465,6 @@ ifeq ($(PLATFORM),darwin) BASE_CFLAGS += -D_THREAD_SAFE=1 - ifeq ($(USE_LOCAL_HEADERS),1) - BASE_CFLAGS += -I$(SDLHDIR)/include - endif - # 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 @@ -543,7 +542,7 @@ ifdef MINGW ifeq ($(USE_OPENAL),1) CLIENT_CFLAGS += $(OPENAL_CFLAGS) ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LDFLAGS += $(OPENAL_LDFLAGS) + CLIENT_LDFLAGS += $(OPENAL_LIBS) endif endif @@ -588,16 +587,7 @@ ifdef MINGW ifeq ($(USE_CURL),1) CLIENT_CFLAGS += $(CURL_CFLAGS) ifneq ($(USE_CURL_DLOPEN),1) - 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 + CLIENT_LIBS += $(CURL_LIBS) endif endif @@ -612,29 +602,9 @@ ifdef MINGW 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 + CLIENT_CFLAGS += $(SDL_CFLAGS) + CLIENT_LIBS += $(SDL_LIBS) + RENDERER_LIBS += $(SDL_LIBS) else # ifdef MINGW @@ -669,6 +639,7 @@ ifeq ($(PLATFORM),freebsd) # optional features/libraries ifeq ($(USE_OPENAL),1) + CLIENT_CFLAGS += $(OPENAL_CFLAGS) ifeq ($(USE_OPENAL_DLOPEN),1) CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) endif @@ -759,6 +730,7 @@ ifeq ($(PLATFORM),openbsd) RENDERER_LIBS = $(SDL_LIBS) -lGL ifeq ($(USE_OPENAL),1) + CLIENT_CFLAGS += $(OPENAL_CFLAGS) ifneq ($(USE_OPENAL_DLOPEN),1) CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) endif @@ -918,11 +890,22 @@ ifndef SHLIBNAME SHLIBNAME=$(ARCH).$(SHLIBEXT) endif +ifeq ($(USE_INTERNAL_MINIZIP),1) + MINIZIP_CFLAGS ?= -I$(MINIZIPDIR) +else + MINIZIP_CFLAGS ?= $(shell pkg-config --silence-errors --cflags minizip) + MINIZIP_LIBS ?= $(shell pkg-config --silence-errors --libs minizip) +endif + ifneq ($(BUILD_SERVER),0) + SERVER_CFLAGS += $(MINIZIP_CFLAGS) + SERVER_LIBS += $(MINIZIP_LIBS) TARGETS += $(B)/$(OUT)/$(SERVERBIN)$(FULLBINEXT) endif ifneq ($(BUILD_CLIENT),0) + CLIENT_CFLAGS += $(MINIZIP_CFLAGS) + CLIENT_LIBS += $(MINIZIP_LIBS) ifneq ($(USE_RENDERER_DLOPEN),0) TARGETS += $(B)/$(OUT)/$(CLIENTBIN)$(FULLBINEXT) $(B)/$(OUT)/renderer_opengl1_$(SHLIBNAME) ifneq ($(BUILD_RENDERER_OPENGL2),0) @@ -1058,10 +1041,6 @@ ifdef DEFAULT_BASEDIR BASE_CFLAGS += -DDEFAULT_BASEDIR=\\\"$(DEFAULT_BASEDIR)\\\" endif -ifeq ($(USE_LOCAL_HEADERS),1) - BASE_CFLAGS += -DUSE_LOCAL_HEADERS -endif - ifeq ($(BUILD_STANDALONE),1) BASE_CFLAGS += -DSTANDALONE endif @@ -1278,12 +1257,14 @@ makedirs: @if [ ! -d $(BUILD_DIR) ];then $(MKDIR) $(BUILD_DIR);fi @if [ ! -d $(B) ];then $(MKDIR) $(B);fi @if [ ! -d $(B)/client ];then $(MKDIR) $(B)/client;fi + @if [ ! -d $(B)/client/minizip ];then $(MKDIR) $(B)/client/minizip;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)/ded/minizip ];then $(MKDIR) $(B)/ded/minizip;fi @if [ ! -d $(B)/cgame ];then $(MKDIR) $(B)/cgame;fi @if [ ! -d $(B)/game ];then $(MKDIR) $(B)/game;fi @if [ ! -d $(B)/ui ];then $(MKDIR) $(B)/ui;fi @@ -1519,8 +1500,6 @@ Q3OBJ = \ $(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 \ @@ -1919,6 +1898,12 @@ Q3OBJ += \ $(B)/client/zutil.o endif +ifeq ($(USE_INTERNAL_MINIZIP),1) +Q3OBJ += \ + $(B)/client/minizip/ioapi.o \ + $(B)/client/minizip/unzip.o +endif + ifeq ($(HAVE_VM_COMPILED),true) ifneq ($(findstring $(ARCH),x86 x86_64),) Q3OBJ += \ @@ -2024,8 +2009,6 @@ Q3DOBJ = \ $(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 \ \ @@ -2058,6 +2041,12 @@ Q3DOBJ += \ $(B)/ded/zutil.o endif +ifeq ($(USE_INTERNAL_MINIZIP),1) + Q3DOBJ += \ + $(B)/ded/minizip/ioapi.o \ + $(B)/ded/minizip/unzip.o +endif + ifeq ($(HAVE_VM_COMPILED),true) ifneq ($(findstring $(ARCH),x86 x86_64),) Q3DOBJ += \ @@ -2089,7 +2078,7 @@ endif $(B)/$(OUT)/$(SERVERBIN)$(FULLBINEXT): $(Q3DOBJ) $(echo_cmd) "LD $@" - $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(Q3DOBJ) $(LIBS) + $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(Q3DOBJ) $(SERVER_LIBS) $(LIBS) @@ -2250,6 +2239,9 @@ $(B)/client/%.o: $(OGGDIR)/src/%.c $(B)/client/vorbis/%.o: $(VORBISDIR)/lib/%.c $(DO_CC) +$(B)/client/minizip/%.o: $(MINIZIPDIR)/%.c + $(DO_CC) + $(B)/client/opus/%.o: $(OPUSDIR)/src/%.c $(DO_CC) @@ -2337,6 +2329,9 @@ $(B)/ded/%.o: $(SYSDIR)/%.rc $(B)/ded/%.o: $(NDIR)/%.c $(DO_DED_CC) +$(B)/ded/minizip/%.o: $(MINIZIPDIR)/%.c + $(DO_DED_CC) + # Extra dependencies to ensure the git version is incorporated ifeq ($(USE_GIT),1) $(B)/client/cl_console.o : .git/index diff --git a/src/client/cl_curl.h b/src/client/cl_curl.h index 1b3856fc..a66b97e0 100644 --- a/src/client/cl_curl.h +++ b/src/client/cl_curl.h @@ -28,11 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" -#ifdef USE_LOCAL_HEADERS - #include "../libcurl-7.35.0/curl/curl.h" -#else - #include -#endif +#include #ifdef USE_CURL_DLOPEN #ifdef WIN32 diff --git a/src/client/qal.h b/src/client/qal.h index a2b5d247..d5ffd9ab 100644 --- a/src/client/qal.h +++ b/src/client/qal.h @@ -34,19 +34,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define ALC_NO_PROTOTYPES #endif -#ifdef USE_LOCAL_HEADERS -#include "../AL/al.h" -#include "../AL/alc.h" -#else -#ifdef _MSC_VER - // MSVC users must install the OpenAL SDK which doesn't use the AL/*.h scheme. - #include - #include -#else - #include - #include -#endif -#endif +#include +#include /* Hack to enable compiling both on OpenAL SDK and OpenAL-soft. */ #ifndef ALC_ENUMERATE_ALL_EXT diff --git a/src/qcommon/files.c b/src/qcommon/files.c index c4c07242..4edf0318 100644 --- a/src/qcommon/files.c +++ b/src/qcommon/files.c @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "q_shared.h" #include "qcommon.h" -#include "unzip.h" +#include /* ============================================================================= diff --git a/src/renderercommon/qgl.h b/src/renderercommon/qgl.h index bf48cc62..bf4761e2 100644 --- a/src/renderercommon/qgl.h +++ b/src/renderercommon/qgl.h @@ -27,11 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __QGL_H__ #define __QGL_H__ -#ifdef USE_LOCAL_HEADERS -# include "SDL_opengl.h" -#else -# include -#endif +#include extern void (APIENTRYP qglActiveTextureARB) (GLenum texture); extern void (APIENTRYP qglClientActiveTextureARB) (GLenum texture); diff --git a/src/renderercommon/tr_image_jpg.c b/src/renderercommon/tr_image_jpg.c index 3e369c20..41d9d52e 100644 --- a/src/renderercommon/tr_image_jpg.c +++ b/src/renderercommon/tr_image_jpg.c @@ -33,10 +33,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * You may also wish to include "jerror.h". */ -#ifdef USE_INTERNAL_JPEG -# define JPEG_INTERNALS -#endif - #include #ifndef USE_INTERNAL_JPEG diff --git a/src/renderergl2/tr_extensions.c b/src/renderergl2/tr_extensions.c index 2972aaef..cbfd3138 100644 --- a/src/renderergl2/tr_extensions.c +++ b/src/renderergl2/tr_extensions.c @@ -21,11 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // tr_extensions.c - extensions needed by the renderer not in sdl_glimp.c -#ifdef USE_LOCAL_HEADERS -# include "SDL.h" -#else -# include -#endif +#include #include "tr_local.h" #include "tr_dsa.h" diff --git a/src/sdl/sdl_gamma.c b/src/sdl/sdl_gamma.c index 7e030683..0998f93a 100644 --- a/src/sdl/sdl_gamma.c +++ b/src/sdl/sdl_gamma.c @@ -21,11 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#ifdef USE_LOCAL_HEADERS -# include "SDL.h" -#else -# include -#endif +#include #include "../renderercommon/tr_common.h" #include "../qcommon/qcommon.h" diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c index fed3fc5b..cc3e6378 100644 --- a/src/sdl/sdl_glimp.c +++ b/src/sdl/sdl_glimp.c @@ -21,11 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#ifdef USE_LOCAL_HEADERS -# include "SDL.h" -#else -# include -#endif +#include #include #include diff --git a/src/sdl/sdl_input.c b/src/sdl/sdl_input.c index 700834c2..bb6403de 100644 --- a/src/sdl/sdl_input.c +++ b/src/sdl/sdl_input.c @@ -21,11 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#ifdef USE_LOCAL_HEADERS -# include "SDL.h" -#else -# include -#endif +#include #include #include diff --git a/src/sdl/sdl_snd.c b/src/sdl/sdl_snd.c index 9420f0ba..018675d1 100644 --- a/src/sdl/sdl_snd.c +++ b/src/sdl/sdl_snd.c @@ -24,11 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#ifdef USE_LOCAL_HEADERS -# include "SDL.h" -#else -# include -#endif +#include #include "../qcommon/q_shared.h" #include "../client/snd_local.h" diff --git a/src/sys/sys_loadlib.h b/src/sys/sys_loadlib.h index 98d96935..c6b63419 100644 --- a/src/sys/sys_loadlib.h +++ b/src/sys/sys_loadlib.h @@ -36,13 +36,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # define Sys_LibraryError() dlerror() # endif #else -# ifdef USE_LOCAL_HEADERS -# include "SDL.h" -# include "SDL_loadso.h" -# else -# include -# include -# endif +# include +# include # define Sys_LoadLibrary(f) SDL_LoadObject(f) # define Sys_UnloadLibrary(h) SDL_UnloadObject(h) # define Sys_LoadFunction(h,fn) SDL_LoadFunction(h,fn) diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c index 34367ce4..fbb0c5b4 100644 --- a/src/sys/sys_main.c +++ b/src/sys/sys_main.c @@ -33,13 +33,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #ifndef DEDICATED -#ifdef USE_LOCAL_HEADERS -# include "SDL.h" -# include "SDL_cpuinfo.h" -#else -# include -# include -#endif +#include +#include #endif #include "sys_local.h" -- cgit