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
22 ###### Sound and audio CD #####
24 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o
27 OBJ_SND_NULL=snd_null.o
30 # Open Sound System (Linux, FreeBSD and Solaris)
31 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
34 # Advanced Linux Sound Architecture (Linux)
35 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
38 # Core Audio (Mac OS X)
39 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.c
40 LIB_SND_COREAUDIO=-framework CoreAudio
42 # BSD / Sun audio API (NetBSD and OpenBSD)
43 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
46 # DirectX and Win32 WAVE output (Win32)
47 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
55 ###### Common objects and flags #####
133 # note that builddate.c is very intentionally not compiled to a .o before
134 # being linked, because it should be recompiled every time an executable is
135 # built to give the executable a proper date string
136 OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_SND_NULL) $(OBJ_NOCD) $(OBJ_COMMON)
137 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
141 CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) -Wall -Wsign-compare -Wdeclaration-after-statement
143 CFLAGS_PROFILE=-g -pg -ggdb
145 CFLAGS_SDL=`$(SDL_CONFIG) --cflags`
147 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
148 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
149 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signaling-nans -fcx-limited-range -funroll-loops $(CPUOPTIMIZATIONS)
150 #OPTIM_RELEASE=-O2 -fno-strict-aliasing -funroll-loops $(CPUOPTIMIZATIONS)
151 OPTIM_RELEASE=-O2 -fno-strict-aliasing $(CPUOPTIMIZATIONS)
153 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
157 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG)
158 LDFLAGS_PROFILE=-g -pg $(OPTIM_RELEASE)
159 LDFLAGS_RELEASE=$(OPTIM_RELEASE)
162 ##### UNIX specific variables #####
164 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
166 LDFLAGS_UNIXCOMMON=-lm
167 LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
168 LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -lvorbis -lvorbisfile -lcurl
169 LDFLAGS_UNIXSV_PRELOAD=-lz -lcurl
170 LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -lvorbis -lvorbisfile -lcurl
171 CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
173 LDFLAGS_UNIXSDL=`$(SDL_CONFIG) --libs`
174 EXE_UNIXCL=darkplaces-glx
175 EXE_UNIXSV=darkplaces-dedicated
176 EXE_UNIXSDL=darkplaces-sdl
177 EXE_UNIXCLNEXUIZ=nexuiz-glx
178 EXE_UNIXSVNEXUIZ=nexuiz-dedicated
179 EXE_UNIXSDLNEXUIZ=nexuiz-sdl
184 ##### Linux specific variables #####
186 # If you want CD sound in Linux
187 OBJ_LINUXCD=cd_linux.o
188 # If you want no CD audio
189 #OBJ_LINUXCD=$(OBJ_NOCD)
192 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
193 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
194 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
197 ##### Mac OS X specific variables #####
199 # No CD support available
200 OBJ_MACOSXCD=$(OBJ_NOCD)
203 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework IOKit -framework Carbon $(LIB_SOUND)
204 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
205 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl `$(SDL_CONFIG) --static-libs`
207 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
209 EXE_MACOSXCL=darkplaces-agl
210 EXE_MACOSXCLNEXUIZ=nexuiz-agl
213 ##### SunOS specific variables #####
215 # No CD support available
216 OBJ_SUNOSCD=$(OBJ_NOCD)
218 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
221 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl -R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86vm $(LIB_SOUND)
222 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl
223 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
226 ##### BSD specific variables #####
228 #if you want CD sound in BSD
230 #if you want no CD audio
231 #OBJ_BSDCD=$(OBJ_NOCD)
234 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
235 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
236 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
239 ##### Win32 specific variables #####
241 #if you want CD sound in Win32
243 #if you want no CD audio
244 #OBJ_WINCD=$(OBJ_NOCD)
246 OBJ_WGL= builddate.c sys_win.o vid_wgl.o conproc.o $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_COMMON)
249 LDFLAGS_WINCOMMON=-lwinmm -lwsock32
250 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
251 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole
252 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) `$(SDL_CONFIG) --libs`
253 EXE_WINCL=darkplaces.exe
254 EXE_WINSV=darkplaces-dedicated.exe
255 EXE_WINSDL=darkplaces-sdl.exe
256 EXE_WINCLNEXUIZ=nexuiz.exe
257 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
258 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
263 .PHONY : clean help \
264 debug profile release \
265 cl-debug cl-profile cl-release \
266 sv-debug sv-profile sv-release \
267 sdl-debug sdl-profile sdl-release
271 @echo "===== Choose one ====="
272 @echo "* $(MAKE) clean : delete all files produced by the build"
273 @echo "* $(MAKE) help : this help"
274 @echo "* $(MAKE) debug : make client and server binaries (debug versions)"
275 @echo "* $(MAKE) profile : make client and server binaries (profile versions)"
276 @echo "* $(MAKE) release : make client and server binaries (release versions)"
277 @echo "* $(MAKE) nexuiz : make client and server binaries with nexuiz icon (release versions)"
278 @echo "* $(MAKE) cl-debug : make client (debug version)"
279 @echo "* $(MAKE) cl-profile : make client (profile version)"
280 @echo "* $(MAKE) cl-release : make client (release version)"
281 @echo "* $(MAKE) cl-nexuiz : make client with nexuiz icon (release version)"
282 @echo "* $(MAKE) sv-debug : make dedicated server (debug version)"
283 @echo "* $(MAKE) sv-profile : make dedicated server (profile version)"
284 @echo "* $(MAKE) sv-release : make dedicated server (release version)"
285 @echo "* $(MAKE) sv-nexuiz : make dedicated server with nexuiz icon (release version)"
286 @echo "* $(MAKE) sdl-debug : make SDL client (debug version)"
287 @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
288 @echo "* $(MAKE) sdl-release : make SDL client (release version)"
289 @echo "* $(MAKE) sdl-nexuiz : make SDL client with nexuiz icon (release version)"
293 $(MAKE) sv-debug cl-debug sdl-debug
296 $(MAKE) sv-profile cl-profile sdl-profile
299 $(MAKE) sv-release cl-release sdl-release
302 $(MAKE) sv-nexuiz cl-nexuiz sdl-nexuiz
306 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
307 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
310 $(MAKE) bin-profile \
311 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
312 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
315 $(MAKE) bin-release \
316 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
317 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
320 $(MAKE) bin-release \
321 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
322 EXE="$(EXE_CLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
326 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
327 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
330 $(MAKE) bin-profile \
331 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
332 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
335 $(MAKE) bin-release \
336 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
337 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
340 $(MAKE) bin-release \
341 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
342 EXE="$(EXE_SVNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
346 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
347 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
350 $(MAKE) bin-profile \
351 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
352 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
355 $(MAKE) bin-release \
356 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
357 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
360 $(MAKE) bin-release \
361 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
362 EXE="$(EXE_SDLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
366 @echo "========== $(EXE) (debug) =========="
368 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
369 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
370 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
374 @echo "========== $(EXE) (profile) =========="
376 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
377 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
378 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
382 @echo "========== $(EXE) (release) =========="
384 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
385 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
386 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
390 $(DO_CC) -I/usr/X11R6/include
393 $(DO_CC) $(CFLAGS_SDL)
396 $(DO_CC) $(CFLAGS_SDL)
399 $(DO_CC) $(CFLAGS_SDL)
402 $(DO_CC) $(CFLAGS_SDL)
404 darkplaces.o: %.o : %.rc
413 $(EXE_CL): $(OBJ_CL) $(OBJ_ICON)
416 $(EXE_SV): $(OBJ_SV) $(OBJ_ICON)
419 $(EXE_SDL): $(OBJ_SDL) $(OBJ_ICON)
422 $(EXE_CLNEXUIZ): $(OBJ_CL) $(OBJ_ICON_NEXUIZ)
425 $(EXE_SVNEXUIZ): $(OBJ_SV) $(OBJ_ICON_NEXUIZ)
428 $(EXE_SDLNEXUIZ): $(OBJ_SDL) $(OBJ_ICON_NEXUIZ)
434 -$(CMD_RM) $(EXE_SDL)
435 -$(CMD_RM) $(EXE_CLNEXUIZ)
436 -$(CMD_RM) $(EXE_SVNEXUIZ)
437 -$(CMD_RM) $(EXE_SDLNEXUIZ)