1 # Choose the compiler you want to use
5 #CPUOPTIMIZATIONS=-march=athlon
6 # athlon xp optimizations
7 #CPUOPTIMIZATIONS=-march=athlon-xp
8 # athlon 64 optimizations
9 #CPUOPTIMIZATIONS=-march=athlon64 -m32
10 # Pentium 3 optimizations
11 #CPUOPTIMIZATIONS=-march=pentium3
12 # Pentium 4 optimizations
13 #CPUOPTIMIZATIONS=-march=pentium4
14 # 686 (Pentium Pro/II) optimizations
15 #CPUOPTIMIZATIONS=-march=i686
16 # No specific CPU (386 compatible)
19 SDL_CONFIG?=sdl-config
20 SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags`
21 SDLCONFIG_UNIXLIBS?=`$(SDL_CONFIG) --libs`
22 SDLCONFIG_UNIXSTATICLIBS?=`$(SDL_CONFIG) --static-libs`
23 SDLCONFIG_MACOSXCFLAGS=
24 SDLCONFIG_MACOSXLIBS=-framework SDL -framework Cocoa
25 SDLCONFIG_MACOSXSTATICLIBS=-framework SDL -framework Cocoa
29 ###### Sound and audio CD #####
31 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o snd_modplug.o
34 OBJ_SND_NULL=snd_null.o
37 # Open Sound System (Linux, FreeBSD and Solaris)
38 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
41 # Advanced Linux Sound Architecture (Linux)
42 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
45 # Core Audio (Mac OS X)
46 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.c
47 LIB_SND_COREAUDIO=-framework CoreAudio
49 # BSD / Sun audio API (NetBSD and OpenBSD)
50 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
53 # DirectX and Win32 WAVE output (Win32)
54 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
62 ###### Common objects and flags #####
141 # note that builddate.c is very intentionally not compiled to a .o before
142 # being linked, because it should be recompiled every time an executable is
143 # built to give the executable a proper date string
144 OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_SND_NULL) $(OBJ_NOCD) $(OBJ_COMMON)
145 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
149 CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) -Wall -Wsign-compare -Wdeclaration-after-statement
151 CFLAGS_PROFILE=-g -pg -ggdb
153 CFLAGS_SDL=$(SDLCONFIG_CFLAGS)
155 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
156 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
157 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signaling-nans -fcx-limited-range -funroll-loops $(CPUOPTIMIZATIONS)
158 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -funroll-loops $(CPUOPTIMIZATIONS)
159 OPTIM_RELEASE=-O2 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
161 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
165 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG)
166 LDFLAGS_PROFILE=-g -pg $(OPTIM_RELEASE)
167 LDFLAGS_RELEASE=$(OPTIM_RELEASE)
170 ##### UNIX specific variables #####
172 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
174 LDFLAGS_UNIXCOMMON=-lm
175 LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
176 LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -lvorbis -lvorbisfile -lcurl -lmodplug
177 LDFLAGS_UNIXSV_PRELOAD=-lz -lcurl
178 LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -lvorbis -lvorbisfile -lcurl -lmodplug
179 CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
181 LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS)
182 EXE_UNIXCL=darkplaces-glx
183 EXE_UNIXSV=darkplaces-dedicated
184 EXE_UNIXSDL=darkplaces-sdl
185 EXE_UNIXCLNEXUIZ=nexuiz-glx
186 EXE_UNIXSVNEXUIZ=nexuiz-dedicated
187 EXE_UNIXSDLNEXUIZ=nexuiz-sdl
192 ##### Linux specific variables #####
194 # If you want CD sound in Linux
195 OBJ_LINUXCD=cd_linux.o
196 # If you want no CD audio
197 #OBJ_LINUXCD=$(OBJ_NOCD)
200 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
201 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
202 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
205 ##### Mac OS X specific variables #####
207 # No CD support available
208 OBJ_MACOSXCD=$(OBJ_NOCD)
211 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit -framework Carbon $(LIB_SOUND)
212 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
213 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(SDLCONFIG_STATICLIBS) SDLMain.m
215 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
217 EXE_MACOSXCL=darkplaces-agl
218 EXE_MACOSXCLNEXUIZ=nexuiz-agl
221 ##### SunOS specific variables #####
223 # No CD support available
224 OBJ_SUNOSCD=$(OBJ_NOCD)
226 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
229 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl -R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm $(LIB_SOUND)
230 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl
231 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
234 ##### BSD specific variables #####
236 #if you want CD sound in BSD
238 #if you want no CD audio
239 #OBJ_BSDCD=$(OBJ_NOCD)
242 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
243 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
244 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
247 ##### Win32 specific variables #####
250 #if you want CD sound in Win32
252 #if you want no CD audio
253 #OBJ_WINCD=$(OBJ_NOCD)
255 OBJ_WGL= builddate.c sys_win.o vid_wgl.o conproc.o $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_COMMON)
258 # 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).
259 LDFLAGS_WINCOMMON=-lws2_32 -Wl,--large-address-aware
260 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -lwinmm -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
261 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole -lwinmm
262 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) $(SDLCONFIG_LIBS)
263 EXE_WINCL=darkplaces.exe
264 EXE_WINSV=darkplaces-dedicated.exe
265 EXE_WINSDL=darkplaces-sdl.exe
266 EXE_WINCLNEXUIZ=nexuiz.exe
267 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
268 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
273 .PHONY : clean help \
274 debug profile release \
275 cl-debug cl-profile cl-release \
276 sv-debug sv-profile sv-release \
277 sdl-debug sdl-profile sdl-release
281 @echo "===== Choose one ====="
282 @echo "* $(MAKE) clean : delete all files produced by the build"
283 @echo "* $(MAKE) help : this help"
284 @echo "* $(MAKE) debug : make client and server binaries (debug versions)"
285 @echo "* $(MAKE) profile : make client and server binaries (profile versions)"
286 @echo "* $(MAKE) release : make client and server binaries (release versions)"
287 @echo "* $(MAKE) nexuiz : make client and server binaries with nexuiz icon (release versions)"
288 @echo "* $(MAKE) cl-debug : make client (debug version)"
289 @echo "* $(MAKE) cl-profile : make client (profile version)"
290 @echo "* $(MAKE) cl-release : make client (release version)"
291 @echo "* $(MAKE) cl-nexuiz : make client with nexuiz icon (release version)"
292 @echo "* $(MAKE) sv-debug : make dedicated server (debug version)"
293 @echo "* $(MAKE) sv-profile : make dedicated server (profile version)"
294 @echo "* $(MAKE) sv-release : make dedicated server (release version)"
295 @echo "* $(MAKE) sv-nexuiz : make dedicated server with nexuiz icon (release version)"
296 @echo "* $(MAKE) sdl-debug : make SDL client (debug version)"
297 @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
298 @echo "* $(MAKE) sdl-release : make SDL client (release version)"
299 @echo "* $(MAKE) sdl-nexuiz : make SDL client with nexuiz icon (release version)"
303 $(MAKE) sv-debug cl-debug sdl-debug
306 $(MAKE) sv-profile cl-profile sdl-profile
309 $(MAKE) sv-release cl-release sdl-release
312 $(MAKE) sv-nexuiz cl-nexuiz sdl-nexuiz
316 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
317 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
320 $(MAKE) bin-profile \
321 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
322 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
325 $(MAKE) bin-release \
326 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
327 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
330 $(MAKE) bin-release \
331 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
332 EXE="$(EXE_CLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
336 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
337 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
340 $(MAKE) bin-profile \
341 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
342 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
345 $(MAKE) bin-release \
346 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
347 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
350 $(MAKE) bin-release \
351 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
352 EXE="$(EXE_SVNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
356 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
357 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
360 $(MAKE) bin-profile \
361 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
362 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
365 $(MAKE) bin-release \
366 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
367 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
370 $(MAKE) bin-release \
371 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
372 EXE="$(EXE_SDLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
376 @echo "========== $(EXE) (debug) =========="
378 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
379 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
380 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
384 @echo "========== $(EXE) (profile) =========="
386 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
387 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
388 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
392 @echo "========== $(EXE) (release) =========="
394 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
395 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
396 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
400 $(DO_CC) -I/usr/X11R6/include
403 $(DO_CC) $(CFLAGS_SDL)
406 $(DO_CC) $(CFLAGS_SDL)
409 $(DO_CC) $(CFLAGS_SDL)
412 $(DO_CC) $(CFLAGS_SDL)
414 darkplaces.o: %.o : %.rc
423 $(EXE_CL): $(OBJ_CL) $(OBJ_ICON)
426 $(EXE_SV): $(OBJ_SV) $(OBJ_ICON)
429 $(EXE_SDL): $(OBJ_SDL) $(OBJ_ICON)
432 $(EXE_CLNEXUIZ): $(OBJ_CL) $(OBJ_ICON_NEXUIZ)
435 $(EXE_SVNEXUIZ): $(OBJ_SV) $(OBJ_ICON_NEXUIZ)
438 $(EXE_SDLNEXUIZ): $(OBJ_SDL) $(OBJ_ICON_NEXUIZ)
444 -$(CMD_RM) $(EXE_SDL)
445 -$(CMD_RM) $(EXE_CLNEXUIZ)
446 -$(CMD_RM) $(EXE_SVNEXUIZ)
447 -$(CMD_RM) $(EXE_SDLNEXUIZ)