1 ##### DP_MAKE_TARGET autodetection and arch specific variables #####
11 DP_ARCH:=$(shell uname)
12 ifneq ($(filter %BSD,$(DP_ARCH)),)
15 ifeq ($(DP_ARCH), Darwin)
18 ifeq ($(DP_ARCH), SunOS)
23 endif # ifeq ($(DP_ARCH), SunOS)
24 endif # ifeq ($(DP_ARCH), Darwin)
25 endif # ifneq ($(filter %BSD,$(DP_ARCH)),)
27 endif # ifndef DP_MAKE_TARGET
29 # If we're not on compiling for Win32, we need additional information
30 ifneq ($(DP_MAKE_TARGET), mingw)
31 DP_ARCH:=$(shell uname)
32 DP_MACHINE:=$(shell uname -m)
46 CMD_MKDIR=$(CMD_UNIXMKDIR)
49 # 64bits AMD CPUs use another lib directory
50 ifeq ($(DP_MACHINE),x86_64)
51 UNIX_X11LIBPATH:=/usr/X11R6/lib64
53 UNIX_X11LIBPATH:=/usr/X11R6/lib
57 TARGETS_DEBUG=sv-debug cl-debug sdl-debug
58 TARGETS_PROFILE=sv-profile cl-profile sdl-profile
59 TARGETS_RELEASE=sv-release cl-release sdl-release
60 TARGETS_RELEASE_PROFILE=sv-release-profile cl-release-profile sdl-release-profile
61 TARGETS_NEXUIZ=sv-nexuiz cl-nexuiz sdl-nexuiz
63 ###### Optional features #####
65 ifeq ($(DP_CDDA), enabled)
66 OBJ_SDLCD=$(OBJ_CD_COMMON) cd_sdl.o
67 OBJ_LINUXCD=$(OBJ_CD_COMMON) cd_linux.o
68 OBJ_BSDCD=$(OBJ_CD_COMMON) cd_bsd.o
69 OBJ_WINCD=$(OBJ_CD_COMMON) cd_win.o
71 OBJ_SDLCD=$(OBJ_CD_COMMON) $(OBJ_NOCD)
72 OBJ_LINUXCD=$(OBJ_CD_COMMON) $(OBJ_NOCD)
73 OBJ_BSDCD=$(OBJ_CD_COMMON) $(OBJ_NOCD)
74 OBJ_WINCD=$(OBJ_CD_COMMON) $(OBJ_NOCD)
77 DP_VIDEO_CAPTURE?=enabled
78 ifeq ($(DP_VIDEO_CAPTURE), enabled)
79 CFLAGS_VIDEO_CAPTURE=-DCONFIG_VIDEO_CAPTURE
80 OBJ_VIDEO_CAPTURE= cap_avi.o cap_ogg.o
87 ifeq ($(DP_MAKE_TARGET), linux)
95 LDFLAGS_CL=$(LDFLAGS_LINUXCL)
96 LDFLAGS_SV=$(LDFLAGS_LINUXSV)
97 LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
99 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
100 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
101 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
105 EXE_SDL=$(EXE_UNIXSDL)
106 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
107 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
108 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
113 DP_LINK_CRYPTO?=dlopen
114 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
117 # Mac OS X configuration
118 ifeq ($(DP_MAKE_TARGET), macosx)
119 DEFAULT_SNDAPI=COREAUDIO
120 OBJ_CD=$(OBJ_MACOSXCD)
126 LDFLAGS_CL=$(LDFLAGS_MACOSXCL)
127 LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
128 LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
130 SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
131 SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
132 SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
134 EXE_CL=$(EXE_MACOSXCL)
136 EXE_SDL=$(EXE_UNIXSDL)
137 EXE_CLNEXUIZ=$(EXE_MACOSXCLNEXUIZ)
138 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
139 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
141 ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
148 DP_LINK_CRYPTO?=dlopen
149 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
151 # on OS X, we don't build the CL by default because it uses deprecated
152 # and not-implemented-in-64bit Carbon
153 TARGETS_DEBUG=sv-debug sdl-debug
154 TARGETS_PROFILE=sv-profile sdl-profile
155 TARGETS_RELEASE=sv-release sdl-release
156 TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
157 TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
160 # SunOS configuration (Solaris)
161 ifeq ($(DP_MAKE_TARGET), sunos)
163 OBJ_CD=$(OBJ_SUNOSCD)
169 CFLAGS_EXTRA=$(CFLAGS_SUNOS)
171 LDFLAGS_CL=$(LDFLAGS_SUNOSCL)
172 LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
173 LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
175 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
176 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
177 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
181 EXE_SDL=$(EXE_UNIXSDL)
182 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
183 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
184 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
189 DP_LINK_CRYPTO?=dlopen
190 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
194 ifeq ($(DP_MAKE_TARGET), bsd)
195 ifeq ($(DP_ARCH),FreeBSD)
206 LDFLAGS_CL=$(LDFLAGS_BSDCL)
207 LDFLAGS_SV=$(LDFLAGS_BSDSV)
208 LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
210 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
211 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
212 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
216 EXE_SDL=$(EXE_UNIXSDL)
217 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
218 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
219 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
224 DP_LINK_CRYPTO?=dlopen
225 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
228 # Win32 configuration
229 ifeq ($(WIN32RELEASE), 1)
230 # TARGET=i686-pc-mingw32
232 # WINDRES=$(TARGET)-windres
233 CPUOPTIMIZATIONS=-march=i686 -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
234 # CPUOPTIMIZATIONS+=-DUSE_WSPIAPI_H -DSUPPORTIPV6
235 LDFLAGS_WINCOMMON=-Wl,--large-address-aware
240 ifeq ($(WIN64RELEASE), 1)
241 # TARGET=x86_64-pc-mingw32
243 # WINDRES=$(TARGET)-windres
247 CFLAGS_D3D=-DSUPPORTD3D -DSUPPORTDIRECTX
248 CFLAGS_WARNINGS=-Wall
252 CFLAGS_WARNINGS=-Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement -Wmissing-prototypes
257 ifeq ($(DP_MAKE_TARGET), mingw)
262 OBJ_ICON=darkplaces.o
263 OBJ_ICON_NEXUIZ=nexuiz.o
265 LDFLAGS_CL=$(LDFLAGS_WINCL)
266 LDFLAGS_SV=$(LDFLAGS_WINSV)
267 LDFLAGS_SDL=$(LDFLAGS_WINSDL)
269 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
270 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
271 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
275 EXE_SDL=$(EXE_WINSDL)
276 EXE_CLNEXUIZ=$(EXE_WINCLNEXUIZ)
277 EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
278 EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
283 DP_LINK_CRYPTO?=dlopen
284 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
287 # set these to "" if you want to use dynamic loading instead
289 ifeq ($(DP_LINK_ZLIB), shared)
290 CFLAGS_LIBZ=-DLINK_TO_ZLIB
293 ifeq ($(DP_LINK_ZLIB), dlopen)
299 ifeq ($(DP_LINK_JPEG), shared)
300 CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
303 ifeq ($(DP_LINK_JPEG), dlopen)
309 ifeq ($(DP_LINK_ODE), shared)
310 ODE_CONFIG?=ode-config
311 LIB_ODE=`$(ODE_CONFIG) --libs`
312 CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE
314 ifeq ($(DP_LINK_ODE), dlopen)
320 ifeq ($(DP_LINK_CRYPTO), shared)
321 LIB_CRYPTO=-ld0_blind_id
322 CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
324 ifeq ($(DP_LINK_CRYPTO), dlopen)
328 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), shared)
329 LIB_CRYPTO_RIJNDAEL=-ld0_rijndael
330 CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
332 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), dlopen)
334 CFLAGS_CRYPTO_RIJNDAEL=
337 ##### Sound configuration #####
340 DP_SOUND_API=$(DEFAULT_SNDAPI)
344 ifeq ($(DP_SOUND_API), NULL)
345 OBJ_SOUND=$(OBJ_SND_NULL)
346 LIB_SOUND=$(LIB_SND_NULL)
349 # OSS: Open Sound System
350 ifeq ($(DP_SOUND_API), OSS)
351 OBJ_SOUND=$(OBJ_SND_OSS)
352 LIB_SOUND=$(LIB_SND_OSS)
355 # ALSA: Advanced Linux Sound Architecture
356 ifeq ($(DP_SOUND_API), ALSA)
357 OBJ_SOUND=$(OBJ_SND_ALSA)
358 LIB_SOUND=$(LIB_SND_ALSA)
361 # COREAUDIO: Core Audio
362 ifeq ($(DP_SOUND_API), COREAUDIO)
363 OBJ_SOUND=$(OBJ_SND_COREAUDIO)
364 LIB_SOUND=$(LIB_SND_COREAUDIO)
367 # BSD: BSD / Sun audio API
368 ifeq ($(DP_SOUND_API), BSD)
369 OBJ_SOUND=$(OBJ_SND_BSD)
370 LIB_SOUND=$(LIB_SND_BSD)
373 # WIN: DirectX and Win32 WAVE output
374 ifeq ($(DP_SOUND_API), WIN)
375 OBJ_SOUND=$(OBJ_SND_WIN)
376 LIB_SOUND=$(LIB_SND_WIN)
379 ifeq ($(DP_SOUND_API),3DRAS)
380 OBJ_SOUND=$(OBJ_SND_3DRAS)
381 LIB_SOUND=$(LIB_SND_3DRAS)
384 ##### Extra CFLAGS #####
388 CFLAGS_FS=-DDP_FS_BASEDIR=\"$(DP_FS_BASEDIR)\"
394 ifneq ($(DP_MAKE_TARGET), mingw)
395 ifdef DP_PRELOAD_DEPENDENCIES
396 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
397 # dynamically so they won't get loaded at runtime using dlopen
398 LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
399 LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
400 LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
401 CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
405 ##### GNU Make specific definitions #####
407 DO_LD=$(CC) -o ../../../$@ $^ $(LDFLAGS)
410 ##### Definitions shared by all makefiles #####
414 ##### Dependency files #####
418 # hack to deal with no-longer-needed .h files
421 @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
422 @echo "HINT: consider 'make clean'"