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
25 CPUOPTIMIZATIONS?=-fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
26 # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag
28 SDL_CONFIG?=sdl2-config
29 SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags`
30 SDLCONFIG_UNIXCFLAGS_X11?=
31 SDLCONFIG_UNIXLIBS?=`$(SDL_CONFIG) --libs`
32 SDLCONFIG_UNIXLIBS_X11?=-lX11
33 SDLCONFIG_UNIXSTATICLIBS?=`$(SDL_CONFIG) --static-libs`
34 SDLCONFIG_UNIXSTATICLIBS_X11?=-lX11
35 SDLCONFIG_MACOSXCFLAGS=-I/Library/Frameworks/SDL2.framework/Headers -I$(HOME)/Library/Frameworks/SDL2.framework/Headers
36 SDLCONFIG_MACOSXLIBS=-F$(HOME)/Library/Frameworks/ -framework SDL2 -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
37 SDLCONFIG_MACOSXSTATICLIBS=-F$(HOME)/Library/Frameworks/ -framework SDL2 -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
43 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o
46 OBJ_SND_NULL=snd_null.o
49 # Open Sound System (Linux, FreeBSD and Solaris)
50 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
53 # Advanced Linux Sound Architecture (Linux)
54 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
57 # Core Audio (Mac OS X)
58 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.o
59 LIB_SND_COREAUDIO=-framework CoreAudio
61 # BSD / Sun audio API (NetBSD and OpenBSD)
62 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
65 # DirectX and Win32 WAVE output (Win32)
66 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
69 # Qantourisc's 3D Realtime Acoustic Lib (3D RAS)
70 OBJ_SND_3DRAS=snd_3dras.o
74 ###### Common objects and flags #####
121 mod_skeletal_animatevertices_sse.o \
122 mod_skeletal_animatevertices_generic.o \
162 # note that builddate.c is very intentionally not compiled to a .o before
163 # being linked, because it should be recompiled every time an executable is
164 # built to give the executable a proper date string
165 OBJ_SV= builddate.c sys_linux.o vid_null.o thread_null.o $(OBJ_SND_NULL) $(OBJ_COMMON)
166 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o thread_sdl.o $(OBJ_MENU) $(OBJ_SND_COMMON) snd_sdl.o $(OBJ_VIDEO_CAPTURE) $(OBJ_COMMON)
170 CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBZ) $(CFLAGS_LIBJPEG) $(CFLAGS_D3D) $(CFLAGS_NET) $(CFLAGS_SDL) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES -I../../../
171 CFLAGS_CLIENT=-DCONFIG_MENU $(CFLAGS_VIDEO_CAPTURE)
174 CFLAGS_PROFILE=-g -pg -ggdb -fprofile-arcs
176 CFLAGS_RELEASE_PROFILE=-fbranch-probabilities
185 endif # ifeq ($(DP_SSE),1)
187 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
188 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
189 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signaling-nans -fcx-limited-range -funroll-loops $(CPUOPTIMIZATIONS)
190 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -funroll-loops $(CPUOPTIMIZATIONS)
191 #OPTIM_RELEASE=-O2 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
192 OPTIM_RELEASE=-O3 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
193 # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag
195 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
199 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG) -DSVNREVISION=`{ test -d .svn && svnversion; } || { test -d .git && git describe --always; } || echo -` -DBUILDTYPE=debug
200 LDFLAGS_PROFILE=-g -pg -fprofile-arcs $(OPTIM_RELEASE) -DSVNREVISION=`{ test -d .svn && svnversion; } || { test -d .git && git describe --always; } || echo -` -DBUILDTYPE=profile
201 LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`{ test -d .svn && svnversion; } || { test -d .git && git describe --always; } || echo -` -DBUILDTYPE=release
204 ##### UNIX specific variables #####
206 LDFLAGS_UNIXCOMMON=-lm $(LIB_ODE) $(LIB_Z) $(LIB_JPEG) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL)
207 LDFLAGS_UNIXSV_PRELOAD=-lz -ljpeg -lpng -lcurl
208 LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl
209 CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
211 LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS)
212 EXE_UNIXSV=darkplaces-dedicated
213 EXE_UNIXSDL=darkplaces-sdl
214 EXE_UNIXSVNEXUIZ=nexuiz-dedicated
215 EXE_UNIXSDLNEXUIZ=nexuiz-sdl
219 CMD_UNIXMKDIR=mkdir -p
222 ##### Linux specific variables #####
225 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl
226 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl $(LDFLAGS_UNIXSDL)
229 ##### Mac OS X specific variables #####
232 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
233 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit $(SDLCONFIG_STATICLIBS) ../../../SDLMain.m
236 ##### SunOS specific variables #####
238 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
241 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl
242 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
245 ##### BSD specific variables #####
248 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
249 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
252 ##### Win32 specific variables #####
257 # see LDFLAGS_WINCOMMON in makefile
258 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) -mconsole -lwinmm -lws2_32 $(LIB_Z) $(LIB_JPEG)
259 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) $(SDLCONFIG_LIBS) -lwinmm -lws2_32 $(LIB_Z) $(LIB_JPEG)
260 EXE_WINSV=darkplaces-dedicated.exe
261 EXE_WINSDL=darkplaces-sdl.exe
262 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
263 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
269 .PHONY : clean clean-profile help \
270 debug profile release \
271 sv-debug sv-profile sv-release \
272 sdl-debug sdl-profile sdl-release
276 @echo "===== Choose one ====="
277 @echo "* $(MAKE) clean : delete all files produced by the build except"
278 @echo " profiling information"
279 @echo "* $(MAKE) clean-profile : delete all files produced by the build, including"
280 @echo " profiling informaiton"
281 @echo "* $(MAKE) help : this help"
282 @echo "* $(MAKE) debug : make client and server binaries (debug versions)"
283 @echo "* $(MAKE) profile : make client and server binaries (profile versions)"
284 @echo "* $(MAKE) release : make client and server binaries (release versions)"
285 @echo "* $(MAKE) release-profile : make client and server binaries (release versions)"
286 @echo " (with profiling optimizations) The profiled"
287 @echo " version of the program must have been"
288 @echo " previously compiled"
289 @echo "* $(MAKE) nexuiz : make client and server binaries with nexuiz icon"
290 @echo " (release versions)"
291 @echo "* $(MAKE) sv-debug : make dedicated server (debug version)"
292 @echo "* $(MAKE) sv-profile : make dedicated server (profile version)"
293 @echo "* $(MAKE) sv-release-profile : make dedicated server (release profile version)"
294 @echo "* $(MAKE) sv-release : make dedicated server (release version)"
295 @echo "* $(MAKE) sv-nexuiz : make dedicated server with nexuiz icon"
296 @echo " (release version)"
297 @echo "* $(MAKE) sdl-debug : make SDL client (debug version)"
298 @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
299 @echo "* $(MAKE) sdl-release-profile : make SDL client (release version)"
300 @echo "* $(MAKE) sdl-release : make SDL client (release version)"
301 @echo "* $(MAKE) sdl-nexuiz : make SDL client with nexuiz icon (release version)"
305 $(MAKE) $(TARGETS_DEBUG)
308 $(MAKE) $(TARGETS_PROFILE)
311 $(MAKE) $(TARGETS_RELEASE)
314 $(MAKE) $(TARGETS_RELEASE_PROFILE)
317 $(MAKE) $(TARGETS_NEXUIZ)
321 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
322 EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
325 $(MAKE) bin-profile \
326 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
327 EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
330 $(MAKE) bin-release \
331 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
332 EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
335 $(MAKE) bin-release-profile \
336 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
337 EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
340 $(MAKE) bin-release \
341 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
342 EXE='$(EXE_SVNEXUIZ)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
346 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
347 EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
350 $(MAKE) bin-profile \
351 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
352 EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
355 $(MAKE) bin-release \
356 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
357 EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
359 sdl-release-profile :
360 $(MAKE) bin-release-profile \
361 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
362 EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
365 $(MAKE) bin-release \
366 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
367 EXE='$(EXE_SDLNEXUIZ)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
372 @echo '========== $(EXE) (debug) =========='
373 $(MAKE) prepare BUILD_DIR=build-obj/debug/$(EXE)
374 $(MAKE) -C build-obj/debug/$(EXE) $(EXE) \
375 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
376 CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)'\
377 LDFLAGS='$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)' LEVEL=2
382 @echo '========== $(EXE) (profile) =========='
383 $(MAKE) prepare BUILD_DIR=build-obj/profile/$(EXE)
384 $(MAKE) -C build-obj/profile/$(EXE) $(EXE) \
385 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
386 CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)'\
387 LDFLAGS='$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)' LEVEL=2
392 @echo '========== $(EXE) (release) =========='
393 $(MAKE) prepare BUILD_DIR=build-obj/release/$(EXE)
394 $(MAKE) -C build-obj/release/$(EXE) $(EXE) \
395 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
396 CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)'\
397 LDFLAGS='$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)' LEVEL=2
400 bin-release-profile :
403 @echo '========== $(EXE) (release) =========='
404 $(MAKE) prepare BUILD_DIR=build-obj/release-profile/$(EXE)
405 $(MAKE) -C build-obj/release-profile/$(EXE) $(EXE) \
406 DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
407 CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE_PROFILE) $(OPTIM_RELEASE)'\
408 LDFLAGS='$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)' LEVEL=2
412 $(CMD_MKDIR) $(BUILD_DIR)
413 $(CMD_CP) makefile.inc $(BUILD_DIR)/
414 $(CMD_CP) $(MAKEFILE) $(BUILD_DIR)/
416 #this checks USEODE when compiling so it needs the ODE flags as well
417 prvm_cmds.o: prvm_cmds.c
419 $(DO_CC) $(CFLAGS_ODE)
423 $(DO_CC) $(CFLAGS_ODE)
427 $(DO_CC) -I/usr/X11R6/include
429 keysym2ucs.o: keysym2ucs.c
431 $(DO_CC) -I/usr/X11R6/include
435 $(DO_CC) $(CFLAGS_CRYPTO) $(CFLAGS_CRYPTO_RIJNDAEL)
437 mod_skeletal_animatevertices_sse.o: mod_skeletal_animatevertices_sse.c
439 $(DO_CC) $(CFLAGS_SSE)
441 darkplaces.o: %.o : %.rc
453 $(EXE_SV): $(OBJ_SV) $(OBJ_ICON)
457 $(EXE_SDL): $(OBJ_SDL) $(OBJ_ICON)
461 $(EXE_SVNEXUIZ): $(OBJ_SV) $(OBJ_ICON_NEXUIZ)
465 $(EXE_SDLNEXUIZ): $(OBJ_SDL) $(OBJ_ICON_NEXUIZ)
471 -$(CMD_RM) $(EXE_SDL)
472 -$(CMD_RM) $(EXE_SVNEXUIZ)
473 -$(CMD_RM) $(EXE_SDLNEXUIZ)
476 -$(CMD_RM) build-obj/