1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
--- 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 <path>
// 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 <path>
+ // allows the game to store binary files (not data) in a sep tree
+ //
+ fs_libdir = Cvar_Get ("libdir", DEFAULT_LIBDIR, CVAR_NOSET);
//
// cddir <path>
@@ -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
|