Don't allow shortcuts with Ctrl+Alt because on Windows they can be used as the AltGr...
[xonotic/darkplaces.git] / makefile.inc
index 4d11490..326e3a4 100644 (file)
@@ -18,37 +18,29 @@ CC?=gcc
 # 686 (Pentium Pro/II) optimizations
 #CPUOPTIMIZATIONS?=-march=i686
 # No specific CPU (386 compatible)
-CPUOPTIMIZATIONS?=
+#CPUOPTIMIZATIONS?=
 # Experimental
 #CPUOPTIMIZATIONS?=-fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fassociative-math -freciprocal-math -fno-signed-zeros -fno-trapping-math
+# Normal
+CPUOPTIMIZATIONS?=-fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
 # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag
 
-# Additional stuff for libode
-LIB_ODE=`[ -n "$(DP_ODE_STATIC_LIBDIR)" ] && "$(DP_ODE_STATIC_LIBDIR)/../bin/ode-config" --libs` `[ -n "$(DP_ODE_STATIC_LIBDIR)" ] && echo -lstdc++`
-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`
-
-# Additional stuff for libCg
-LIB_CG=`[ -r "/usr/lib64/libCg.so" -o -r "/usr/lib/libCg.so" ] && echo \ -lCg\ -lCgGL -lGL`
-CFLAGS_CG=`[ -r "/usr/lib64/libCg.so" -o -r "/usr/lib/libCg.so" ] && echo \ -DSUPPORTCG`
-
-
-SDL_CONFIG?=sdl-config
+SDL_CONFIG?=sdl2-config
 SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags`
+SDLCONFIG_UNIXCFLAGS_X11?=
 SDLCONFIG_UNIXLIBS?=`$(SDL_CONFIG) --libs`
+SDLCONFIG_UNIXLIBS_X11?=-lX11
 SDLCONFIG_UNIXSTATICLIBS?=`$(SDL_CONFIG) --static-libs`
-SDLCONFIG_MACOSXCFLAGS=-I/Library/Frameworks/SDL.framework/Headers
-SDLCONFIG_MACOSXLIBS=-framework SDL -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
-SDLCONFIG_MACOSXSTATICLIBS=-framework SDL -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
+SDLCONFIG_UNIXSTATICLIBS_X11?=-lX11
+SDLCONFIG_MACOSXCFLAGS=-I/Library/Frameworks/SDL2.framework/Headers -I$(HOME)/Library/Frameworks/SDL2.framework/Headers
+SDLCONFIG_MACOSXLIBS=-F$(HOME)/Library/Frameworks/ -framework SDL2 -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
+SDLCONFIG_MACOSXSTATICLIBS=-F$(HOME)/Library/Frameworks/ -framework SDL2 -framework Cocoa $(SDLCONFIG_MACOSXCFLAGS)
 STRIP?=strip
 
 
-###### Sound and audio CD #####
+###### Sound #####
 
-OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o snd_modplug.o
-
-# Additional stuff for libmodplug
-LIB_SND_MODPLUG=`[ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ] && echo \ $(DP_MODPLUG_STATIC_LIBDIR)/libmodplug.a\ -lstdc++`
-CFLAGS_SND_MODPLUG=`[ -n "$(DP_MODPLUG_STATIC_LIBDIR)" ] && echo \ -I$(DP_MODPLUG_STATIC_LIBDIR)/../include\ -DSND_MODPLUG_STATIC`
+OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o
 
 # No sound
 OBJ_SND_NULL=snd_null.o
@@ -56,43 +48,38 @@ LIB_SND_NULL=
 
 # Open Sound System (Linux, FreeBSD and Solaris)
 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
-LIB_SND_OSS=$(LIB_SND_MODPLUG)
+LIB_SND_OSS=
 
 # Advanced Linux Sound Architecture (Linux)
 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
-LIB_SND_ALSA=-lasound $(LIB_SND_MODPLUG)
+LIB_SND_ALSA=-lasound
 
 # Core Audio (Mac OS X)
 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.o
-LIB_SND_COREAUDIO=-framework CoreAudio $(LIB_SND_MODPLUG)
+LIB_SND_COREAUDIO=-framework CoreAudio
 
 # BSD / Sun audio API (NetBSD and OpenBSD)
 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
