CFLAGS_FS=
.endif
+CFLAGS_PRELOAD=
+.ifdef DP_PRELOAD_DEPENDENCIES
+LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
+LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
+LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
+CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
+.endif
+
##### BSD Make specific definitions #####
EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
endif
-
##### Sound configuration #####
ifndef DP_SOUND_API
CFLAGS_FS=
endif
+CFLAGS_PRELOAD=
+ifneq ($(DP_MAKE_TARGET), mingw)
+ifdef DP_PRELOAD_DEPENDENCIES
+# DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
+# dynamically so they won't get loaded at runtime using dlopen
+ LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
+ LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
+ LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
+ CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
+endif
+endif
##### GNU Make specific definitions #####
# Compilation
-CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_FS) -Wall -Wsign-compare -Wdeclaration-after-statement
+CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) -Wall -Wsign-compare -Wdeclaration-after-statement
CFLAGS_DEBUG=-ggdb
CFLAGS_PROFILE=-g -pg -ggdb
CFLAGS_RELEASE=
LDFLAGS_UNIXCOMMON=-lm
LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
+LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -lvorbis -lvorbisfile -lcurl
+LDFLAGS_UNIXSV_PRELOAD=-lz -lcurl
+LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -lvorbis -lvorbisfile -lcurl
+CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
LDFLAGS_UNIXSDL=`$(SDL_CONFIG) --libs`
EXE_UNIXCL=darkplaces-glx
-
#include "quakedef.h"
# include <time.h>
#ifndef WIN32
if (handle == NULL)
return false;
+#ifndef WIN32
+#ifdef PREFER_PRELOAD
+ dllhandle = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);
+ if(dllhandle)
+ {
+ for (func = fcts; func && func->name != NULL; func++)
+ if (!(*func->funcvariable = (void *) Sys_GetProcAddress (dllhandle, func->name)))
+ {
+ dlclose(dllhandle);
+ goto notfound;
+ }
+ Con_Printf ("All of %s's functions were already linked in! Not loading dynamically...\n", dllnames[0]);
+ *handle = dllhandle;
+ return true;
+ }
+notfound:
+#endif
+#endif
+
// Initializations
for (func = fcts; func && func->name != NULL; func++)
*func->funcvariable = NULL;