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)
78 ifeq ($(DP_MAKE_TARGET), linux)
86 LDFLAGS_CL=$(LDFLAGS_LINUXCL)
87 LDFLAGS_SV=$(LDFLAGS_LINUXSV)
88 LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
90 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
91 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
92 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
96 EXE_SDL=$(EXE_UNIXSDL)
97 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
98 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
99 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
106 # Mac OS X configuration
107 ifeq ($(DP_MAKE_TARGET), macosx)
108 DEFAULT_SNDAPI=COREAUDIO
109 OBJ_CD=$(OBJ_MACOSXCD)
115 LDFLAGS_CL=$(LDFLAGS_MACOSXCL)
116 LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
117 LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
119 SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
120 SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
121 SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
123 EXE_CL=$(EXE_MACOSXCL)
125 EXE_SDL=$(EXE_UNIXSDL)
126 EXE_CLNEXUIZ=$(EXE_MACOSXCLNEXUIZ)
127 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
128 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
130 ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
138 # on OS X, we don't build the CL by default because it uses deprecated
139 # and not-implemented-in-64bit Carbon
140 TARGETS_DEBUG=sv-debug sdl-debug
141 TARGETS_PROFILE=sv-profile sdl-profile
142 TARGETS_RELEASE=sv-release sdl-release
143 TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
144 TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
147 # SunOS configuration (Solaris)
148 ifeq ($(DP_MAKE_TARGET), sunos)
150 OBJ_CD=$(OBJ_SUNOSCD)
156 CFLAGS_EXTRA=$(CFLAGS_SUNOS)
158 LDFLAGS_CL=$(LDFLAGS_SUNOSCL)
159 LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
160 LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
162 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
163 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
164 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
168 EXE_SDL=$(EXE_UNIXSDL)
169 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
170 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
171 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
179 ifeq ($(DP_MAKE_TARGET), bsd)
180 ifeq ($(DP_ARCH),FreeBSD)
191 LDFLAGS_CL=$(LDFLAGS_BSDCL)
192 LDFLAGS_SV=$(LDFLAGS_BSDSV)
193 LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
195 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
196 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
197 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
201 EXE_SDL=$(EXE_UNIXSDL)
202 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
203 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
204 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
211 # Win32 configuration
212 ifeq ($(WIN32RELEASE), 1)
213 # TARGET=i686-pc-mingw32
215 # WINDRES=$(TARGET)-windres
216 CPUOPTIMIZATIONS=-march=i686 -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
217 # CPUOPTIMIZATIONS+=-DUSE_WSPIAPI_H -DSUPPORTIPV6
218 LDFLAGS_WINCOMMON=-Wl,--large-address-aware
223 ifeq ($(WIN64RELEASE), 1)
224 # TARGET=x86_64-pc-mingw32
226 # WINDRES=$(TARGET)-windres
230 CFLAGS_D3D=-DSUPPORTD3D -DSUPPORTDIRECTX
231 CFLAGS_WARNINGS=-Wall
235 CFLAGS_WARNINGS=-Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement -Wmissing-prototypes
240 ifeq ($(DP_MAKE_TARGET), mingw)
245 OBJ_ICON=darkplaces.o
246 OBJ_ICON_NEXUIZ=nexuiz.o
248 LDFLAGS_CL=$(LDFLAGS_WINCL)
249 LDFLAGS_SV=$(LDFLAGS_WINSV)
250 LDFLAGS_SDL=$(LDFLAGS_WINSDL)
252 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
253 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
254 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
258 EXE_SDL=$(EXE_WINSDL)
259 EXE_CLNEXUIZ=$(EXE_WINCLNEXUIZ)
260 EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
261 EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
268 # set these to "" if you want to use dynamic loading instead
270 ifeq ($(DP_LINK_ZLIB), shared)
271 CFLAGS_LIBZ=-DLINK_TO_ZLIB
274 ifeq ($(DP_LINK_ZLIB), dlopen)
280 ifeq ($(DP_LINK_JPEG), shared)
281 CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
284 ifeq ($(DP_LINK_JPEG), dlopen)
290 ifeq ($(DP_LINK_ODE), shared)
291 ODE_CONFIG?=ode-config
292 LIB_ODE=`$(ODE_CONFIG) --libs`
293 CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE
295 ifeq ($(DP_LINK_ODE), dlopen)
301 # most distros do not have d0_blind_id package, dlopen will used by default
302 # LIB_CRYPTO=-ld0_blind_id
303 # CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
304 # LIB_CRYPTO_RIJNDAEL=-ld0_rijndael
305 # CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
309 CFLAGS_CRYPTO_RIJNDAEL=
311 ##### Sound configuration #####
314 DP_SOUND_API=$(DEFAULT_SNDAPI)
318 ifeq ($(DP_SOUND_API), NULL)
319 OBJ_SOUND=$(OBJ_SND_NULL)
320 LIB_SOUND=$(LIB_SND_NULL)
323 # OSS: Open Sound System
324 ifeq ($(DP_SOUND_API), OSS)
325 OBJ_SOUND=$(OBJ_SND_OSS)
326 LIB_SOUND=$(LIB_SND_OSS)
329 # ALSA: Advanced Linux Sound Architecture
330 ifeq ($(DP_SOUND_API), ALSA)
331 OBJ_SOUND=$(OBJ_SND_ALSA)
332 LIB_SOUND=$(LIB_SND_ALSA)
335 # COREAUDIO: Core Audio
336 ifeq ($(DP_SOUND_API), COREAUDIO)
337 OBJ_SOUND=$(OBJ_SND_COREAUDIO)
338 LIB_SOUND=$(LIB_SND_COREAUDIO)
341 # BSD: BSD / Sun audio API
342 ifeq ($(DP_SOUND_API), BSD)
343 OBJ_SOUND=$(OBJ_SND_BSD)
344 LIB_SOUND=$(LIB_SND_BSD)
347 # WIN: DirectX and Win32 WAVE output
348 ifeq ($(DP_SOUND_API), WIN)
349 OBJ_SOUND=$(OBJ_SND_WIN)
350 LIB_SOUND=$(LIB_SND_WIN)
353 ifeq ($(DP_SOUND_API),3DRAS)
354 OBJ_SOUND=$(OBJ_SND_3DRAS)
355 LIB_SOUND=$(LIB_SND_3DRAS)
358 ##### Extra CFLAGS #####
362 CFLAGS_FS=-DDP_FS_BASEDIR='\"$(DP_FS_BASEDIR)\"'
368 ifneq ($(DP_MAKE_TARGET), mingw)
369 ifdef DP_PRELOAD_DEPENDENCIES
370 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
371 # dynamically so they won't get loaded at runtime using dlopen
372 LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
373 LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
374 LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
375 CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
379 ##### GNU Make specific definitions #####
381 DO_LD=$(CC) -o ../../../$@ $^ $(LDFLAGS)
384 ##### Definitions shared by all makefiles #####
388 ##### Dependency files #####
392 # hack to deal with no-longer-needed .h files
395 @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
396 @echo "HINT: consider 'make clean'"