From: nikoli Date: Wed, 24 Jul 2013 16:27:58 +0000 (+0000) Subject: Update build system, fix and enable ODE by default X-Git-Tag: xonotic-v0.8.0~159 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=994497d01400c33f5a6425426965d35d0c49bdbc;p=xonotic%2Fdarkplaces.git Update build system, fix and enable ODE by default Fixed crash when running in Hardened Gentoo with libode installed. Fixed building and running with USEODE disabled. Use same LINK_TO_NAME, LIB_NAME, CFLAGS_NAME style for dependencies. Link to libz and libode by default. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11979 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=7df12163f2fe3193d5709ae8172eeaa5e92933b5 --- diff --git a/BSDmakefile b/BSDmakefile index ac9793a0..8293e46c 100644 --- a/BSDmakefile +++ b/BSDmakefile @@ -50,10 +50,38 @@ EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ) EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ) EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ) -# libjpeg dependency (set these to "" if you want to use dynamic loading instead) +# set these to "" if you want to use dynamic loading instead +# zlib +CFLAGS_LIBZ=-DLINK_TO_ZLIB +LIB_Z=-lz + +# jpeg CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG LIB_JPEG=-ljpeg +# ode +ODE_CONFIG?=ode-config +LIB_ODE=`$(ODE_CONFIG) --libs` +CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE + +# d0_blind_id +# most distros do not have d0_blind_id package, dlopen will used by default +# LIB_CRYPTO=-ld0_blind_id +# CFLAGS_CRYPTO=-DLINK_TO_CRYPTO +# LIB_CRYPTO_RIJNDAEL=-ld0_rijndael +# CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL +LIB_CRYPTO= +CFLAGS_CRYPTO= +LIB_CRYPTO_RIJNDAEL= +CFLAGS_CRYPTO_RIJNDAEL= + +# modplug +# now ogg is mostly used, modplug is required rarely, keep it dlopen by default +# LIB_SND_MODPLUG=-lmodplug +# CFLAGS_SND_MODPLUG=-DLINK_TO_LIBMODPLUG +LIB_SND_MODPLUG= +CFLAGS_SND_MODPLUG= + .endif diff --git a/crypto.c b/crypto.c index a681379c..2baa5a97 100644 --- a/crypto.c +++ b/crypto.c @@ -102,7 +102,7 @@ static size_t Crypto_UnParsePack(char *buf, size_t len, unsigned long header, co #define USE_AES -#ifdef CRYPTO_STATIC +#ifdef LINK_TO_CRYPTO #include @@ -285,7 +285,7 @@ static void Crypto_CloseLibrary (void) #endif -#ifdef CRYPTO_RIJNDAEL_STATIC +#ifdef LINK_TO_CRYPTO_RIJNDAEL #include diff --git a/makefile b/makefile index 35de3283..920a9e84 100644 --- a/makefile +++ b/makefile @@ -78,9 +78,7 @@ ifeq ($(DP_MAKE_TARGET), linux) EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ) EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ) - # libjpeg dependency (set these to "" if you want to use dynamic loading instead) - CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG - LIB_JPEG=-ljpeg + DP_LINK_LIBS=shared endif # Mac OS X configuration @@ -111,10 +109,7 @@ ifeq ($(DP_MAKE_TARGET), macosx) CFLAGS_MAKEDEP= endif - # libjpeg dependency (set these to "" if you want to use dynamic loading instead) - # we don't currently link to libjpeg on Mac because the OS does not have an easy way to load libjpeg and we provide our own in the .app - CFLAGS_LIBJPEG= - LIB_JPEG= + DP_LINK_LIBS=dlopen # on OS X, we don't build the CL by default because it uses deprecated # and not-implemented-in-64bit Carbon @@ -151,9 +146,7 @@ ifeq ($(DP_MAKE_TARGET), sunos) EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ) EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ) - # libjpeg dependency (set these to "" if you want to use dynamic loading instead) - CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG - LIB_JPEG=-ljpeg + DP_LINK_LIBS=shared endif # BSD configuration @@ -184,9 +177,7 @@ endif EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ) EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ) - # libjpeg dependency (set these to "" if you want to use dynamic loading instead) - CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG - LIB_JPEG=-ljpeg + DP_LINK_LIBS=shared endif # Win32 configuration @@ -241,10 +232,58 @@ ifeq ($(DP_MAKE_TARGET), mingw) EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ) EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ) - # libjpeg dependency (set these to "" if you want to use dynamic loading instead) + DP_LINK_LIBS=shared +endif + +# set these to "" if you want to use dynamic loading instead +# zlib +ifeq ($(DP_LINK_LIBS), shared) + CFLAGS_LIBZ=-DLINK_TO_ZLIB + LIB_Z=-lz +endif +ifeq ($(DP_LINK_LIBS), dlopen) + CFLAGS_LIBZ= + LIB_Z= +endif + +# jpeg +ifeq ($(DP_LINK_LIBS), shared) CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG LIB_JPEG=-ljpeg endif +ifeq ($(DP_LINK_LIBS), dlopen) + CFLAGS_LIBJPEG= + LIB_JPEG= +endif + +# ode +ifeq ($(DP_LINK_LIBS), shared) + ODE_CONFIG?=ode-config + LIB_ODE=`$(ODE_CONFIG) --libs` + CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE +endif +ifeq ($(DP_LINK_LIBS), dlopen) + LIB_ODE= + CFLAGS_ODE=-DUSEODE +endif + +# d0_blind_id +# most distros do not have d0_blind_id package, dlopen will used by default +# LIB_CRYPTO=-ld0_blind_id +# CFLAGS_CRYPTO=-DLINK_TO_CRYPTO +# LIB_CRYPTO_RIJNDAEL=-ld0_rijndael +# CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL +LIB_CRYPTO= +CFLAGS_CRYPTO= +LIB_CRYPTO_RIJNDAEL= +CFLAGS_CRYPTO_RIJNDAEL= + +# modplug +# now ogg is mostly used, modplug is required rarely, keep it dlopen by default +# LIB_SND_MODPLUG=-lmodplug +# CFLAGS_SND_MODPLUG=-DLINK_TO_LIBMODPLUG +LIB_SND_MODPLUG= +CFLAGS_SND_MODPLUG= ##### Sound configuration ##### diff --git a/makefile.inc b/makefile.inc index be52ef6b..72d1856a 100644 --- a/makefile.inc +++ b/makefile.inc @@ -25,11 +25,6 @@ CC?=gcc CPUOPTIMIZATIONS?=-fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag -# Additional stuff for libode -LIB_ODE=`[ -n "$(DP_ODE_STATIC_LIBDIR)" ] && "$(DP_ODE_STATIC_LIBDIR)/../bin/ode-config" --libs` `[ -n "$(DP_ODE_STATIC_LIBDIR)" ] && echo -lstdc++` -CFLAGS_ODE=`[ -n "$(DP_ODE_STATIC_LIBDIR)" ] && "$(DP_ODE_STATIC_LIBDIR)/../bin/ode-config" --cflags || { [ -n "$(DP_ODE_DYNAMIC)" ] && echo \ -DODE_DYNAMIC; }` `[ -n "$(DP_ODE_STATIC_LIBDIR)" ] && echo -DODE_STATIC` - - SDL_CONFIG?=sdl-config SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags` SDLCONFIG_UNIXCFLAGS_X11?= @@ -47,17 +42,6 @@ STRIP?=strip OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o snd_modplug.o -# statically loading d0_blind_id -LIB_CRYPTO=`[ -n "$(DP_CRYPTO_STATIC_LIBDIR)" ] && echo \ $(DP_CRYPTO_STATIC_LIBDIR)/libd0_blind_id.a` -LIB_GMP=`[ -n "$(DP_CRYPTO_STATIC_LIBDIR)" ] && { [ -n "$(DP_GMP_STATIC_LIBDIR)" ] && echo \ $(DP_GMP_STATIC_LIBDIR)/libgmp.a || echo \ -lgmp; }` -CFLAGS_CRYPTO=`[ -n "$(DP_CRYPTO_STATIC_LIBDIR)" ] && echo \ -I$(DP_CRYPTO_STATIC_LIBDIR)/../include\ -DCRYPTO_STATIC` -LIB_CRYPTO_RIJNDAEL=`[ -n "$(DP_CRYPTO_RIJNDAEL_STATIC_LIBDIR)" ] && echo \ $(DP_CRYPTO_RIJNDAEL_STATIC_LIBDIR)/libd0_rijndael.a` -CFLAGS_CRYPTO_RIJNDAEL=`[ -n "$(DP_CRYPTO_RIJNDAEL_STATIC_LIBDIR)" ] && echo \ -I$(DP_CRYPTO_RIJNDAEL_STATIC_LIBDIR)/../include\ -DCRYPTO_RIJNDAEL_STATIC` - -# Additional stuff for libmodplug -LIB_SND_MODPLUG=`[ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ] && echo \ $(DP_MODPLUG_STATIC_LIBDIR)/libmodplug.a\ -lstdc++` -CFLAGS_SND_MODPLUG=`[ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ] && echo \ -I$(DP_MODPLUG_STATIC_LIBDIR)/../include\ -DSND_MODPLUG_STATIC` - # No sound OBJ_SND_NULL=snd_null.o LIB_SND_NULL= @@ -187,7 +171,7 @@ OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o thread_sdl.o $(OBJ_SND_COMMON) snd_sdl. # Compilation -CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBJPEG) $(CFLAGS_D3D) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES +CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBZ) $(CFLAGS_LIBJPEG) $(CFLAGS_D3D) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES CFLAGS_DEBUG=-ggdb CFLAGS_PROFILE=-g -pg -ggdb -fprofile-arcs CFLAGS_RELEASE= @@ -218,7 +202,7 @@ LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`{ test -d .svn && svnversion; } OBJ_GLX= builddate.c sys_linux.o vid_glx.o thread_pthread.o keysym2ucs.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON) -LDFLAGS_UNIXCOMMON=-lm $(LIB_ODE) $(LIB_JPEG) $(LIB_CRYPTO) $(LIB_GMP) $(LIB_CRYPTO_RIJNDAEL) +LDFLAGS_UNIXCOMMON=-lm $(LIB_ODE) $(LIB_Z) $(LIB_JPEG) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm -pthread $(LIB_SOUND) LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl -lmodplug LDFLAGS_UNIXSV_PRELOAD=-lz -ljpeg -lpng -lcurl @@ -303,9 +287,9 @@ OBJ_WGL= builddate.c sys_win.o vid_wgl.o thread_null.o $(OBJ_SND_WIN) $(OBJ_WINC # Link # see LDFLAGS_WINCOMMON in makefile -LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_GMP) $(LIB_CRYPTO_RIJNDAEL) -mwindows -lwinmm -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32 -lws2_32 $(LDFLAGS_D3D) $(LIB_JPEG) -LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_GMP) $(LIB_CRYPTO_RIJNDAEL) -mconsole -lwinmm -lws2_32 $(LIB_JPEG) -LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_GMP) $(LIB_CRYPTO_RIJNDAEL) $(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG) -lwinmm -lws2_32 $(LIB_JPEG) +LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) -mwindows -lwinmm -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32 -lws2_32 $(LDFLAGS_D3D) $(LIB_Z) $(LIB_JPEG) +LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) -mconsole -lwinmm -lws2_32 $(LIB_Z) $(LIB_JPEG) +LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) $(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG) -lwinmm -lws2_32 $(LIB_Z) $(LIB_JPEG) EXE_WINCL=darkplaces.exe EXE_WINSV=darkplaces-dedicated.exe EXE_WINSDL=darkplaces-sdl.exe @@ -490,7 +474,7 @@ snd_modplug.o: snd_modplug.c $(CHECKLEVEL2) $(DO_CC) $(CFLAGS_SND_MODPLUG) -#this checks ODE_DYNAMIC and ODE_STATIC when compiling so it needs the ODE flags as well +#this checks USEODE when compiling so it needs the ODE flags as well prvm_cmds.o: prvm_cmds.c $(CHECKLEVEL2) $(DO_CC) $(CFLAGS_ODE) diff --git a/prvm_cmds.c b/prvm_cmds.c index c9f55279..1c9c8099 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -17,7 +17,9 @@ #include "mdfour.h" extern cvar_t prvm_backtraceforwarnings; +#ifdef USEODE extern dllhandle_t ode_dll; +#endif // LordHavoc: changed this to NOT use a return statement, so that it can be used in functions that must return a value void VM_Warning(prvm_prog_t *prog, const char *fmt, ...) @@ -275,19 +277,21 @@ static qboolean checkextension(prvm_prog_t *prog, const char *name) e++; if ((e - start) == len && !strncasecmp(start, name, len)) { +#ifdef USEODE // special sheck for ODE if (!strncasecmp("DP_PHYSICS_ODE", name, 14)) { -#ifdef ODE_DYNAMIC +#ifndef LINK_TO_LIBODE return ode_dll ? true : false; #else -#ifdef ODE_STATIC +#ifdef LINK_TO_LIBODE return true; #else return false; #endif #endif } +#endif // special sheck for d0_blind_id if (!strcasecmp("DP_CRYPTO", name)) diff --git a/snd_modplug.c b/snd_modplug.c index 52a152a3..fa0e57f5 100644 --- a/snd_modplug.c +++ b/snd_modplug.c @@ -26,7 +26,7 @@ #include "snd_main.h" #include "snd_modplug.h" -#ifdef SND_MODPLUG_STATIC +#ifdef LINK_TO_LIBMODPLUG #include qboolean ModPlug_OpenLibrary (void) @@ -252,7 +252,7 @@ static void ModPlug_GetSamplesFloat(channel_t *ch, sfx_t *sfx, int firstsamplefr return; } -#ifndef SND_MODPLUG_STATIC +#ifndef LINK_TO_LIBMODPLUG if(qModPlug_SetMasterVolume) #endif qModPlug_SetMasterVolume(per_ch->mf, 512); // max volume, DP scales down! @@ -412,7 +412,7 @@ qboolean ModPlug_LoadModPlugFile (const char *filename, sfx_t *sfx) return false; } -#ifndef SND_MODPLUG_STATIC +#ifndef LINK_TO_LIBMODPLUG if(qModPlug_SetMasterVolume) #endif qModPlug_SetMasterVolume(mf, 512); // max volume, DP scales down! diff --git a/world.c b/world.c index abacf51d..4fe5fcf5 100644 --- a/world.c +++ b/world.c @@ -365,7 +365,7 @@ cvar_t physics_ode = {0, "physics_ode", "0", "run ODE physics (VERY experimental // LordHavoc: this large chunk of definitions comes from the ODE library // include files. -#ifdef ODE_STATIC +#ifdef LINK_TO_LIBODE #include "ode/ode.h" #else #ifdef WINAPI @@ -1470,7 +1470,7 @@ dllhandle_t ode_dll = NULL; static void World_Physics_Init(void) { #ifdef USEODE -#ifdef ODE_DYNAMIC +#ifndef LINK_TO_LIBODE const char* dllnames [] = { # if defined(WIN32) @@ -1520,14 +1520,14 @@ static void World_Physics_Init(void) Cvar_RegisterVariable(&physics_ode_allowconvex); Cvar_RegisterVariable(&physics_ode); -#ifdef ODE_DYNAMIC +#ifndef LINK_TO_LIBODE // Load the DLL if (Sys_LoadLibrary (dllnames, &ode_dll, odefuncs)) #endif { dInitODE(); // dInitODE2(0); -#ifdef ODE_DYNAMIC +#ifndef LINK_TO_LIBODE # ifdef dSINGLE if (!dCheckConfiguration("ODE_single_precision")) # else @@ -1559,12 +1559,12 @@ static void World_Physics_Init(void) static void World_Physics_Shutdown(void) { #ifdef USEODE -#ifdef ODE_DYNAMIC +#ifndef LINK_TO_LIBODE if (ode_dll) #endif { dCloseODE(); -#ifdef ODE_DYNAMIC +#ifndef LINK_TO_LIBODE Sys_UnloadLibrary(&ode_dll); ode_dll = NULL; #endif @@ -1616,7 +1616,7 @@ static void World_Physics_EnableODE(world_t *world) dVector3 center, extents; if (world->physics.ode) return; -#ifdef ODE_DYNAMIC +#ifndef LINK_TO_LIBODE if (!ode_dll) return; #endif @@ -1722,9 +1722,9 @@ void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed) void World_Physics_ApplyCmd(prvm_edict_t *ed, edict_odefunc_t *f) { +#ifdef USEODE dBodyID body = (dBodyID)ed->priv.server->ode_body; -#ifdef USEODE switch(f->type) { case ODEFUNC_ENABLE: @@ -2160,7 +2160,7 @@ static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed) qboolean *mapped, *used, convex_compatible; int numplanes = 0, numpoints = 0, i; -#ifdef ODE_DYNAMIC +#ifndef LINK_TO_LIBODE if (!ode_dll) return; #endif @@ -3013,10 +3013,10 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2) void World_Physics_Frame(world_t *world, double frametime, double gravity) { prvm_prog_t *prog = world->prog; +#ifdef USEODE double tdelta, tdelta2, tdelta3, simulationtime, collisiontime; tdelta = Sys_DirtyTime(); -#ifdef USEODE if (world->physics.ode && physics_ode.integer) { int i; diff --git a/world.h b/world.h index 18e9b001..e43ebd14 100644 --- a/world.h +++ b/world.h @@ -119,15 +119,6 @@ int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, in void World_Start(world_t *world); void World_End(world_t *world); -// physics macros -#ifndef ODE_STATIC -# define ODE_DYNAMIC 1 -#endif - -#if defined(ODE_STATIC) || defined(ODE_DYNAMIC) -# define USEODE 1 -#endif - // update physics // this is called by SV_Physics void World_Physics_Frame(world_t *world, double frametime, double gravity);