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)
20 ###### Sound and audio CD #####
22 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o
25 OBJ_SND_NULL=snd_null.o
28 # Open Sound System (Linux, FreeBSD and Solaris)
29 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
32 # Advanced Linux Sound Architecture (Linux)
33 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
36 # Core Audio (Mac OS X)
37 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.c
38 LIB_SND_COREAUDIO=-framework CoreAudio
40 # BSD / Sun audio API (NetBSD and OpenBSD)
41 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
44 # DirectX and Win32 WAVE output (Win32)
45 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
53 ###### 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=-MD -Wall -Werror
142 CFLAGS_COMMON=-MD -Wall -Wsign-compare
144 CFLAGS_PROFILE=-g -pg -ggdb
147 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
148 OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
150 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
154 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG)
155 LDFLAGS_PROFILE=-g -pg $(OPTIM_RELEASE)
156 LDFLAGS_RELEASE=$(OPTIM_RELEASE)
159 ##### UNIX specific variables #####
161 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
163 LDFLAGS_UNIXCOMMON=-lm
164 #LDFLAGS_UNIXCL=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
165 ifeq ($(DP_MAKE_TARGET), sunos)
166 LDFLAGS_UNIXCL=-R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86vm $(LIB_SOUND)
168 LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
171 LDFLAGS_UNIXSDL=`sdl-config --libs`
172 EXE_UNIXCL=darkplaces-glx
173 EXE_UNIXSV=darkplaces-dedicated
174 EXE_UNIXSDL=darkplaces-sdl
175 EXE_UNIXCLNEXUIZ=nexuiz-glx
176 EXE_UNIXSVNEXUIZ=nexuiz-dedicated
177 EXE_UNIXSDLNEXUIZ=nexuiz-sdl
182 ##### Linux specific variables #####
184 # If you want CD sound in Linux
185 OBJ_LINUXCD=cd_linux.o
186 # If you want no CD audio
187 #OBJ_LINUXCD=$(OBJ_NOCD)
190 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
191 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
192 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
195 ##### Mac OS X specific variables #####
197 # No CD support available
198 OBJ_MACOSXCD=$(OBJ_NOCD)
201 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework Carbon $(LIB_SOUND)
202 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
203 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl `sdl-config --static-libs`
205 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
207 EXE_MACOSXCL=darkplaces-agl
210 ##### SunOS specific variables #####
212 # No CD support available
213 OBJ_SUNOSCD=$(OBJ_NOCD)
215 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
218 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXCL)
219 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl
220 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
223 ##### BSD specific variables #####
225 #if you want CD sound in BSD
227 #if you want no CD audio
228 #OBJ_BSDCD=$(OBJ_NOCD)
231 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
232 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
233 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
236 ##### Win32 specific variables #####
238 #if you want CD sound in Win32
240 #if you want no CD audio
241 #OBJ_WINCD=$(OBJ_NOCD)
243 OBJ_WGL= builddate.c sys_win.o vid_wgl.o conproc.o $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_COMMON)
246 LDFLAGS_WINCOMMON=-lwinmm -lwsock32
247 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
248 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole
249 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) `sdl-config --libs`
250 EXE_WINCL=darkplaces.exe
251 EXE_WINSV=darkplaces-dedicated.exe
252 EXE_WINSDL=darkplaces-sdl.exe
253 EXE_WINCLNEXUIZ=nexuiz.exe
254 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
255 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
260 .PHONY : clean help \
261 debug profile release \
262 cl-debug cl-profile cl-release \
263 sv-debug sv-profile sv-release \
264 sdl-debug sdl-profile sdl-release
268 @echo "===== Choose one ====="
269 @echo "* $(MAKE) clean : delete all files produced by the build"
270 @echo "* $(MAKE) help : this help"
271 @echo "* $(MAKE) debug : make client and server binaries (debug versions)"
272 @echo "* $(MAKE) profile : make client and server binaries (profile versions)"
273 @echo "* $(MAKE) release : make client and server binaries (release versions)"
274 @echo "* $(MAKE) nexuiz : make client and server binaries with nexuiz icon (release versions)"
275 @echo "* $(MAKE) cl-debug : make client (debug version)"
276 @echo "* $(MAKE) cl-profile : make client (profile version)"
277 @echo "* $(MAKE) cl-release : make client (release version)"
278 @echo "* $(MAKE) cl-nexuiz : make client with nexuiz icon (release version)"
279 @echo "* $(MAKE) sv-debug : make dedicated server (debug version)"
280 @echo "* $(MAKE) sv-profile : make dedicated server (profile version)"
281 @echo "* $(MAKE) sv-release : make dedicated server (release version)"
282 @echo "* $(MAKE) sv-nexuiz : make dedicated server with nexuiz icon (release version)"
283 @echo "* $(MAKE) sdl-debug : make SDL client (debug version)"
284 @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
285 @echo "* $(MAKE) sdl-release : make SDL client (release version)"
286 @echo "* $(MAKE) sdl-nexuiz : make SDL client with nexuiz icon (release version)"
290 $(MAKE) sv-debug cl-debug sdl-debug
293 $(MAKE) sv-profile cl-profile sdl-profile
296 $(MAKE) sv-release cl-release sdl-release
299 $(MAKE) sv-nexuiz cl-nexuiz sdl-nexuiz
303 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
304 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
307 $(MAKE) bin-profile \
308 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
309 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
312 $(MAKE) bin-release \
313 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
314 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
317 $(MAKE) bin-release \
318 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
319 EXE="$(EXE_CLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
323 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
324 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
327 $(MAKE) bin-profile \
328 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
329 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
332 $(MAKE) bin-release \
333 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
334 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
337 $(MAKE) bin-release \
338 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
339 EXE="$(EXE_SVNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
343 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
344 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
347 $(MAKE) bin-profile \
348 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
349 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
352 $(MAKE) bin-release \
353 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
354 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
357 $(MAKE) bin-release \
358 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
359 EXE="$(EXE_SDLNEXUIZ)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
363 @echo "========== $(EXE) (debug) =========="
365 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
366 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
367 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
371 @echo "========== $(EXE) (profile) =========="
373 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
374 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
375 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
379 @echo "========== $(EXE) (release) =========="
381 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
382 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
383 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
387 $(DO_CC) -I/usr/X11R6/include
390 $(DO_CC) `sdl-config --cflags`
393 $(DO_CC) `sdl-config --cflags`
396 $(DO_CC) `sdl-config --cflags`
399 $(DO_CC) `sdl-config --cflags`
401 darkplaces.o: %.o : %.rc
410 $(EXE_CL): $(OBJ_CL) $(OBJ_ICON)
413 $(EXE_SV): $(OBJ_SV) $(OBJ_ICON)
416 $(EXE_SDL): $(OBJ_SDL) $(OBJ_ICON)
419 $(EXE_CLNEXUIZ): $(OBJ_CL) $(OBJ_ICON_NEXUIZ)
422 $(EXE_SVNEXUIZ): $(OBJ_SV) $(OBJ_ICON_NEXUIZ)
425 $(EXE_SDLNEXUIZ): $(OBJ_SDL) $(OBJ_ICON_NEXUIZ)
431 -$(CMD_RM) $(EXE_SDL)
432 -$(CMD_RM) $(EXE_CLNEXUIZ)
433 -$(CMD_RM) $(EXE_SVNEXUIZ)
434 -$(CMD_RM) $(EXE_SDLNEXUIZ)