]> git.xonotic.org Git - xonotic/darkplaces.git/blob - makefile
Revert "Build in subdirs"
[xonotic/darkplaces.git] / makefile
1 #####  DP_MAKE_TARGET autodetection and arch specific variables #####
2
3 ifndef DP_MAKE_TARGET
4
5 # Win32
6 ifdef WINDIR
7         DP_MAKE_TARGET=mingw
8 else
9
10 # UNIXes
11 DP_ARCH:=$(shell uname)
12 ifneq ($(filter %BSD,$(DP_ARCH)),)
13         DP_MAKE_TARGET=bsd
14 else
15 ifeq ($(DP_ARCH), Darwin)
16         DP_MAKE_TARGET=macosx
17 else
18 ifeq ($(DP_ARCH), SunOS)
19         DP_MAKE_TARGET=sunos
20 else
21         DP_MAKE_TARGET=linux
22
23 endif  # ifeq ($(DP_ARCH), SunOS)
24 endif  # ifeq ($(DP_ARCH), Darwin)
25 endif  # ifneq ($(filter %BSD,$(DP_ARCH)),)
26 endif  # ifdef windir
27 endif  # ifndef DP_MAKE_TARGET
28
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)
33 endif
34
35
36 # Command used to delete files
37 ifdef windir
38         CMD_RM=del
39 else
40         CMD_RM=$(CMD_UNIXRM)
41 endif
42
43 # 64bits AMD CPUs use another lib directory
44 ifeq ($(DP_MACHINE),x86_64)
45         UNIX_X11LIBPATH:=/usr/X11R6/lib64
46 else
47         UNIX_X11LIBPATH:=/usr/X11R6/lib
48 endif
49
50 # default targets
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
56
57 ###### Optional features #####
58 DP_CDDA?=enabled
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
64 else
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)
69 endif
70
71 # Linux configuration
72 ifeq ($(DP_MAKE_TARGET), linux)
73         DEFAULT_SNDAPI=ALSA
74         OBJ_CD=$(OBJ_LINUXCD)
75
76         OBJ_CL=$(OBJ_GLX)
77         OBJ_ICON=
78         OBJ_ICON_NEXUIZ=
79
80         LDFLAGS_CL=$(LDFLAGS_LINUXCL)
81         LDFLAGS_SV=$(LDFLAGS_LINUXSV)
82         LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
83
84         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
85         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
86         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
87
88         EXE_CL=$(EXE_UNIXCL)
89         EXE_SV=$(EXE_UNIXSV)
90         EXE_SDL=$(EXE_UNIXSDL)
91         EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
92         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
93         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
94
95         DP_LINK_ZLIB?=shared
96         DP_LINK_JPEG?=shared
97         DP_LINK_ODE?=dlopen
98 endif
99
100 # Mac OS X configuration
101 ifeq ($(DP_MAKE_TARGET), macosx)
102         DEFAULT_SNDAPI=COREAUDIO
103         OBJ_CD=$(OBJ_MACOSXCD)
104
105         OBJ_CL=$(OBJ_AGL)
106         OBJ_ICON=
107         OBJ_ICON_NEXUIZ=
108
109         LDFLAGS_CL=$(LDFLAGS_MACOSXCL)
110         LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
111         LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
112
113         SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
114         SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
115         SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
116
117         EXE_CL=$(EXE_MACOSXCL)
118         EXE_SV=$(EXE_UNIXSV)
119         EXE_SDL=$(EXE_UNIXSDL)
120         EXE_CLNEXUIZ=$(EXE_MACOSXCLNEXUIZ)
121         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
122         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
123
124         ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
125                 CFLAGS_MAKEDEP=
126         endif
127
128         DP_LINK_ZLIB?=shared
129         DP_LINK_JPEG?=shared
130         DP_LINK_ODE?=dlopen
131
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
139 endif
140
141 # SunOS configuration (Solaris)
142 ifeq ($(DP_MAKE_TARGET), sunos)
143         DEFAULT_SNDAPI=BSD
144         OBJ_CD=$(OBJ_SUNOSCD)
145
146         OBJ_CL=$(OBJ_GLX)
147         OBJ_ICON=
148         OBJ_ICON_NEXUIZ=
149
150         CFLAGS_EXTRA=$(CFLAGS_SUNOS)
151
152         LDFLAGS_CL=$(LDFLAGS_SUNOSCL)
153         LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
154         LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
155
156         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
157         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
158         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
159
160         EXE_CL=$(EXE_UNIXCL)
161         EXE_SV=$(EXE_UNIXSV)
162         EXE_SDL=$(EXE_UNIXSDL)
163         EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
164         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
165         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
166
167         DP_LINK_ZLIB?=shared
168         DP_LINK_JPEG?=shared
169         DP_LINK_ODE?=dlopen
170 endif
171
172 # BSD configuration
173 ifeq ($(DP_MAKE_TARGET), bsd)
174 ifeq ($(DP_ARCH),FreeBSD)
175         DEFAULT_SNDAPI=OSS
176 else
177         DEFAULT_SNDAPI=BSD
178 endif
179         OBJ_CD=$(OBJ_BSDCD)
180
181         OBJ_CL=$(OBJ_GLX)
182         OBJ_ICON=
183         OBJ_ICON_NEXUIZ=
184
185         LDFLAGS_CL=$(LDFLAGS_BSDCL)
186         LDFLAGS_SV=$(LDFLAGS_BSDSV)
187         LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
188
189         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
190         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
191         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
192
193         EXE_CL=$(EXE_UNIXCL)
194         EXE_SV=$(EXE_UNIXSV)
195         EXE_SDL=$(EXE_UNIXSDL)
196         EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
197         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
198         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
199
200         DP_LINK_ZLIB?=shared
201         DP_LINK_JPEG?=shared
202         DP_LINK_ODE?=dlopen
203 endif
204
205 # Win32 configuration
206 ifeq ($(WIN32RELEASE), 1)
207 #       TARGET=i686-pc-mingw32
208 #       CC=$(TARGET)-g++
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
213 else
214         LDFLAGS_WINCOMMON=
215 endif
216
217 ifeq ($(WIN64RELEASE), 1)
218 #       TARGET=x86_64-pc-mingw32
219 #       CC=$(TARGET)-g++
220 #       WINDRES=$(TARGET)-windres
221 endif
222
223 ifeq ($(D3D), 1)
224         CFLAGS_D3D=-DSUPPORTD3D -DSUPPORTDIRECTX
225         CFLAGS_WARNINGS=-Wall
226         LDFLAGS_D3D=-ld3d9
227 else
228         CFLAGS_D3D=
229         CFLAGS_WARNINGS=-Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement -Wmissing-prototypes
230         LDFLAGS_D3D=
231 endif
232
233
234 ifeq ($(DP_MAKE_TARGET), mingw)
235         DEFAULT_SNDAPI=WIN
236         OBJ_CD=$(OBJ_WINCD)
237
238         OBJ_CL=$(OBJ_WGL)
239         OBJ_ICON=darkplaces.o
240         OBJ_ICON_NEXUIZ=nexuiz.o
241
242         LDFLAGS_CL=$(LDFLAGS_WINCL)
243         LDFLAGS_SV=$(LDFLAGS_WINSV)
244         LDFLAGS_SDL=$(LDFLAGS_WINSDL)
245
246         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
247         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
248         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
249
250         EXE_CL=$(EXE_WINCL)
251         EXE_SV=$(EXE_WINSV)
252         EXE_SDL=$(EXE_WINSDL)
253         EXE_CLNEXUIZ=$(EXE_WINCLNEXUIZ)
254         EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
255         EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
256
257         DP_LINK_ZLIB?=shared
258         DP_LINK_JPEG?=shared
259         DP_LINK_ODE?=dlopen
260 endif
261
262 # set these to "" if you want to use dynamic loading instead
263 # zlib
264 ifeq ($(DP_LINK_ZLIB), shared)
265         CFLAGS_LIBZ=-DLINK_TO_ZLIB
266         LIB_Z=-lz
267 endif
268 ifeq ($(DP_LINK_ZLIB), dlopen)
269         CFLAGS_LIBZ=
270         LIB_Z=
271 endif
272
273 # jpeg
274 ifeq ($(DP_LINK_JPEG), shared)
275         CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
276         LIB_JPEG=-ljpeg
277 endif
278 ifeq ($(DP_LINK_JPEG), dlopen)
279         CFLAGS_LIBJPEG=
280         LIB_JPEG=
281 endif
282
283 # ode
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
288 endif
289 ifeq ($(DP_LINK_ODE), dlopen)
290         LIB_ODE=
291         CFLAGS_ODE=-DUSEODE
292 endif
293
294 # d0_blind_id
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
300 LIB_CRYPTO=
301 CFLAGS_CRYPTO=
302 LIB_CRYPTO_RIJNDAEL=
303 CFLAGS_CRYPTO_RIJNDAEL=
304
305 ##### Sound configuration #####
306
307 ifndef DP_SOUND_API
308         DP_SOUND_API=$(DEFAULT_SNDAPI)
309 endif
310
311 # NULL: no sound
312 ifeq ($(DP_SOUND_API), NULL)
313         OBJ_SOUND=$(OBJ_SND_NULL)
314         LIB_SOUND=$(LIB_SND_NULL)
315 endif
316
317 # OSS: Open Sound System
318 ifeq ($(DP_SOUND_API), OSS)
319         OBJ_SOUND=$(OBJ_SND_OSS)
320         LIB_SOUND=$(LIB_SND_OSS)
321 endif
322
323 # ALSA: Advanced Linux Sound Architecture
324 ifeq ($(DP_SOUND_API), ALSA)
325         OBJ_SOUND=$(OBJ_SND_ALSA)
326         LIB_SOUND=$(LIB_SND_ALSA)
327 endif
328
329 # COREAUDIO: Core Audio
330 ifeq ($(DP_SOUND_API), COREAUDIO)
331         OBJ_SOUND=$(OBJ_SND_COREAUDIO)
332         LIB_SOUND=$(LIB_SND_COREAUDIO)
333 endif
334
335 # BSD: BSD / Sun audio API
336 ifeq ($(DP_SOUND_API), BSD)
337         OBJ_SOUND=$(OBJ_SND_BSD)
338         LIB_SOUND=$(LIB_SND_BSD)
339 endif
340
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)
345 endif
346
347 ifeq ($(DP_SOUND_API),3DRAS)
348         OBJ_SOUND=$(OBJ_SND_3DRAS)
349         LIB_SOUND=$(LIB_SND_3DRAS)
350 endif
351
352 ##### Extra CFLAGS #####
353
354 CFLAGS_MAKEDEP?=-MMD
355 ifdef DP_FS_BASEDIR
356         CFLAGS_FS=-DDP_FS_BASEDIR='\"$(DP_FS_BASEDIR)\"'
357 else
358         CFLAGS_FS=
359 endif
360
361 CFLAGS_PRELOAD=
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)
370 endif
371 endif
372
373 ##### GNU Make specific definitions #####
374
375 DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
376
377
378 ##### Definitions shared by all makefiles #####
379 include makefile.inc
380
381
382 ##### Dependency files #####
383
384 -include *.d
385
386 # hack to deal with no-longer-needed .h files
387 %.h:
388         @echo
389         @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
390         @echo "HINT: consider 'make clean'"
391         @echo