Compile with IPv6 support by default
[xonotic/darkplaces.git] / makefile.inc
1 # Invalid call detection
2 CHECKLEVEL1 = @if [ "$(LEVEL)" != 1 ]; then $(MAKE) help; false; fi
3 CHECKLEVEL2 = @if [ "$(LEVEL)" != 2 ]; then $(MAKE) help; false; fi
4
5 # Choose the compiler you want to use
6 CC?=gcc
7
8 # athlon optimizations
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)
21 #CPUOPTIMIZATIONS?=
22 # Experimental
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 # Normal
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
27
28 SDL_CONFIG?=sdl-config
29 SDL2_CONFIG?=sdl2-config
30 SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags`
31 SDLCONFIG_UNIXCFLAGS_X11?=
32 SDLCONFIG_UNIXLIBS?=`$(SDL_CONFIG) --libs`
33 SDLCONFIG_UNIXLIBS_X11?=-lX11
34 SDLCONFIG_UNIXSTATICLIBS?=`$(SDL_CONFIG) --static-libs`
35 SDLCONFIG_UNIXSTATICLIBS_X11?=-lX11
36 SDLCONFIG_MACOSXCFLAGS=-I/Library/Frameworks/SDL.framework/Headers -I$(HOME)/Library/Frameworks/SDL.framework/Headers
37 SDLCONFIG_MACOSXLIBS=-F$(HOME)/Library/Frameworks/ -framework SDL -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
38 SDLCONFIG_MACOSXSTATICLIBS=-F$(HOME)/Library/Frameworks/ -framework SDL -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
39 STRIP?=strip
40
41
42 ###### Sound and audio CD #####
43
44 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o
45
46 # No sound
47 OBJ_SND_NULL=snd_null.o
48 LIB_SND_NULL=
49
50 # Open Sound System (Linux, FreeBSD and Solaris)
51 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
52 LIB_SND_OSS=
53
54 # Advanced Linux Sound Architecture (Linux)
55 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
56 LIB_SND_ALSA=-lasound
57
58 # Core Audio (Mac OS X)
59 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.o
60 LIB_SND_COREAUDIO=-framework CoreAudio
61
62 # BSD / Sun audio API (NetBSD and OpenBSD)
63 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
64 LIB_SND_BSD=
65
66 # DirectX and Win32 WAVE output (Win32)
67 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
68 LIB_SND_WIN=
69
70 # Qantourisc's 3D Realtime Acoustic Lib (3D RAS)
71 OBJ_SND_3DRAS=snd_3dras.o
72 LIB_SND_3DRAS=
73
74 # CD objects
75 OBJ_CD_COMMON=cd_shared.o
76 OBJ_NOCD=cd_null.o
77
78
79 ###### Common objects and flags #####
80
81 # Common objects
82 OBJ_COMMON= \
83         bih.o \
84         crypto.o \
85         cl_collision.o \
86         cl_demo.o \
87         cl_dyntexture.o \
88         cl_input.o \
89         cl_main.o \
90         cl_parse.o \
91         cl_particles.o \
92         cl_screen.o \
93         cl_video.o \
94         clvm_cmds.o \
95         cmd.o \
96         collision.o \
97         common.o \
98         console.o \
99         csprogs.o \
100         curves.o \
101         cvar.o \
102         dpsoftrast.o \
103         dpvsimpledecode.o \
104         filematch.o \
105         fractalnoise.o \
106         fs.o \
107         ft2.o \
108         utf8lib.o \
109         gl_backend.o \
110         gl_draw.o \
111         gl_rmain.o \
112         gl_rsurf.o \
113         gl_textures.o \
114         hmac.o \
115         host.o \
116         host_cmd.o \
117         image.o \
118         image_png.o \
119         jpeg.o \
120         keys.o \
121         lhnet.o \
122         libcurl.o \
123         mathlib.o \
124         matrixlib.o \
125         mdfour.o \
126         meshqueue.o \
127         mod_skeletal_animatevertices_sse.o \
128         mod_skeletal_animatevertices_generic.o \
129         model_alias.o \
130         model_brush.o \
131         model_shared.o \
132         model_sprite.o \
133         netconn.o \
134         palette.o \
135         polygon.o \
136         portals.o \
137         protocol.o \
138         prvm_cmds.o \
139         prvm_edict.o \
140         prvm_exec.o \
141         r_explosion.o \
142         r_lerpanim.o \
143         r_lightning.o \
144         r_modules.o \
145         r_shadow.o \
146         r_sky.o \
147         r_sprites.o \
148         sbar.o \
149         sv_demo.o \
150         sv_main.o \
151         sv_move.o \
152         sv_phys.o \
153         sv_user.o \
154         svbsp.o \
155         svvm_cmds.o \
156         sys_shared.o \
157         vid_shared.o \
158         view.o \
159         wad.o \
160         world.o \
161         zone.o
162
163 OBJ_MENU= \
164         menu.o \
165         mvm_cmds.o
166
167 # note that builddate.c is very intentionally not compiled to a .o before
168 # being linked, because it should be recompiled every time an executable is
169 # built to give the executable a proper date string
170 OBJ_SV= builddate.c sys_linux.o vid_null.o thread_null.o $(OBJ_SND_NULL) $(OBJ_COMMON)
171 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o thread_sdl.o $(OBJ_MENU) $(OBJ_SND_COMMON) snd_sdl.o $(OBJ_SDLCD) $(OBJ_VIDEO_CAPTURE) $(OBJ_COMMON)
172
173
174 # Compilation
175 CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBZ) $(CFLAGS_LIBJPEG) $(CFLAGS_D3D) $(CFLAGS_NET) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES -I../../../
176 CFLAGS_CLIENT=-DCONFIG_MENU -DCONFIG_CD $(CFLAGS_VIDEO_CAPTURE)
177 CFLAGS_SERVER=
178 CFLAGS_DEBUG=-ggdb
179 CFLAGS_PROFILE=-g -pg -ggdb -fprofile-arcs
180 CFLAGS_RELEASE=
181 CFLAGS_RELEASE_PROFILE=-fbranch-probabilities
182 CFLAGS_SDL=$(SDLCONFIG_CFLAGS)
183
184 CFLAGS_SSE=-msse
185 CFLAGS_SSE2=-msse2
186
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
194
195 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
196
197
198 # Link
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
202
203
204 ##### UNIX specific variables #####
205
206 OBJ_GLX= builddate.c sys_linux.o vid_glx.o thread_pthread.o keysym2ucs.o $(OBJ_MENU) $(OBJ_SOUND) $(OBJ_CD) $(OBJ_VIDEO_CAPTURE) $(OBJ_COMMON)
207
208 LDFLAGS_UNIXCOMMON=-lm $(LIB_ODE) $(LIB_Z) $(LIB_JPEG) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL)
209 LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm -pthread $(LIB_SOUND)
210 LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl
211 LDFLAGS_UNIXSV_PRELOAD=-lz -ljpeg -lpng -lcurl
212 LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl
213 CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
214
215 LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS)
216 EXE_UNIXCL=darkplaces-glx
217 EXE_UNIXSV=darkplaces-dedicated
218 EXE_UNIXSDL=darkplaces-sdl
219 EXE_UNIXCLNEXUIZ=nexuiz-glx
220 EXE_UNIXSVNEXUIZ=nexuiz-dedicated
221 EXE_UNIXSDLNEXUIZ=nexuiz-sdl
222
223 CMD_UNIXRM=rm -rf
224 CMD_UNIXCP=cp -f
225 CMD_UNIXMKDIR=mkdir -p
226
227
228 ##### Linux specific variables #####
229
230 # Link
231 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl $(LDFLAGS_UNIXCL)
232 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl
233 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl $(LDFLAGS_UNIXSDL)
234
235
236 ##### Mac OS X specific variables #####
237
238 # No CD support available
239 OBJ_MACOSXCD=$(OBJ_NOCD)
240
241 # Link
242 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit -framework Carbon $(LIB_SOUND)
243 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
244 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit $(SDLCONFIG_STATICLIBS) ../../../SDLMain.m
245
246 OBJ_AGL= builddate.c sys_linux.o vid_agl.o thread_null.o $(OBJ_MENU) $(OBJ_SOUND) $(OBJ_CD) $(OBJ_VIDEO_CAPTURE) $(OBJ_COMMON)
247
248 EXE_MACOSXCL=darkplaces-agl
249 EXE_MACOSXCLNEXUIZ=nexuiz-agl
250
251
252 ##### SunOS specific variables #####
253
254 # No CD support available
255 OBJ_SUNOSCD=$(OBJ_NOCD)
256
257 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
258
259 # Link
260 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl -R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm $(LIB_SOUND)
261 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl
262 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
263
264
265 ##### BSD specific variables #####
266
267 # Link
268 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
269 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON) 
270 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
271
272
273 ##### Win32 specific variables #####
274
275 WINDRES ?= windres
276
277 OBJ_WGL= builddate.c sys_win.o vid_wgl.o thread_null.o $(OBJ_MENU) $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_VIDEO_CAPTURE) $(OBJ_COMMON)
278
279 # Link
280 # see LDFLAGS_WINCOMMON in makefile
281 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) -mwindows -lwinmm -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32 -lws2_32 $(LDFLAGS_D3D) $(LIB_Z) $(LIB_JPEG)
282 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) -mconsole -lwinmm -lws2_32 $(LIB_Z) $(LIB_JPEG)
283 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) $(SDLCONFIG_LIBS) -lwinmm -lws2_32 $(LIB_Z) $(LIB_JPEG)
284 EXE_WINCL=darkplaces.exe
285 EXE_WINSV=darkplaces-dedicated.exe
286 EXE_WINSDL=darkplaces-sdl.exe
287 EXE_WINCLNEXUIZ=nexuiz.exe
288 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
289 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
290
291 VPATH := ../../../
292
293 ##### Commands #####
294
295 .PHONY : clean clean-profile help \
296          debug profile release \
297          cl-debug cl-profile cl-release \
298          sv-debug sv-profile sv-release \
299          sdl-debug sdl-profile sdl-release
300
301 help:
302         @echo
303         @echo "===== Choose one ====="
304         @echo "* $(MAKE) clean                : delete all files produced by the build except"
305         @echo "                              profiling information"
306         @echo "* $(MAKE) clean-profile        : delete all files produced by the build, including"
307         @echo "                              profiling informaiton"
308         @echo "* $(MAKE) help                 : this help"
309         @echo "* $(MAKE) debug                : make client and server binaries (debug versions)"
310         @echo "* $(MAKE) profile              : make client and server binaries (profile versions)"
311         @echo "* $(MAKE) release              : make client and server binaries (release versions)"
312         @echo "* $(MAKE) release-profile      : make client and server binaries (release versions)"
313         @echo "                              (with profiling optimizations) The profiled"
314         @echo "                              version of the program must have been"
315         @echo "                              previously compiled"
316         @echo "* $(MAKE) nexuiz               : make client and server binaries with nexuiz icon"
317         @echo "                              (release versions)"
318         @echo "* $(MAKE) cl-debug             : make client (debug version)"
319         @echo "* $(MAKE) cl-profile           : make client (profile version)"
320         @echo "* $(MAKE) cl-release-profile   : make client (release profile version)"
321         @echo "* $(MAKE) cl-release           : make client (release version)"
322         @echo "* $(MAKE) cl-nexuiz            : make client with nexuiz icon (release version)"
323         @echo "* $(MAKE) sv-debug             : make dedicated server (debug version)"
324         @echo "* $(MAKE) sv-profile           : make dedicated server (profile version)"
325         @echo "* $(MAKE) sv-release-profile   : make dedicated server (release profile version)"
326         @echo "* $(MAKE) sv-release           : make dedicated server (release version)"
327         @echo "* $(MAKE) sv-nexuiz            : make dedicated server with nexuiz icon"
328         @echo "                              (release version)"
329         @echo "* $(MAKE) sdl-debug            : make SDL client (debug version)"
330         @echo "* $(MAKE) sdl-profile          : make SDL client (profile version)"
331         @echo "* $(MAKE) sdl-release-profile  : make SDL client (release version)"
332         @echo "* $(MAKE) sdl-release          : make SDL client (release version)"
333         @echo "* $(MAKE) sdl-nexuiz           : make SDL client with nexuiz icon (release version)"
334         @echo "* $(MAKE) sdl2-debug           : make SDL2 client (debug version)"
335         @echo "* $(MAKE) sdl2-profile         : make SDL2 client (profile version)"
336         @echo "* $(MAKE) sdl2-release-profile : make SDL2 client (release profile version)"
337         @echo "* $(MAKE) sdl2-release         : make SDL2 client (release version)"
338         @echo "* $(MAKE) sdl2-nexuiz          : make SDL2 client with nexuiz icon (release version)"
339         @echo
340
341 debug :
342         $(MAKE) $(TARGETS_DEBUG)
343
344 profile :
345         $(MAKE) $(TARGETS_PROFILE)
346
347 release :
348         $(MAKE) $(TARGETS_RELEASE)
349
350 release-profile :
351         $(MAKE) $(TARGETS_RELEASE_PROFILE)
352
353 nexuiz :
354         $(MAKE) $(TARGETS_NEXUIZ)
355
356 cl-debug :
357         $(MAKE) bin-debug \
358                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
359                 EXE='$(EXE_CL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_CL)' LEVEL=1
360
361 cl-profile :
362         $(MAKE) bin-profile \
363                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
364                 EXE='$(EXE_CL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_CL)' LEVEL=1
365
366 cl-release :
367         $(MAKE) bin-release \
368                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
369                 EXE='$(EXE_CL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_CL)' LEVEL=1
370
371 cl-release-profile :
372         $(MAKE) bin-release-profile \
373                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
374                 EXE='$(EXE_CL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_CL)' LEVEL=1
375
376 cl-nexuiz :
377         $(MAKE) bin-release \
378                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
379                 EXE='$(EXE_CLNEXUIZ)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_CL)' LEVEL=1
380
381 sv-debug :
382         $(MAKE) bin-debug \
383                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
384                 EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
385
386 sv-profile :
387         $(MAKE) bin-profile \
388                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
389                 EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
390
391 sv-release :
392         $(MAKE) bin-release \
393                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
394                 EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
395
396 sv-release-profile :
397         $(MAKE) bin-release-profile \
398                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
399                 EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
400
401 sv-nexuiz :
402         $(MAKE) bin-release \
403                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
404                 EXE='$(EXE_SVNEXUIZ)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
405
406 sdl-debug :
407         $(MAKE) bin-debug \
408                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
409                 EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
410
411 sdl-profile :
412         $(MAKE) bin-profile \
413                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
414                 EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
415
416 sdl-release :
417         $(MAKE) bin-release \
418                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
419                 EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
420
421 sdl-release-profile :
422         $(MAKE) bin-release-profile \
423                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
424                 EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
425
426 sdl-nexuiz :
427         $(MAKE) bin-release \
428                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
429                 EXE='$(EXE_SDLNEXUIZ)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
430
431 sdl2-debug :
432         $(MAKE) SDL_CONFIG=$(SDL2_CONFIG) sdl-debug
433
434 sdl2-profile :
435         $(MAKE) SDL_CONFIG=$(SDL2_CONFIG) sdl-profile
436
437 sdl2-release :
438         $(MAKE) SDL_CONFIG=$(SDL2_CONFIG) sdl-release
439
440 sdl2-release-profile :
441         $(MAKE) SDL_CONFIG=$(SDL2_CONFIG) sdl-release-profile
442
443 sdl2-nexuiz :
444         $(MAKE) SDL_CONFIG=$(SDL2_CONFIG) sdl-nexuiz
445
446 bin-debug :
447         $(CHECKLEVEL1)
448         @echo
449         @echo '========== $(EXE) (debug) =========='
450         $(MAKE) prepare BUILD_DIR=build-obj/debug/$(EXE)
451         $(MAKE) -C build-obj/debug/$(EXE) $(EXE) \
452                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
453                 CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)'\
454                 LDFLAGS='$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)' LEVEL=2
455
456 bin-profile :
457         $(CHECKLEVEL1)
458         @echo
459         @echo '========== $(EXE) (profile) =========='
460         $(MAKE) prepare BUILD_DIR=build-obj/profile/$(EXE)
461         $(MAKE) -C build-obj/profile/$(EXE) $(EXE) \
462                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
463                 CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)'\
464                 LDFLAGS='$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)' LEVEL=2
465
466 bin-release :
467         $(CHECKLEVEL1)
468         @echo
469         @echo '========== $(EXE) (release) =========='
470         $(MAKE) prepare BUILD_DIR=build-obj/release/$(EXE)
471         $(MAKE) -C build-obj/release/$(EXE) $(EXE) \
472                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
473                 CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)'\
474                 LDFLAGS='$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)' LEVEL=2
475         $(STRIP) $(EXE)
476
477 bin-release-profile :
478         $(CHECKLEVEL1)
479         @echo
480         @echo '========== $(EXE) (release) =========='
481         $(MAKE) prepare BUILD_DIR=build-obj/release-profile/$(EXE)
482         $(MAKE) -C build-obj/release-profile/$(EXE) $(EXE) \
483                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
484                 CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE_PROFILE) $(OPTIM_RELEASE)'\
485                 LDFLAGS='$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)' LEVEL=2
486         $(STRIP) $(EXE)
487
488 prepare :
489         $(CMD_MKDIR) $(BUILD_DIR)
490         $(CMD_CP) makefile.inc $(BUILD_DIR)/
491         $(CMD_CP) $(MAKEFILE) $(BUILD_DIR)/
492
493 #this checks USEODE when compiling so it needs the ODE flags as well
494 prvm_cmds.o: prvm_cmds.c
495         $(CHECKLEVEL2)
496         $(DO_CC) $(CFLAGS_ODE)
497
498 world.o: world.c
499         $(CHECKLEVEL2)
500         $(DO_CC) $(CFLAGS_ODE)
501
502 vid_glx.o: vid_glx.c
503         $(CHECKLEVEL2)
504         $(DO_CC) -I/usr/X11R6/include
505
506 keysym2ucs.o: keysym2ucs.c
507         $(CHECKLEVEL2)
508         $(DO_CC) -I/usr/X11R6/include
509
510 vid_sdl.o: vid_sdl.c
511         $(CHECKLEVEL2)
512         $(DO_CC) $(CFLAGS_SDL)
513
514 sys_sdl.o: sys_sdl.c
515         $(CHECKLEVEL2)
516         $(DO_CC) $(CFLAGS_SDL)
517
518 snd_sdl.o: snd_sdl.c
519         $(CHECKLEVEL2)
520         $(DO_CC) $(CFLAGS_SDL)
521
522 thread_sdl.o: thread_sdl.c
523         $(CHECKLEVEL2)
524         $(DO_CC) $(CFLAGS_SDL)
525
526 snd_3dras.o: snd_3dras.c
527         $(CHECKLEVEL2)
528         $(DO_CC)
529
530 cd_sdl.o: cd_sdl.c
531         $(CHECKLEVEL2)
532         $(DO_CC) $(CFLAGS_SDL)
533
534 crypto.o: crypto.c
535         $(CHECKLEVEL2)
536         $(DO_CC) $(CFLAGS_CRYPTO) $(CFLAGS_CRYPTO_RIJNDAEL)
537
538 mod_skeletal_animatevertices_sse.o: mod_skeletal_animatevertices_sse.c
539         $(CHECKLEVEL2)
540         $(DO_CC) $(CFLAGS_SSE)
541
542 dpsoftrast.o: dpsoftrast.c
543         $(CHECKLEVEL2)
544         $(DO_CC) $(CFLAGS_SSE2)
545
546 darkplaces.o: %.o : %.rc
547         $(CHECKLEVEL2)
548         $(WINDRES) -o $@ $<
549
550 nexuiz.o: %.o : %.rc
551         $(CHECKLEVEL2)
552         $(WINDRES) -o $@ $<
553
554 .c.o:
555         $(CHECKLEVEL2)
556         $(DO_CC)
557
558 $(EXE_CL): $(OBJ_CL) $(OBJ_ICON)
559         $(CHECKLEVEL2)
560         $(DO_LD)
561
562 $(EXE_SV): $(OBJ_SV) $(OBJ_ICON)
563         $(CHECKLEVEL2)
564         $(DO_LD)
565
566 $(EXE_SDL): $(OBJ_SDL) $(OBJ_ICON)
567         $(CHECKLEVEL2)
568         $(DO_LD)
569
570 $(EXE_CLNEXUIZ): $(OBJ_CL) $(OBJ_ICON_NEXUIZ)
571         $(CHECKLEVEL2)
572         $(DO_LD)
573
574 $(EXE_SVNEXUIZ): $(OBJ_SV) $(OBJ_ICON_NEXUIZ)
575         $(CHECKLEVEL2)
576         $(DO_LD)
577
578 $(EXE_SDLNEXUIZ): $(OBJ_SDL) $(OBJ_ICON_NEXUIZ)
579         $(CHECKLEVEL2)
580         $(DO_LD)
581
582 clean:
583         -$(CMD_RM) $(EXE_CL)
584         -$(CMD_RM) $(EXE_SV)
585         -$(CMD_RM) $(EXE_SDL)
586         -$(CMD_RM) $(EXE_CLNEXUIZ)
587         -$(CMD_RM) $(EXE_SVNEXUIZ)
588         -$(CMD_RM) $(EXE_SDLNEXUIZ)
589         -$(CMD_RM) *.o
590         -$(CMD_RM) *.d
591         -$(CMD_RM) build-obj/
592
593 clean-profile: clean
594         -$(CMD_RM) *.gcda
595         -$(CMD_RM) *.gcno