1 # Invalid call detection
2 CHECKLEVEL1 = @if [ "$(LEVEL)" != 1 ]; then $(MAKE) help; false; fi
3 CHECKLEVEL2 = @if [ "$(LEVEL)" != 2 ]; then $(MAKE) help; false; fi
5 # Choose the compiler you want to use
9 #CPUOPTIMIZATIONS?=-march=athlon
10 # athlon xp optimizations
11 #CPUOPTIMIZATIONS?=-march=athlon-xp
12 # athlon 64 optimizations
13 #CPUOPTIMIZATIONS?=-march=athlon64 -m32
14 # Pentium 3 optimizations
15 #CPUOPTIMIZATIONS?=-march=pentium3
16 # Pentium 4 optimizations
17 #CPUOPTIMIZATIONS?=-march=pentium4
18 # 686 (Pentium Pro/II) optimizations
19 #CPUOPTIMIZATIONS?=-march=i686
20 # No specific CPU (386 compatible)
23 #CPUOPTIMIZATIONS?=-fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fassociative-math -freciprocal-math -fno-signed-zeros -fno-trapping-math
24 # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag
26 # Additional stuff for libode
27 LIB_ODE=`[ -n "$(DP_ODE_STATIC_LIBDIR)" ] && "$(DP_ODE_STATIC_LIBDIR)/../bin/ode-config" --libs` `[ -n "$(DP_ODE_STATIC_LIBDIR)" ] && echo -lstdc++`
28 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`
31 SDL_CONFIG?=sdl-config
32 SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags`
33 SDLCONFIG_UNIXLIBS?=`$(SDL_CONFIG) --libs`
34 SDLCONFIG_UNIXSTATICLIBS?=`$(SDL_CONFIG) --static-libs`
35 SDLCONFIG_MACOSXCFLAGS=-I/Library/Frameworks/SDL.framework/Headers
36 SDLCONFIG_MACOSXLIBS=-framework SDL -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
37 SDLCONFIG_MACOSXSTATICLIBS=-framework SDL -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
41 ###### Sound and audio CD #####
43 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o snd_modplug.o
45 # Additional stuff for libmodplug
46 LIB_SND_MODPLUG=`[ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ] && echo \ $(DP_MODPLUG_STATIC_LIBDIR)/libmodplug.a\ -lstdc++`
47 CFLAGS_SND_MODPLUG=`[ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ] && echo \ -I$(DP_MODPLUG_STATIC_LIBDIR)/../include\ -DSND_MODPLUG_STATIC`
50 OBJ_SND_NULL=snd_null.o
53 # Open Sound System (Linux, FreeBSD and Solaris)
54 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
55 LIB_SND_OSS=$(LIB_SND_MODPLUG)
57 # Advanced Linux Sound Architecture (Linux)
58 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
59 LIB_SND_ALSA=-lasound $(LIB_SND_MODPLUG)
61 # Core Audio (Mac OS X)
62 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.o
63 LIB_SND_COREAUDIO=-framework CoreAudio $(LIB_SND_MODPLUG)
65 # BSD / Sun audio API (NetBSD and OpenBSD)
66 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
67 LIB_SND_BSD=$(LIB_SND_MODPLUG)
69 # DirectX and Win32 WAVE output (Win32)
70 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
71 LIB_SND_WIN=$(LIB_SND_MODPLUG)
73 # Qantourisc's 3D Realtime Acoustic Lib (3D RAS)
74 OBJ_SND_3DRAS=snd_3dras.o
81 ###### Common objects and flags #####
164 # note that builddate.c is very intentionally not compiled to a .o before
165 # being linked, because it should be recompiled every time an executable is
166 # built to give the executable a proper date string
167 OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_SND_NULL) $(OBJ_NOCD) $(OBJ_COMMON)
168 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
172 CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) -Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement
174 CFLAGS_PROFILE=-g -pg -ggdb -fprofile-arcs
176 CFLAGS_RELEASE_PROFILE=-fbranch-probabilities
177 CFLAGS_SDL=$(SDLCONFIG_CFLAGS)
179 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
180 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
181 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signaling-nans -fcx-limited-range -funroll-loops $(CPUOPTIMIZATIONS)
182 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -funroll-loops $(CPUOPTIMIZATIONS)
183 OPTIM_RELEASE=-O2 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
184 # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag
186 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
190 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=debug
191 LDFLAGS_PROFILE=-g -pg -fprofile-arcs $(OPTIM_RELEASE) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=profile
192 LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=release
195 ##### UNIX specific variables #####
197 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
199 LDFLAGS_UNIXCOMMON=-lm $(LIB_ODE)
200 LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
201 LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl -lmodplug
202 LDFLAGS_UNIXSV_PRELOAD=-lz -lcurl
203 LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl -lmodplug
204 CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
206 LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG)
207 EXE_UNIXCL=darkplaces-glx
208 EXE_UNIXSV=darkplaces-dedicated
209 EXE_UNIXSDL=darkplaces-sdl
210 EXE_UNIXCLNEXUIZ=nexuiz-glx
211 EXE_UNIXSVNEXUIZ=nexuiz-dedicated
212 EXE_UNIXSDLNEXUIZ=nexuiz-sdl
217 ##### Linux specific variables #####
219 # If you want CD sound in Linux
220 OBJ_LINUXCD=cd_linux.o
221 # If you want no CD audio
222 #OBJ_LINUXCD=$(OBJ_NOCD)
225 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl $(LDFLAGS_UNIXCL)
226 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl
227 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl $(LDFLAGS_UNIXSDL)
230 ##### Mac OS X specific variables #####
232 # No CD support available
233 OBJ_MACOSXCD=$(OBJ_NOCD)
236 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit -framework Carbon $(LIB_SOUND)
237 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
238 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(SDLCONFIG_STATICLIBS) SDLMain.m
240 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
242 EXE_MACOSXCL=darkplaces-agl
243 EXE_MACOSXCLNEXUIZ=nexuiz-agl
246 ##### SunOS specific variables #####
248 # No CD support available
249 OBJ_SUNOSCD=$(OBJ_NOCD)
251 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
254 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl -R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm $(LIB_SOUND)
255 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl
256 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
259 ##### BSD specific variables #####
261 #if you want CD sound in BSD
263 #if you want no CD audio
264 #OBJ_BSDCD=$(OBJ_NOCD)
267 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
268 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
269 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
272 ##### Win32 specific variables #####
275 #if you want CD sound in Win32
277 #if you want no CD audio
278 #OBJ_WINCD=$(OBJ_NOCD)
280 OBJ_WGL= builddate.c sys_win.o vid_wgl.o $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_COMMON)
283 # 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).
284 LDFLAGS_WINCOMMON=-lws2_32 -Wl,--large-address-aware
285 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -lwinmm -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
286 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole -lwinmm
287 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG)
288 EXE_WINCL=darkplaces.exe
289 EXE_WINSV=darkplaces-dedicated.exe
290 EXE_WINSDL=darkplaces-sdl.exe
291 EXE_WINCLNEXUIZ=nexuiz.exe
292 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
293 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
298 .PHONY : clean clean-profile help \
299 debug profile release \
300 cl-debug cl-profile cl-release \
301 sv-debug sv-profile sv-release \
302 sdl-debug sdl-profile sdl-release
306 @echo "===== Choose one ====="
307 @echo "* $(MAKE) clean : delete all files produced by the build except"
308 @echo " profiling information"
309 @echo "* $(MAKE) clean-profile : delete all files produced by the build, including"
310 @echo " profiling informaiton"
311 @echo "* $(MAKE) help : this help"
312 @echo "* $(MAKE) debug : make client and server binaries (debug versions)"
313 @echo "* $(MAKE) profile : make client and server binaries (profile versions)"
314 @echo "* $(MAKE) release : make client and server binaries (release versions)"
315 @echo "* $(MAKE) release-profile : make client and server binaries (release versions)"
316 @echo " with profileing optomizations) The profiled"
317 @echo " version of the program must have been"
318 @echo " previously compiled"
319 @echo "* $(MAKE) nexuiz : make client and server binaries with nexuiz icon"
320 @echo " (release versions)"
321 @echo "* $(MAKE) cl-debug : make client (debug version)"
322 @echo "* $(MAKE) cl-profile : make client (profile version)"
323 @echo "* $(MAKE) cl-release : make client (release version)"
324 @echo "* $(MAKE) cl-release-profile : make client (release version)"
325 @echo "* $(MAKE) cl-nexuiz : make client with nexuiz icon (release version)"
326 @echo "* $(MAKE) sv-debug : make dedicated server (debug version)"
327 @echo "* $(MAKE) sv-profile : make dedicated server (profile version)"
328 @echo "* $(MAKE) sv-release : make dedicated server (release version)"
329 @echo "* $(MAKE) sv-release-profile : make dedicated server (release version)"
330 @echo "* $(MAKE) sv-nexuiz : make dedicated server with nexuiz icon"
331 @echo " (release version)"
332 @echo "* $(MAKE) sdl-debug : make SDL client (debug version)"
333 @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
334 @echo "* $(MAKE) sdl-profile-profile : make SDL client (profile version)"
335 @echo "* $(MAKE) sdl-release : make SDL client (release version)"
336 @echo "* $(MAKE) sdl-nexuiz : make SDL client with nexuiz icon (release version)"
340 $(MAKE) sv-debug cl-debug sdl-debug
343 $(MAKE) sv-profile cl-profile sdl-profile
346 $(MAKE) sv-release cl-release sdl-release
349 $(MAKE) sv-release-profile cl-release-profile sdl-release-profile
352 $(MAKE) sv-nexuiz cl-nexuiz sdl-nexuiz
356 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
357 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
360 $(MAKE) bin-profile \
361 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
362 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
365 $(MAKE) bin-release \
366 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
367 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
370 $(MAKE) bin-release-profile \
371 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
372 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
375 $(MAKE) bin-release \
376 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
377 EXE="$(EXE_CLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
381 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
382 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
385 $(MAKE) bin-profile \
386 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
387 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
390 $(MAKE) bin-release \
391 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
392 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
395 $(MAKE) bin-release-profile \
396 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
397 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
400 $(MAKE) bin-release \
401 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
402 EXE="$(EXE_SVNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
406 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
407 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
410 $(MAKE) bin-profile \
411 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
412 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
415 $(MAKE) bin-release \
416 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
417 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
419 sdl-release-profile :
420 $(MAKE) bin-release-profile \
421 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
422 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
425 $(MAKE) bin-release \
426 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
427 EXE="$(EXE_SDLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
432 @echo "========== $(EXE) (debug) =========="
434 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
435 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
436 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)" LEVEL=2
441 @echo "========== $(EXE) (profile) =========="
443 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
444 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
445 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)" LEVEL=2
450 @echo "========== $(EXE) (release) =========="
452 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
453 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
454 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2
457 bin-release-profile :
460 @echo "========== $(EXE) (release) =========="
462 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
463 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE_PROFILE) $(OPTIM_RELEASE)"\
464 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2
468 snd_modplug.o: snd_modplug.c
470 $(DO_CC) $(CFLAGS_SND_MODPLUG)
474 $(DO_CC) $(CFLAGS_ODE)
478 $(DO_CC) -I/usr/X11R6/include
482 $(DO_CC) $(CFLAGS_SDL)
486 $(DO_CC) $(CFLAGS_SDL)
490 $(DO_CC) $(CFLAGS_SDL)
492 snd_3dras.o: snd_3dras.c
498 $(DO_CC) $(CFLAGS_SDL)
500 darkplaces.o: %.o : %.rc
512 $(EXE_CL): $(OBJ_CL) $(OBJ_ICON)
516 $(EXE_SV): $(OBJ_SV) $(OBJ_ICON)
520 $(EXE_SDL): $(OBJ_SDL) $(OBJ_ICON)
524 $(EXE_CLNEXUIZ): $(OBJ_CL) $(OBJ_ICON_NEXUIZ)
528 $(EXE_SVNEXUIZ): $(OBJ_SV) $(OBJ_ICON_NEXUIZ)
532 $(EXE_SDLNEXUIZ): $(OBJ_SDL) $(OBJ_ICON_NEXUIZ)
539 -$(CMD_RM) $(EXE_SDL)
540 -$(CMD_RM) $(EXE_CLNEXUIZ)
541 -$(CMD_RM) $(EXE_SVNEXUIZ)
542 -$(CMD_RM) $(EXE_SDLNEXUIZ)