--- a/Makefile +++ b/Makefile @@ -74,35 +74,46 @@ endif CC=gcc +ifndef OPT_CFLAGS ifeq ($(ARCH),axp) -RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \ +OPT_CFLAGS=-ffast-math -funroll-loops \ -fomit-frame-pointer -fexpensive-optimizations endif ifeq ($(ARCH),ppc) -RELEASE_CFLAGS=$(BASE_CFLAGS) -O2 -ffast-math -funroll-loops \ +OPT_CFLAGS=-O2 -ffast-math -funroll-loops \ -fomit-frame-pointer -fexpensive-optimizations endif ifeq ($(ARCH),sparc) -RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \ +OPT_CFLAGS=-ffast-math -funroll-loops \ -fomit-frame-pointer -fexpensive-optimizations endif ifeq ($(ARCH),i386) -RELEASE_CFLAGS=$(BASE_CFLAGS) -O2 -ffast-math -funroll-loops -falign-loops=2 \ +OPT_CFLAGS=-O2 -ffast-math -funroll-loops -falign-loops=2 \ -falign-jumps=2 -falign-functions=2 -fno-strict-aliasing # compiler bugs with gcc 2.96 and 3.0.1 can cause bad builds with heavy opts. -#RELEASE_CFLAGS=$(BASE_CFLAGS) -O6 -m486 -ffast-math -funroll-loops \ +#OPT_CFLAGS=-O6 -m486 -ffast-math -funroll-loops \ # -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \ # -malign-jumps=2 -malign-functions=2 endif ifeq ($(ARCH),x86_64) _LIB := 64 -RELEASE_CFLAGS=$(BASE_CFLAGS) -O2 -ffast-math -funroll-loops \ +OPT_CFLAGS=-O2 -ffast-math -funroll-loops \ -fomit-frame-pointer -fexpensive-optimizations -fno-strict-aliasing endif +endif +RELEASE_CFLAGS=$(BASE_CFLAGS) $(OPT_CFLAGS) + +ifeq ($(ADDCFLAGS),debug) +CFLAGS=$(DEBUG_CFLAGS) -DLINUX_VERSION=\"$(VERSION) Debug\" +endif + +ifeq ($(ADDCFLAGS),release) +CFLAGS=$(RELEASE_CFLAGS) -DLINUX_VERSION=\"$(VERSION)\" +endif VERSION=3.21+r0.16 @@ -133,6 +136,13 @@ else NET_UDP=net_udp endif +ifdef DEFAULT_BASEDIR +BASE_CFLAGS += -DDEFAULT_BASEDIR=\"$(DEFAULT_BASEDIR)\" +endif +ifdef DEFAULT_LIBDIR +BASE_CFLAGS += -DDEFAULT_LIBDIR=\"$(DEFAULT_LIBDIR)\" +endif + ifeq ($(strip $(BUILD_QMAX)),YES) BASE_CFLAGS+=-DQMAX endif @@ -406,7 +424,7 @@ $(BUILD_DEBUG_DIR)/ctf \ $(BUILD_DEBUG_DIR)/xatrix \ $(BUILD_DEBUG_DIR)/rogue - $(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) CFLAGS="$(DEBUG_CFLAGS) -DLINUX_VERSION='\"$(VERSION) Debug\"'" + $(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) ADDCFLAGS=debug build_release: @-mkdir -p $(BUILD_RELEASE_DIR) \ @@ -418,7 +436,7 @@ $(BUILD_RELEASE_DIR)/ctf \ $(BUILD_RELEASE_DIR)/xatrix \ $(BUILD_RELEASE_DIR)/rogue - $(MAKE) targets BUILDDIR=$(BUILD_RELEASE_DIR) CFLAGS="$(RELEASE_CFLAGS) -DLINUX_VERSION='\"$(VERSION)\"'" + $(MAKE) targets BUILDDIR=$(BUILD_RELEASE_DIR) ADDCFLAGS=release targets: $(TARGETS) --- a/src/linux/qgl_linux.c +++ b/src/linux/qgl_linux.c @@ -3006,13 +3006,17 @@ qboolean QGL_Init( const char *dllname ) // dllname, dlerror()); // try basedir next - path = ri.Cvar_Get ("basedir", ".", CVAR_NOSET)->string; + path = ri.Cvar_Get ("basedir", DEFAULT_BASEDIR, CVAR_NOSET)->string; snprintf (fn, MAX_OSPATH, "%s/%s", path, dllname ); if ( ( glw_state.OpenGLLib = dlopen( fn, RTLD_LAZY ) ) == 0 ) { - ri.Con_Printf( PRINT_ALL, "%s\n", dlerror() ); - return false; + path = ri.Cvar_Get ("libdir", DEFAULT_LIBDIR, CVAR_NOSET)->string; + snprintf (fn, MAX_OSPATH, "%s/%s", path, dllname ); + if ( ( glw_state.OpenGLLib = dlopen( fn, RTLD_LAZY ) ) == 0 ) { + ri.Con_Printf( PRINT_ALL, "%s\n", dlerror() ); + return false; + } } Com_Printf ("Using %s for OpenGL...", fn); } else { --- a/src/linux/vid_so.c +++ b/src/linux/vid_so.c @@ -237,13 +237,17 @@ qboolean VID_LoadRefresh( char *name ) //regain root seteuid(saved_euid); - path = Cvar_Get ("basedir", ".", CVAR_NOSET)->string; + path = Cvar_Get ("basedir", DEFAULT_BASEDIR, CVAR_NOSET)->string; snprintf (fn, MAX_OSPATH, "%s/%s", path, name ); if (stat(fn, &st) == -1) { - Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name, strerror(errno)); - return false; + path = Cvar_Get ("libdir", DEFAULT_LIBDIR, CVAR_NOSET)->string; + snprintf (fn, MAX_OSPATH, "%s/%s", path, name ); + if (stat(fn, &st) == -1) { + Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name, strerror(errno)); + return false; + } } // permission checking @@ -493,13 +497,19 @@ qboolean VID_CheckRefExists (const char char *path; struct stat st; - path = Cvar_Get ("basedir", ".", CVAR_NOSET)->string; + path = Cvar_Get ("libdir", DEFAULT_LIBDIR, CVAR_NOSET)->string; snprintf (fn, MAX_OSPATH, "%s/ref_%s.so", path, ref ); if (stat(fn, &st) == 0) return true; - else - return false; + else { + path = Cvar_Get ("basedir", DEFAULT_BASEDIR, CVAR_NOSET)->string; + snprintf (fn, MAX_OSPATH, "%s/ref_%s.so", path, ref ); + if (stat(fn, &st) == 0) + return true; + else + return false; + } } /*****************************************************************************/ --- a/src/qcommon/files.c +++ b/src/qcommon/files.c @@ -60,6 +60,7 @@ typedef struct pack_s char fs_gamedir[MAX_OSPATH]; cvar_t *fs_basedir; +cvar_t *fs_libdir; cvar_t *fs_cddir; cvar_t *fs_gamedirvar; @@ -681,6 +682,7 @@ void FS_SetGamedir (char *dir) if (fs_cddir->string[0]) FS_AddGameDirectory (va("%s/%s", fs_cddir->string, dir) ); FS_AddGameDirectory (va("%s/%s", fs_basedir->string, dir) ); + FS_AddGameDirectory (va("%s/%s", fs_libdir->string, dir) ); FS_AddHomeAsGameDirectory(dir); } } @@ -898,7 +900,13 @@ void FS_InitFilesystem (void) // basedir // allows the game to run from outside the data tree // - fs_basedir = Cvar_Get ("basedir", ".", CVAR_NOSET); + fs_basedir = Cvar_Get ("basedir", DEFAULT_BASEDIR, CVAR_NOSET); + + // + // libdir + // allows the game to store binary files (not data) in a sep tree + // + fs_libdir = Cvar_Get ("libdir", DEFAULT_LIBDIR, CVAR_NOSET); // // cddir @@ -913,6 +921,7 @@ void FS_InitFilesystem (void) // add baseq2 to search path // FS_AddGameDirectory (va("%s/"BASEDIRNAME, fs_basedir->string) ); + FS_AddGameDirectory (va("%s/"BASEDIRNAME, fs_libdir->string) ); // // then add a '.quake2/baseq2' directory in home directory by default --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -74,6 +74,13 @@ Foundation, Inc., 59 Temple Place - Suit #endif +#ifndef DEFAULT_BASEDIR +# define DEFAULT_BASEDIR "." +#endif +#ifndef DEFAULT_LIBDIR +# define DEFAULT_LIBDIR DEFAULT_BASEDIR +#endif + //============================================================================ typedef struct sizebuf_s