-LIB_SND_BSD=$(LIB_SND_MODPLUG)
+LIB_SND_BSD=
 
 # DirectX and Win32 WAVE output (Win32)
 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
-LIB_SND_WIN=$(LIB_SND_MODPLUG)
+LIB_SND_WIN=
 
 # Qantourisc's 3D Realtime Acoustic Lib (3D RAS)
 OBJ_SND_3DRAS=snd_3dras.o
 LIB_SND_3DRAS=
 
-# CD objects
-OBJ_NOCD=cd_null.o
-
 
 ###### Common objects and flags #####
 
 # Common objects
 OBJ_COMMON= \
-       cap_avi.o \
-       cap_ogg.o \
+       bih.o \
+       crypto.o \
        cd_shared.o \
        cl_collision.o \
        cl_demo.o \
-       cl_dyntexture.o \
-       cl_gecko.o \
        cl_input.o \
        cl_main.o \
        cl_parse.o \
@@ -111,6 +98,8 @@ OBJ_COMMON= \
        filematch.o \
        fractalnoise.o \
        fs.o \
+       ft2.o \
+       utf8lib.o \
        gl_backend.o \
        gl_draw.o \
        gl_rmain.o \
@@ -128,13 +117,13 @@ OBJ_COMMON= \
        mathlib.o \
        matrixlib.o \
        mdfour.o \
-       menu.o \
        meshqueue.o \
+       mod_skeletal_animatevertices_sse.o \
+       mod_skeletal_animatevertices_generic.o \
        model_alias.o \
        model_brush.o \
        model_shared.o \
        model_sprite.o \
-       mvm_cmds.o \
        netconn.o \
        palette.o \
        polygon.o \
@@ -165,110 +154,96 @@ OBJ_COMMON= \
        world.o \
        zone.o
 
+OBJ_MENU= \
+       menu.o \
+       mvm_cmds.o
+
 # note that builddate.c is very intentionally not compiled to a .o before
 # being linked, because it should be recompiled every time an executable is
 # built to give the executable a proper date string
-OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_SND_NULL) $(OBJ_NOCD) $(OBJ_COMMON)
-OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
+OBJ_SV= builddate.c sys_linux.o vid_null.o thread_null.o $(OBJ_SND_NULL) $(OBJ_COMMON)
+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)
 
 
 # Compilation
-CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_CG) -Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement
+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../../../
+CFLAGS_CLIENT=-DCONFIG_MENU $(CFLAGS_VIDEO_CAPTURE)
+CFLAGS_SERVER=
 CFLAGS_DEBUG=-ggdb
 CFLAGS_PROFILE=-g -pg -ggdb -fprofile-arcs
 CFLAGS_RELEASE=
 CFLAGS_RELEASE_PROFILE=-fbranch-probabilities
-CFLAGS_SDL=$(SDLCONFIG_CFLAGS)
+CFLAGS_SDL=
+
+ifeq ($(DP_SSE),1)
+       CFLAGS_SSE=-msse
+       CFLAGS_SSE2=-msse2
+else
+       CFLAGS_SSE=
+       CFLAGS_SSE2=
+endif # ifeq ($(DP_SSE),1)
 
 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signaling-nans -fcx-limited-range -funroll-loops $(CPUOPTIMIZATIONS)
 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -funroll-loops $(CPUOPTIMIZATIONS)
-OPTIM_RELEASE=-O2 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
+#OPTIM_RELEASE=-O2 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
+OPTIM_RELEASE=-O3 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
 # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag
 
 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
 
 
 # Link
-LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=debug
-LDFLAGS_PROFILE=-g -pg -fprofile-arcs $(OPTIM_RELEASE) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=profile
-LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=release
+LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG) -DSVNREVISION=`{ test -d .svn && svnversion; } || { test -d .git && git describe --always; } || echo -` -DBUILDTYPE=debug
+LDFLAGS_PROFILE=-g -pg -fprofile-arcs $(OPTIM_RELEASE) -DSVNREVISION=`{ test -d .svn && svnversion; } || { test -d .git && git describe --always; } || echo -` -DBUILDTYPE=profile
+LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`{ test -d .svn && svnversion; } || { test -d .git && git describe --always; } || echo -` -DBUILDTYPE=release
 
 
 ##### UNIX specific variables #####
 
-OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
-
-LDFLAGS_UNIXCOMMON=-lm $(LIB_ODE) $(LIB_CG)
-LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
-LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl -lmodplug
-LDFLAGS_UNIXSV_PRELOAD=-lz -lcurl
-LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl -lmodplug
+LDFLAGS_UNIXCOMMON=-lm $(LIB_ODE) $(LIB_Z) $(LIB_JPEG) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL)
+LDFLAGS_UNIXSV_PRELOAD=-lz -ljpeg -lpng -lcurl
+LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl
 CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
 
-LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG)
-EXE_UNIXCL=darkplaces-glx
+LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS)
 EXE_UNIXSV=darkplaces-dedicated
 EXE_UNIXSDL=darkplaces-sdl
-EXE_UNIXCLNEXUIZ=nexuiz-glx
 EXE_UNIXSVNEXUIZ=nexuiz-dedicated
 EXE_UNIXSDLNEXUIZ=nexuiz-sdl
 
 CMD_UNIXRM=rm -rf
+CMD_UNIXCP=cp -f
+CMD_UNIXMKDIR=mkdir -p
 
 
 ##### Linux specific variables #####
 
-# If you want CD sound in Linux
-OBJ_LINUXCD=cd_linux.o
-# If you want no CD audio
-#OBJ_LINUXCD=$(OBJ_NOCD)
-
 # Link
-LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl $(LDFLAGS_UNIXCL)
 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl
 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl $(LDFLAGS_UNIXSDL)
 
 
 ##### Mac OS X specific variables #####
 
-# No CD support available
-OBJ_MACOSXCD=$(OBJ_NOCD)
-
 # Link
-LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit -framework Carbon $(LIB_SOUND)
 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
-LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(SDLCONFIG_STATICLIBS) SDLMain.m
-
-OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
-
-EXE_MACOSXCL=darkplaces-agl
-EXE_MACOSXCLNEXUIZ=nexuiz-agl
+LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit $(SDLCONFIG_STATICLIBS) ../../../SDLMain.m
 
 
 ##### SunOS specific variables #####
 
-# No CD support available
-OBJ_SUNOSCD=$(OBJ_NOCD)
-
 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
 
 # Link
-LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl -R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm $(LIB_SOUND)
 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl
 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -lrt -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
 
 
 ##### BSD specific variables #####
 
-#if you want CD sound in BSD
-OBJ_BSDCD=cd_bsd.o
-#if you want no CD audio
-#OBJ_BSDCD=$(OBJ_NOCD)
-
 # Link
-LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON) 
 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
 
@@ -276,202 +251,171 @@ LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
 ##### Win32 specific variables #####
 
 WINDRES ?= windres
-#if you want CD sound in Win32
-OBJ_WINCD=cd_win.o
-#if you want no CD audio
-#OBJ_WINCD=$(OBJ_NOCD)
-
-OBJ_WGL= builddate.c sys_win.o vid_wgl.o $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_COMMON)
 
 # Link
-# 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).
-LDFLAGS_WINCOMMON=-lws2_32 -Wl,--large-address-aware
-LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -lwinmm -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
-LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole -lwinmm
-LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(SDLCONFIG_LIBS) $(LIB_SND_MODPLUG)
-EXE_WINCL=darkplaces.exe
+# see LDFLAGS_WINCOMMON in makefile
+LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) -mconsole -lwinmm -lws2_32 $(LIB_Z) $(LIB_JPEG)
+LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL) $(SDLCONFIG_LIBS) -lwinmm -lws2_32 $(LIB_Z) $(LIB_JPEG)
 EXE_WINSV=darkplaces-dedicated.exe
 EXE_WINSDL=darkplaces-sdl.exe
-EXE_WINCLNEXUIZ=nexuiz.exe
 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
 
+VPATH := ../../../
 
 ##### Commands #####
 
 .PHONY : clean clean-profile help \
         debug profile release \
-        cl-debug cl-profile cl-release \
         sv-debug sv-profile sv-release \
         sdl-debug sdl-profile sdl-release
 
 help:
        @echo
        @echo "===== Choose one ====="
