1 # Choose the compiler you want to use
5 #CPUOPTIMIZATIONS=-march=athlon
6 # athlon xp optimizations
7 #CPUOPTIMIZATIONS=-march=athlon-xp
8 # athlon 64 optimizations
9 #CPUOPTIMIZATIONS=-march=athlon64 -m32
10 # Pentium 3 optimizations
11 #CPUOPTIMIZATIONS=-march=pentium3
12 # Pentium 4 optimizations
13 #CPUOPTIMIZATIONS=-march=pentium4
14 # 686 (Pentium Pro/II) optimizations
15 #CPUOPTIMIZATIONS=-march=i686
16 # No specific CPU (386 compatible)
19 SDL_CONFIG?=sdl-config
20 SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags`
21 SDLCONFIG_UNIXLIBS?=`$(SDL_CONFIG) --libs`
22 SDLCONFIG_UNIXSTATICLIBS?=`$(SDL_CONFIG) --static-libs`
23 SDLCONFIG_MACOSXCFLAGS=
24 SDLCONFIG_MACOSXLIBS=-framework SDL -framework Cocoa
25 SDLCONFIG_MACOSXSTATICLIBS=-framework SDL -framework Cocoa
29 ###### Sound and audio CD #####
31 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o snd_modplug.o
33 # Additional stuff for libmodplug
34 LIB_SND_MODPLUG=`if [ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ]; then echo " $(DP_MODPLUG_STATIC_LIBDIR)/libmodplug.a -lstdc++"; fi`
35 CFLAGS_SND_MODPLUG=`if [ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ]; then echo " -I$(DP_MODPLUG_STATIC_LIBDIR)/../include -DSND_MODPLUG_STATIC"; fi`
38 OBJ_SND_NULL=snd_null.o
41 # Open Sound System (Linux, FreeBSD and Solaris)
42 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
43 LIB_SND_OSS=$(LIB_SND_MODPLUG)
45 # Advanced Linux Sound Architecture (Linux)
46 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
47 LIB_SND_ALSA=-lasound $(LIB_SND_MODPLUG)
49 # Core Audio (Mac OS X)
50 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.c
51 LIB_SND_COREAUDIO=-framework CoreAudio $(LIB_SND_MODPLUG)
53 # BSD / Sun audio API (NetBSD and OpenBSD)
54 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
55 LIB_SND_BSD=$(LIB_SND_MODPLUG)
57 # DirectX and Win32 WAVE output (Win32)
58 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
59 LIB_SND_WIN=$(LIB_SND_MODPLUG)
66 ###### Common objects and flags #####
145 # note that builddate.c is very intentionally not compiled to a .o before
146 # being linked, because it should be recompiled every time an executable is
147 # built to give the executable a proper date string
148 OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_SND_NULL) $(OBJ_NOCD) $(OBJ_COMMON)
149 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
153 CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) -Wall -Wsign-compare -Wdeclaration-after-statement
155 CFLAGS_PROFILE=-g -pg -ggdb
157 CFLAGS_SDL=$(SDLCONFIG_CFLAGS)
159 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
160 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
161 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signaling-nans -fcx-limited-range -funroll-loops $(CPUOPTIMIZATIONS)
162 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -funroll-loops $(CPUOPTIMIZATIONS)
163 OPTIM_RELEASE=-O2 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
165 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
169 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG)
170 LDFLAGS_PROFILE=-g -pg $(OPTIM_RELEASE)
171 LDFLAGS_RELEASE=$(OPTIM_RELEASE)
174 ##### UNIX specific variables #####
176 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
178 LDFLAGS_UNIXCOMMON=-lm
179 LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
180 LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -lvorbis -lvorbisfile -lcurl -lmodplug
181 LDFLAGS_UNIXSV_PRELOAD=-lz -lcurl
182 LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -lvorbis -lvorbisfile -lcurl -lmodplug
183 CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
185 LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG)
186 EXE_UNIXCL=darkplaces-glx
187 EXE_UNIXSV=darkplaces-dedicated
188 EXE_UNIXSDL=darkplaces-sdl
189 EXE_UNIXCLNEXUIZ=nexuiz-glx
190 EXE_UNIXSVNEXUIZ=nexuiz-dedicated
191 EXE_UNIXSDLNEXUIZ=nexuiz-sdl
196 ##### Linux specific variables #####
198 # If you want CD sound in Linux
199 OBJ_LINUXCD=cd_linux.o
200 # If you want no CD audio
201 #OBJ_LINUXCD=$(OBJ_NOCD)
204 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
205 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
206 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
209 ##### Mac OS X specific variables #####
211 # No CD support available
212 OBJ_MACOSXCD=$(OBJ_NOCD)
215 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit -framework Carbon $(LIB_SOUND)
216 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
217 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(SDLCONFIG_STATICLIBS) SDLMain.m
219 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
221 EXE_MACOSXCL=darkplaces-agl
222 EXE_MACOSXCLNEXUIZ=nexuiz-agl
225 ##### SunOS specific variables #####
227 # No CD support available
228 OBJ_SUNOSCD=$(OBJ_NOCD)
230 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
233 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl -R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm $(LIB_SOUND)
234 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl
235 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
238 ##### BSD specific variables #####
240 #if you want CD sound in BSD
242 #if you want no CD audio
243 #OBJ_BSDCD=$(OBJ_NOCD)
246 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
247 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
248 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
251 ##### Win32 specific variables #####
254 #if you want CD sound in Win32
256 #if you want no CD audio
257 #OBJ_WINCD=$(OBJ_NOCD)
259 OBJ_WGL= builddate.c sys_win.o vid_wgl.o conproc.o $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_COMMON)
262 # Note that Windows Vista users may need --large-address-aware because Vista seems to map over 500MB of application address space for its own purposes, which is a significant chunk taken out of the default 2GB address space, this option raises the limit to 4GB (or 3GB on Vista 32 and older versions of Windows).
263 LDFLAGS_WINCOMMON=-lws2_32 -Wl,--large-address-aware
264 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -lwinmm -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
265 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole -lwinmm
266 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG)
267 EXE_WINCL=darkplaces.exe
268 EXE_WINSV=darkplaces-dedicated.exe
269 EXE_WINSDL=darkplaces-sdl.exe
270 EXE_WINCLNEXUIZ=nexuiz.exe
271 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
272 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
277 .PHONY : clean help \
278 debug profile release \
279 cl-debug cl-profile cl-release \
280 sv-debug sv-profile sv-release \
281 sdl-debug sdl-profile sdl-release
285 @echo "===== Choose one ====="
286 @echo "* $(MAKE) clean : delete all files produced by the build"
287 @echo "* $(MAKE) help : this help"
288 @echo "* $(MAKE) debug : make client and server binaries (debug versions)"
289 @echo "* $(MAKE) profile : make client and server binaries (profile versions)"
290 @echo "* $(MAKE) release : make client and server binaries (release versions)"
291 @echo "* $(MAKE) nexuiz : make client and server binaries with nexuiz icon (release versions)"
292 @echo "* $(MAKE) cl-debug : make client (debug version)"
293 @echo "* $(MAKE) cl-profile : make client (profile version)"
294 @echo "* $(MAKE) cl-release : make client (release version)"
295 @echo "* $(MAKE) cl-nexuiz : make client with nexuiz icon (release version)"
296 @echo "* $(MAKE) sv-debug : make dedicated server (debug version)"
297 @echo "* $(MAKE) sv-profile : make dedicated server (profile version)"
298 @echo "* $(MAKE) sv-release : make dedicated server (release version)"
299 @echo "* $(MAKE) sv-nexuiz : make dedicated server with nexuiz icon (release version)"
300 @echo "* $(MAKE) sdl-debug : make SDL client (debug version)"
301 @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
302 @echo "* $(MAKE) sdl-release : make SDL client (release version)"
303 @echo "* $(MAKE) sdl-nexuiz : make SDL client with nexuiz icon (release version)"
307 $(MAKE) sv-debug cl-debug sdl-debug
310 $(MAKE) sv-profile cl-profile sdl-profile
313 $(MAKE) sv-release cl-release sdl-release
316 $(MAKE) sv-nexuiz cl-nexuiz sdl-nexuiz
320 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
321 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
324 $(MAKE) bin-profile \
325 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
326 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
329 $(MAKE) bin-release \
330 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
331 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
334 $(MAKE) bin-release \
335 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
336 EXE="$(EXE_CLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
340 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
341 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
344 $(MAKE) bin-profile \
345 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
346 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
349 $(MAKE) bin-release \
350 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
351 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
354 $(MAKE) bin-release \
355 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
356 EXE="$(EXE_SVNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
360 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
361 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
364 $(MAKE) bin-profile \
365 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
366 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
369 $(MAKE) bin-release \
370 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
371 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
374 $(MAKE) bin-release \
375 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
376 EXE="$(EXE_SDLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
380 @echo "========== $(EXE) (debug) =========="
382 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
383 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
384 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
388 @echo "========== $(EXE) (profile) =========="
390 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
391 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
392 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
396 @echo "========== $(EXE) (release) =========="
398 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
399 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
400 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
403 snd_modplug.o: snd_modplug.c
404 $(DO_CC) $(CFLAGS_SND_MODPLUG)
407 $(DO_CC) -I/usr/X11R6/include
410 $(DO_CC) $(CFLAGS_SDL)
413 $(DO_CC) $(CFLAGS_SDL)
416 $(DO_CC) $(CFLAGS_SDL)
419 $(DO_CC) $(CFLAGS_SDL)
421 darkplaces.o: %.o : %.rc
430 $(EXE_CL): $(OBJ_CL) $(OBJ_ICON)
433 $(EXE_SV): $(OBJ_SV) $(OBJ_ICON)
436 $(EXE_SDL): $(OBJ_SDL) $(OBJ_ICON)
439 $(EXE_CLNEXUIZ): $(OBJ_CL) $(OBJ_ICON_NEXUIZ)
442 $(EXE_SVNEXUIZ): $(OBJ_SV) $(OBJ_ICON_NEXUIZ)
445 $(EXE_SDLNEXUIZ): $(OBJ_SDL) $(OBJ_ICON_NEXUIZ)
451 -$(CMD_RM) $(EXE_SDL)
452 -$(CMD_RM) $(EXE_CLNEXUIZ)
453 -$(CMD_RM) $(EXE_SVNEXUIZ)
454 -$(CMD_RM) $(EXE_SDLNEXUIZ)