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 SDL_CONFIG?=sdl-config
27 SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags`
28 SDLCONFIG_UNIXLIBS?=`$(SDL_CONFIG) --libs`
29 SDLCONFIG_UNIXSTATICLIBS?=`$(SDL_CONFIG) --static-libs`
30 SDLCONFIG_MACOSXCFLAGS=-I/Library/Frameworks/SDL.framework/Headers
31 SDLCONFIG_MACOSXLIBS=-framework SDL -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
32 SDLCONFIG_MACOSXSTATICLIBS=-framework SDL -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
36 ###### Sound and audio CD #####
38 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o snd_modplug.o
40 # Additional stuff for libmodplug
41 LIB_SND_MODPLUG=`[ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ] && echo \ $(DP_MODPLUG_STATIC_LIBDIR)/libmodplug.a\ -lstdc++`
42 CFLAGS_SND_MODPLUG=`[ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ] && echo \ -I$(DP_MODPLUG_STATIC_LIBDIR)/../include\ -DSND_MODPLUG_STATIC`
45 OBJ_SND_NULL=snd_null.o
48 # Open Sound System (Linux, FreeBSD and Solaris)
49 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
50 LIB_SND_OSS=$(LIB_SND_MODPLUG)
52 # Advanced Linux Sound Architecture (Linux)
53 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
54 LIB_SND_ALSA=-lasound $(LIB_SND_MODPLUG)
56 # Core Audio (Mac OS X)
57 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.o
58 LIB_SND_COREAUDIO=-framework CoreAudio $(LIB_SND_MODPLUG)
60 # BSD / Sun audio API (NetBSD and OpenBSD)
61 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
62 LIB_SND_BSD=$(LIB_SND_MODPLUG)
64 # DirectX and Win32 WAVE output (Win32)
65 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
66 LIB_SND_WIN=$(LIB_SND_MODPLUG)
68 # Qantourisc's 3D Realtime Acoustic Lib (3D RAS)
69 OBJ_SND_3DRAS=snd_3dras.o
76 ###### Common objects and flags #####
159 # note that builddate.c is very intentionally not compiled to a .o before
160 # being linked, because it should be recompiled every time an executable is
161 # built to give the executable a proper date string
162 OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_SND_NULL) $(OBJ_NOCD) $(OBJ_COMMON)
163 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
167 CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) -Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement
169 CFLAGS_PROFILE=-g -pg -ggdb -fprofile-arcs
171 CFLAGS_RELEASE_PROFILE=-fbranch-probabilities
172 CFLAGS_SDL=$(SDLCONFIG_CFLAGS)
174 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
175 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
176 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signaling-nans -fcx-limited-range -funroll-loops $(CPUOPTIMIZATIONS)
177 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -funroll-loops $(CPUOPTIMIZATIONS)
178 OPTIM_RELEASE=-O2 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
179 # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag
181 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
185 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=debug
186 LDFLAGS_PROFILE=-g -pg -fprofile-arcs $(OPTIM_RELEASE) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=profile
187 LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=release
190 ##### UNIX specific variables #####
192 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
194 LDFLAGS_UNIXCOMMON=-lm
195 LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
196 LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl -lmodplug
197 LDFLAGS_UNIXSV_PRELOAD=-lz -lcurl
198 LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl -lmodplug
199 CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
201 LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG)
202 EXE_UNIXCL=darkplaces-glx
203 EXE_UNIXSV=darkplaces-dedicated
204 EXE_UNIXSDL=darkplaces-sdl
205 EXE_UNIXCLNEXUIZ=nexuiz-glx
206 EXE_UNIXSVNEXUIZ=nexuiz-dedicated
207 EXE_UNIXSDLNEXUIZ=nexuiz-sdl
212 ##### Linux specific variables #####
214 # If you want CD sound in Linux
215 OBJ_LINUXCD=cd_linux.o
216 # If you want no CD audio
217 #OBJ_LINUXCD=$(OBJ_NOCD)
220 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl $(LDFLAGS_UNIXCL)
221 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl
222 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl $(LDFLAGS_UNIXSDL)
225 ##### Mac OS X specific variables #####
227 # No CD support available
228 OBJ_MACOSXCD=$(OBJ_NOCD)
231 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit -framework Carbon $(LIB_SOUND)
232 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
233 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(SDLCONFIG_STATICLIBS) SDLMain.m
235 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
237 EXE_MACOSXCL=darkplaces-agl
238 EXE_MACOSXCLNEXUIZ=nexuiz-agl
241 ##### SunOS specific variables #####
243 # No CD support available
244 OBJ_SUNOSCD=$(OBJ_NOCD)
246 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
249 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl -R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm $(LIB_SOUND)
250 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl
251 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
254 ##### BSD specific variables #####
256 #if you want CD sound in BSD
258 #if you want no CD audio
259 #OBJ_BSDCD=$(OBJ_NOCD)
262 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
263 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
264 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
267 ##### Win32 specific variables #####
270 #if you want CD sound in Win32
272 #if you want no CD audio
273 #OBJ_WINCD=$(OBJ_NOCD)
275 OBJ_WGL= builddate.c sys_win.o vid_wgl.o $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_COMMON)
278 # 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).
279 LDFLAGS_WINCOMMON=-lws2_32 -Wl,--large-address-aware
280 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -lwinmm -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
281 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole -lwinmm
282 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG)
283 EXE_WINCL=darkplaces.exe
284 EXE_WINSV=darkplaces-dedicated.exe
285 EXE_WINSDL=darkplaces-sdl.exe
286 EXE_WINCLNEXUIZ=nexuiz.exe
287 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
288 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
293 .PHONY : clean clean-profile help \
294 debug profile release \
295 cl-debug cl-profile cl-release \
296 sv-debug sv-profile sv-release \
297 sdl-debug sdl-profile sdl-release
301 @echo "===== Choose one ====="
302 @echo "* $(MAKE) clean : delete all files produced by the build except"
303 @echo " profiling information"
304 @echo "* $(MAKE) clean-profile : delete all files produced by the build, including"
305 @echo " profiling informaiton"
306 @echo "* $(MAKE) help : this help"
307 @echo "* $(MAKE) debug : make client and server binaries (debug versions)"
308 @echo "* $(MAKE) profile : make client and server binaries (profile versions)"
309 @echo "* $(MAKE) release : make client and server binaries (release versions)"
310 @echo "* $(MAKE) release-profile : make client and server binaries (release versions)"
311 @echo " with profileing optomizations) The profiled"
312 @echo " version of the program must have been"
313 @echo " previously compiled"
314 @echo "* $(MAKE) nexuiz : make client and server binaries with nexuiz icon"
315 @echo " (release versions)"
316 @echo "* $(MAKE) cl-debug : make client (debug version)"
317 @echo "* $(MAKE) cl-profile : make client (profile version)"
318 @echo "* $(MAKE) cl-release : make client (release version)"
319 @echo "* $(MAKE) cl-release-profile : make client (release version)"
320 @echo "* $(MAKE) cl-nexuiz : make client with nexuiz icon (release version)"
321 @echo "* $(MAKE) sv-debug : make dedicated server (debug version)"
322 @echo "* $(MAKE) sv-profile : make dedicated server (profile version)"
323 @echo "* $(MAKE) sv-release : make dedicated server (release version)"
324 @echo "* $(MAKE) sv-release-profile : make dedicated server (release version)"
325 @echo "* $(MAKE) sv-nexuiz : make dedicated server with nexuiz icon"
326 @echo " (release version)"
327 @echo "* $(MAKE) sdl-debug : make SDL client (debug version)"
328 @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
329 @echo "* $(MAKE) sdl-profile-profile : make SDL client (profile version)"
330 @echo "* $(MAKE) sdl-release : make SDL client (release version)"
331 @echo "* $(MAKE) sdl-nexuiz : make SDL client with nexuiz icon (release version)"
335 $(MAKE) sv-debug cl-debug sdl-debug
338 $(MAKE) sv-profile cl-profile sdl-profile
341 $(MAKE) sv-release cl-release sdl-release
344 $(MAKE) sv-release-profile cl-release-profile sdl-release-profile
347 $(MAKE) sv-nexuiz cl-nexuiz sdl-nexuiz
351 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
352 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
355 $(MAKE) bin-profile \
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-release \
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-profile \
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 \
371 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
372 EXE="$(EXE_CLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
376 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
377 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
380 $(MAKE) bin-profile \
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-release \
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-profile \
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 \
396 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
397 EXE="$(EXE_SVNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
401 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
402 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
405 $(MAKE) bin-profile \
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-release \
411 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
412 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
414 sdl-release-profile :
415 $(MAKE) bin-release-profile \
416 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
417 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
420 $(MAKE) bin-release \
421 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
422 EXE="$(EXE_SDLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
427 @echo "========== $(EXE) (debug) =========="
429 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
430 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
431 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)" LEVEL=2
436 @echo "========== $(EXE) (profile) =========="
438 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
439 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
440 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)" LEVEL=2
445 @echo "========== $(EXE) (release) =========="
447 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
448 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
449 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2
452 bin-release-profile :
455 @echo "========== $(EXE) (release) =========="
457 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
458 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE_PROFILE) $(OPTIM_RELEASE)"\
459 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2
463 snd_modplug.o: snd_modplug.c
465 $(DO_CC) $(CFLAGS_SND_MODPLUG)
469 $(DO_CC) -I/usr/X11R6/include
473 $(DO_CC) $(CFLAGS_SDL)
477 $(DO_CC) $(CFLAGS_SDL)
481 $(DO_CC) $(CFLAGS_SDL)
483 snd_3dras.o: snd_3dras.c
489 $(DO_CC) $(CFLAGS_SDL)
491 darkplaces.o: %.o : %.rc
503 $(EXE_CL): $(OBJ_CL) $(OBJ_ICON)
507 $(EXE_SV): $(OBJ_SV) $(OBJ_ICON)
511 $(EXE_SDL): $(OBJ_SDL) $(OBJ_ICON)
515 $(EXE_CLNEXUIZ): $(OBJ_CL) $(OBJ_ICON_NEXUIZ)
519 $(EXE_SVNEXUIZ): $(OBJ_SV) $(OBJ_ICON_NEXUIZ)
523 $(EXE_SDLNEXUIZ): $(OBJ_SDL) $(OBJ_ICON_NEXUIZ)
530 -$(CMD_RM) $(EXE_SDL)
531 -$(CMD_RM) $(EXE_CLNEXUIZ)
532 -$(CMD_RM) $(EXE_SVNEXUIZ)
533 -$(CMD_RM) $(EXE_SDLNEXUIZ)