-       @echo "* $(MAKE) clean               : delete all files produced by the build except"
-       @echo "                             profiling information"
-       @echo "* $(MAKE) clean-profile       : delete all files produced by the build, including"
-       @echo "                             profiling informaiton"
-       @echo "* $(MAKE) help                : this help"
-       @echo "* $(MAKE) debug               : make client and server binaries (debug versions)"
-       @echo "* $(MAKE) profile             : make client and server binaries (profile versions)"
-       @echo "* $(MAKE) release             : make client and server binaries (release versions)"
-       @echo "* $(MAKE) release-profile     : make client and server binaries (release versions)"
-       @echo "                             with profileing optomizations) The profiled"
-       @echo "                             version of the program must have been"
-       @echo "                             previously compiled"
-       @echo "* $(MAKE) nexuiz              : make client and server binaries with nexuiz icon"
-       @echo "                             (release versions)"
-       @echo "* $(MAKE) cl-debug            : make client (debug version)"
-       @echo "* $(MAKE) cl-profile          : make client (profile version)"
-       @echo "* $(MAKE) cl-release          : make client (release version)"
-       @echo "* $(MAKE) cl-release-profile  : make client (release version)"
-       @echo "* $(MAKE) cl-nexuiz           : make client with nexuiz icon (release version)"
-       @echo "* $(MAKE) sv-debug            : make dedicated server (debug version)"
-       @echo "* $(MAKE) sv-profile          : make dedicated server (profile version)"
-       @echo "* $(MAKE) sv-release          : make dedicated server (release version)"
-       @echo "* $(MAKE) sv-release-profile  : make dedicated server (release version)"
-       @echo "* $(MAKE) sv-nexuiz           : make dedicated server with nexuiz icon"
-       @echo "                             (release version)"
-       @echo "* $(MAKE) sdl-debug           : make SDL client (debug version)"
-       @echo "* $(MAKE) sdl-profile         : make SDL client (profile version)"
-       @echo "* $(MAKE) sdl-profile-profile : make SDL client (profile version)"
-       @echo "* $(MAKE) sdl-release         : make SDL client (release version)"
-       @echo "* $(MAKE) sdl-nexuiz          : make SDL client with nexuiz icon (release version)"
+       @echo "* $(MAKE) clean                : delete all files produced by the build except"
+       @echo "                              profiling information"
+       @echo "* $(MAKE) clean-profile        : delete all files produced by the build, including"
+       @echo "                              profiling informaiton"
+       @echo "* $(MAKE) help                 : this help"
+       @echo "* $(MAKE) debug                : make client and server binaries (debug versions)"
+       @echo "* $(MAKE) profile              : make client and server binaries (profile versions)"
+       @echo "* $(MAKE) release              : make client and server binaries (release versions)"
+       @echo "* $(MAKE) release-profile      : make client and server binaries (release versions)"
+       @echo "                              (with profiling optimizations) The profiled"
+       @echo "                              version of the program must have been"
+       @echo "                              previously compiled"
+       @echo "* $(MAKE) nexuiz               : make client and server binaries with nexuiz icon"
+       @echo "                              (release versions)"
+       @echo "* $(MAKE) sv-debug             : make dedicated server (debug version)"
+       @echo "* $(MAKE) sv-profile           : make dedicated server (profile version)"
+       @echo "* $(MAKE) sv-release-profile   : make dedicated server (release profile version)"
+       @echo "* $(MAKE) sv-release           : make dedicated server (release version)"
+       @echo "* $(MAKE) sv-nexuiz            : make dedicated server with nexuiz icon"
+       @echo "                              (release version)"
+       @echo "* $(MAKE) sdl-debug            : make SDL client (debug version)"
+       @echo "* $(MAKE) sdl-profile          : make SDL client (profile version)"
+       @echo "* $(MAKE) sdl-release-profile  : make SDL client (release version)"
+       @echo "* $(MAKE) sdl-release          : make SDL client (release version)"
+       @echo "* $(MAKE) sdl-nexuiz           : make SDL client with nexuiz icon (release version)"
        @echo
 
 debug :
-       $(MAKE) sv-debug cl-debug sdl-debug
+       $(MAKE) $(TARGETS_DEBUG)
 
 profile :
