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