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)
36 # Command used to delete files
43 # 64bits AMD CPUs use another lib directory
44 ifeq ($(DP_MACHINE),x86_64)
45 UNIX_X11LIBPATH:=/usr/X11R6/lib64
47 UNIX_X11LIBPATH:=/usr/X11R6/lib
51 TARGETS_DEBUG=sv-debug cl-debug sdl-debug
52 TARGETS_PROFILE=sv-profile cl-profile sdl-profile
53 TARGETS_RELEASE=sv-release cl-release sdl-release
54 TARGETS_RELEASE_PROFILE=sv-release-profile cl-release-profile sdl-release-profile
55 TARGETS_NEXUIZ=sv-nexuiz cl-nexuiz sdl-nexuiz
57 ###### Optional features #####
59 ifeq ($(DP_CDDA), enabled)
60 OBJ_SDLCD=$(OBJ_CD_COMMON) cd_sdl.o
61 OBJ_LINUXCD=$(OBJ_CD_COMMON) cd_linux.o
62 OBJ_BSDCD=$(OBJ_CD_COMMON) cd_bsd.o
63 OBJ_WINCD=$(OBJ_CD_COMMON) cd_win.o
65 OBJ_SDLCD=$(OBJ_CD_COMMON) $(OBJ_NOCD)
66 OBJ_LINUXCD=$(OBJ_CD_COMMON) $(OBJ_NOCD)
67 OBJ_BSDCD=$(OBJ_CD_COMMON) $(OBJ_NOCD)
68 OBJ_WINCD=$(OBJ_CD_COMMON) $(OBJ_NOCD)
72 ifeq ($(DP_MAKE_TARGET), linux)
80 LDFLAGS_CL=$(LDFLAGS_LINUXCL)
81 LDFLAGS_SV=$(LDFLAGS_LINUXSV)
82 LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
84 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
85 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
86 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
90 EXE_SDL=$(EXE_UNIXSDL)
91 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
92 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
93 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
100 # Mac OS X configuration
101 ifeq ($(DP_MAKE_TARGET), macosx)
102 DEFAULT_SNDAPI=COREAUDIO
103 OBJ_CD=$(OBJ_MACOSXCD)
109 LDFLAGS_CL=$(LDFLAGS_MACOSXCL)
110 LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
111 LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
113 SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
114 SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
115 SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
117 EXE_CL=$(EXE_MACOSXCL)
119 EXE_SDL=$(EXE_UNIXSDL)
120 EXE_CLNEXUIZ=$(EXE_MACOSXCLNEXUIZ)
121 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
122 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
124 ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
132 # on OS X, we don't build the CL by default because it uses deprecated
133 # and not-implemented-in-64bit Carbon
134 TARGETS_DEBUG=sv-debug sdl-debug
135 TARGETS_PROFILE=sv-profile sdl-profile
136 TARGETS_RELEASE=sv-release sdl-release
137 TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
138 TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
141 # SunOS configuration (Solaris)
142 ifeq ($(DP_MAKE_TARGET), sunos)
144 OBJ_CD=$(OBJ_SUNOSCD)
150 CFLAGS_EXTRA=$(CFLAGS_SUNOS)
152 LDFLAGS_CL=$(LDFLAGS_SUNOSCL)
153 LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
154 LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
156 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
157 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
158 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
162 EXE_SDL=$(EXE_UNIXSDL)
163 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
164 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
165 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
173 ifeq ($(DP_MAKE_TARGET), bsd)
174 ifeq ($(DP_ARCH),FreeBSD)
185 LDFLAGS_CL=$(LDFLAGS_BSDCL)
186 LDFLAGS_SV=$(LDFLAGS_BSDSV)
187 LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
189 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
190 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
191 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
195 EXE_SDL=$(EXE_UNIXSDL)
196 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
197 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
198 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
205 # Win32 configuration
206 ifeq ($(WIN32RELEASE), 1)
207 # TARGET=i686-pc-mingw32
209 # WINDRES=$(TARGET)-windres
210 CPUOPTIMIZATIONS=-march=i686 -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
211 # CPUOPTIMIZATIONS+=-DUSE_WSPIAPI_H -DSUPPORTIPV6
212 LDFLAGS_WINCOMMON=-Wl,--large-address-aware
217 ifeq ($(WIN64RELEASE), 1)
218 # TARGET=x86_64-pc-mingw32
220 # WINDRES=$(TARGET)-windres
224 CFLAGS_D3D=-DSUPPORTD3D -DSUPPORTDIRECTX
225 CFLAGS_WARNINGS=-Wall
229 CFLAGS_WARNINGS=-Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement -Wmissing-prototypes
234 ifeq ($(DP_MAKE_TARGET), mingw)
239 OBJ_ICON=darkplaces.o
240 OBJ_ICON_NEXUIZ=nexuiz.o
242 LDFLAGS_CL=$(LDFLAGS_WINCL)
243 LDFLAGS_SV=$(LDFLAGS_WINSV)
244 LDFLAGS_SDL=$(LDFLAGS_WINSDL)
246 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
247 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
248 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
252 EXE_SDL=$(EXE_WINSDL)
253 EXE_CLNEXUIZ=$(EXE_WINCLNEXUIZ)
254 EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
255 EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
262 # set these to "" if you want to use dynamic loading instead
264 ifeq ($(DP_LINK_ZLIB), shared)
265 CFLAGS_LIBZ=-DLINK_TO_ZLIB
268 ifeq ($(DP_LINK_ZLIB), dlopen)
274 ifeq ($(DP_LINK_JPEG), shared)
275 CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
278 ifeq ($(DP_LINK_JPEG), dlopen)
284 ifeq ($(DP_LINK_ODE), shared)
285 ODE_CONFIG?=ode-config
286 LIB_ODE=`$(ODE_CONFIG) --libs`
287 CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE
289 ifeq ($(DP_LINK_ODE), dlopen)
295 # most distros do not have d0_blind_id package, dlopen will used by default
296 # LIB_CRYPTO=-ld0_blind_id
297 # CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
298 # LIB_CRYPTO_RIJNDAEL=-ld0_rijndael
299 # CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
303 CFLAGS_CRYPTO_RIJNDAEL=
305 ##### Sound configuration #####
308 DP_SOUND_API=$(DEFAULT_SNDAPI)
312 ifeq ($(DP_SOUND_API), NULL)
313 OBJ_SOUND=$(OBJ_SND_NULL)
314 LIB_SOUND=$(LIB_SND_NULL)
317 # OSS: Open Sound System
318 ifeq ($(DP_SOUND_API), OSS)
319 OBJ_SOUND=$(OBJ_SND_OSS)
320 LIB_SOUND=$(LIB_SND_OSS)
323 # ALSA: Advanced Linux Sound Architecture
324 ifeq ($(DP_SOUND_API), ALSA)
325 OBJ_SOUND=$(OBJ_SND_ALSA)
326 LIB_SOUND=$(LIB_SND_ALSA)
329 # COREAUDIO: Core Audio
330 ifeq ($(DP_SOUND_API), COREAUDIO)
331 OBJ_SOUND=$(OBJ_SND_COREAUDIO)
332 LIB_SOUND=$(LIB_SND_COREAUDIO)
335 # BSD: BSD / Sun audio API
336 ifeq ($(DP_SOUND_API), BSD)
337 OBJ_SOUND=$(OBJ_SND_BSD)
338 LIB_SOUND=$(LIB_SND_BSD)
341 # WIN: DirectX and Win32 WAVE output
342 ifeq ($(DP_SOUND_API), WIN)
343 OBJ_SOUND=$(OBJ_SND_WIN)
344 LIB_SOUND=$(LIB_SND_WIN)
347 ifeq ($(DP_SOUND_API),3DRAS)
348 OBJ_SOUND=$(OBJ_SND_3DRAS)
349 LIB_SOUND=$(LIB_SND_3DRAS)
352 ##### Extra CFLAGS #####
356 CFLAGS_FS=-DDP_FS_BASEDIR='\"$(DP_FS_BASEDIR)\"'
362 ifneq ($(DP_MAKE_TARGET), mingw)
363 ifdef DP_PRELOAD_DEPENDENCIES
364 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
365 # dynamically so they won't get loaded at runtime using dlopen
366 LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
367 LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
368 LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
369 CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
373 ##### GNU Make specific definitions #####
375 DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
378 ##### Definitions shared by all makefiles #####
382 ##### Dependency files #####
386 # hack to deal with no-longer-needed .h files
389 @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
390 @echo "HINT: consider 'make clean'"