-       $(MAKE) sv-profile cl-profile sdl-profile
+       $(MAKE) $(TARGETS_PROFILE)
 
 release :
-       $(MAKE) sv-release cl-release sdl-release
+       $(MAKE) $(TARGETS_RELEASE)
 
 release-profile :
-       $(MAKE) sv-release-profile cl-release-profile sdl-release-profile
+       $(MAKE) $(TARGETS_RELEASE_PROFILE)
 
 nexuiz :
-       $(MAKE) sv-nexuiz cl-nexuiz sdl-nexuiz
-
-cl-debug :
-       $(MAKE) bin-debug \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
-
-cl-profile :
-       $(MAKE) bin-profile \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
-
-cl-release :
-       $(MAKE) bin-release \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
-
-cl-release-profile :
-       $(MAKE) bin-release-profile \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
-
-cl-nexuiz :
-       $(MAKE) bin-release \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_CLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_CL)" LEVEL=1
+       $(MAKE) $(TARGETS_NEXUIZ)
 
 sv-debug :
        $(MAKE) bin-debug \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
 
 sv-profile :
        $(MAKE) bin-profile \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
 
 sv-release :
        $(MAKE) bin-release \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
 
 sv-release-profile :
        $(MAKE) bin-release-profile \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SV)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
 
 sv-nexuiz :
        $(MAKE) bin-release \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SVNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SV)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SVNEXUIZ)' CFLAGS_FEATURES='$(CFLAGS_SERVER)' LDFLAGS_COMMON='$(LDFLAGS_SV)' LEVEL=1
 
 sdl-debug :
        $(MAKE) bin-debug \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
 
 sdl-profile :
        $(MAKE) bin-profile \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
 
 sdl-release :
        $(MAKE) bin-release \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
 
 sdl-release-profile :
        $(MAKE) bin-release-profile \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SDL)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
 
 sdl-nexuiz :
        $(MAKE) bin-release \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               EXE="$(EXE_SDLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" LEVEL=1
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               EXE='$(EXE_SDLNEXUIZ)' CFLAGS_FEATURES='$(CFLAGS_CLIENT)' CFLAGS_SDL='$(SDLCONFIG_CFLAGS)' LDFLAGS_COMMON='$(LDFLAGS_SDL)' LEVEL=1
 
 bin-debug :
        $(CHECKLEVEL1)
        @echo
-       @echo "========== $(EXE) (debug) =========="
-       $(MAKE) $(EXE) \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
-               LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)" LEVEL=2
+       @echo '========== $(EXE) (debug) =========='
+       $(MAKE) prepare BUILD_DIR=build-obj/debug/$(EXE)
+       $(MAKE) -C build-obj/debug/$(EXE) $(EXE) \
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)'\
+               LDFLAGS='$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)' LEVEL=2
 
 bin-profile :
        $(CHECKLEVEL1)
        @echo
-       @echo "========== $(EXE) (profile) =========="
-       $(MAKE) $(EXE) \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
-               LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)" LEVEL=2
+       @echo '========== $(EXE) (profile) =========='
+       $(MAKE) prepare BUILD_DIR=build-obj/profile/$(EXE)
+       $(MAKE) -C build-obj/profile/$(EXE) $(EXE) \
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)'\
+               LDFLAGS='$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)' LEVEL=2
 
 bin-release :
        $(CHECKLEVEL1)
        @echo
-       @echo "========== $(EXE) (release) =========="
-       $(MAKE) $(EXE) \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
-               LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2
+       @echo '========== $(EXE) (release) =========='
+       $(MAKE) prepare BUILD_DIR=build-obj/release/$(EXE)
+       $(MAKE) -C build-obj/release/$(EXE) $(EXE) \
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)'\
+               LDFLAGS='$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)' LEVEL=2
        $(STRIP) $(EXE)
 
 bin-release-profile :
        $(CHECKLEVEL1)
        @echo
-       @echo "========== $(EXE) (release) =========="
-       $(MAKE) $(EXE) \
-               DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-               CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE_PROFILE) $(OPTIM_RELEASE)"\
-               LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2
+       @echo '========== $(EXE) (release) =========='
+       $(MAKE) prepare BUILD_DIR=build-obj/release-profile/$(EXE)
+       $(MAKE) -C build-obj/release-profile/$(EXE) $(EXE) \
+               DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+               CFLAGS='$(CFLAGS_COMMON) $(CFLAGS_FEATURES) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE_PROFILE) $(OPTIM_RELEASE)'\
+               LDFLAGS='$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)' LEVEL=2
        $(STRIP) $(EXE)
 
+prepare :
+       $(CMD_MKDIR) $(BUILD_DIR)
+       $(CMD_CP) makefile.inc $(BUILD_DIR)/
+       $(CMD_CP) $(MAKEFILE) $(BUILD_DIR)/
 
-snd_modplug.o: snd_modplug.c
+#this checks USEODE when compiling so it needs the ODE flags as well
+prvm_cmds.o: prvm_cmds.c
        $(CHECKLEVEL2)
-       $(DO_CC) $(CFLAGS_SND_MODPLUG)
+       $(DO_CC) $(CFLAGS_ODE)
 
 world.o: world.c
        $(CHECKLEVEL2)
@@ -481,25 +425,17 @@ vid_glx.o: vid_glx.c
        $(CHECKLEVEL2)
        $(DO_CC) -I/usr/X11R6/include
 
-vid_sdl.o: vid_sdl.c
-       $(CHECKLEVEL2)
-       $(DO_CC) $(CFLAGS_SDL)
-
-sys_sdl.o: sys_sdl.c
-       $(CHECKLEVEL2)
-       $(DO_CC) $(CFLAGS_SDL)
-
-snd_sdl.o: snd_sdl.c
+keysym2ucs.o: keysym2ucs.c
        $(CHECKLEVEL2)
-       $(DO_CC) $(CFLAGS_SDL)
+       $(DO_CC) -I/usr/X11R6/include
 
-snd_3dras.o: snd_3dras.c
+crypto.o: crypto.c
        $(CHECKLEVEL2)
-       $(DO_CC)
+       $(DO_CC) $(CFLAGS_CRYPTO) $(CFLAGS_CRYPTO_RIJNDAEL)
 
-cd_sdl.o: cd_sdl.c
+mod_skeletal_animatevertices_sse.o: mod_skeletal_animatevertices_sse.c
        $(CHECKLEVEL2)
-       $(DO_CC) $(CFLAGS_SDL)
+       $(DO_CC) $(CFLAGS_SSE)
 
 darkplaces.o: %.o : %.rc
        $(CHECKLEVEL2)
@@ -513,10 +449,6 @@ nexuiz.o: %.o : %.rc
        $(CHECKLEVEL2)
        $(DO_CC)
 
-$(EXE_CL): $(OBJ_CL) $(OBJ_ICON)
-       $(CHECKLEVEL2)
-       $(DO_LD)
-
 $(EXE_SV): $(OBJ_SV) $(OBJ_ICON)
        $(CHECKLEVEL2)
        $(DO_LD)
@@ -525,10 +457,6 @@ $(EXE_SDL): $(OBJ_SDL) $(OBJ_ICON)
        $(CHECKLEVEL2)
        $(DO_LD)
 
-$(EXE_CLNEXUIZ): $(OBJ_CL) $(OBJ_ICON_NEXUIZ)
-       $(CHECKLEVEL2)
-       $(DO_LD)
-
 $(EXE_SVNEXUIZ): $(OBJ_SV) $(OBJ_ICON_NEXUIZ)
        $(CHECKLEVEL2)
        $(DO_LD)
@@ -538,16 +466,14 @@ $(EXE_SDLNEXUIZ): $(OBJ_SDL) $(OBJ_ICON_NEXUIZ)
        $(DO_LD)
 
 clean:
-       -$(CMD_RM) $(EXE_CL)
        -$(CMD_RM) $(EXE_SV)
        -$(CMD_RM) $(EXE_SDL)
-       -$(CMD_RM) $(EXE_CLNEXUIZ)
        -$(CMD_RM) $(EXE_SVNEXUIZ)
        -$(CMD_RM) $(EXE_SDLNEXUIZ)
        -$(CMD_RM) *.o
        -$(CMD_RM) *.d
+       -$(CMD_RM) build-obj/
 
 clean-profile: clean
        -$(CMD_RM) *.gcda
        -$(CMD_RM) *.gcno
-