remove DP_LINK_TO_JPEG from makefile, as this is default now
[divverent/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
51 # Linux configuration
52 ifeq ($(DP_MAKE_TARGET), linux)
53         DEFAULT_SNDAPI=ALSA
54         OBJ_CD=$(OBJ_LINUXCD)
55
56         OBJ_CL=$(OBJ_GLX)
57         OBJ_ICON=
58         OBJ_ICON_NEXUIZ=
59
60         LDFLAGS_CL=$(LDFLAGS_LINUXCL)
61         LDFLAGS_SV=$(LDFLAGS_LINUXSV)
62         LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
63
64         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
65         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
66         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
67
68         EXE_CL=$(EXE_UNIXCL)
69         EXE_SV=$(EXE_UNIXSV)
70         EXE_SDL=$(EXE_UNIXSDL)
71         EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
72         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
73         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
74 endif
75
76 # Mac OS X configuration
77 ifeq ($(DP_MAKE_TARGET), macosx)
78         DEFAULT_SNDAPI=COREAUDIO
79         OBJ_CD=$(OBJ_MACOSXCD)
80
81         OBJ_CL=$(OBJ_AGL)
82         OBJ_ICON=
83         OBJ_ICON_NEXUIZ=
84
85         LDFLAGS_CL=$(LDFLAGS_MACOSXCL)
86         LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
87         LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
88
89         SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
90         SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
91         SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
92
93         EXE_CL=$(EXE_MACOSXCL)
94         EXE_SV=$(EXE_UNIXSV)
95         EXE_SDL=$(EXE_UNIXSDL)
96         EXE_CLNEXUIZ=$(EXE_MACOSXCLNEXUIZ)
97         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
98         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
99
100         ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
101                 CFLAGS_MAKEDEP=
102         endif
103 endif
104
105 # SunOS configuration (Solaris)
106 ifeq ($(DP_MAKE_TARGET), sunos)
107         DEFAULT_SNDAPI=BSD
108         OBJ_CD=$(OBJ_SUNOSCD)
109
110         OBJ_CL=$(OBJ_GLX)
111         OBJ_ICON=
112         OBJ_ICON_NEXUIZ=
113
114         CFLAGS_EXTRA=$(CFLAGS_SUNOS)
115
116         LDFLAGS_CL=$(LDFLAGS_SUNOSCL)
117         LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
118         LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
119
120         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
121         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
122         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
123
124         EXE_CL=$(EXE_UNIXCL)
125         EXE_SV=$(EXE_UNIXSV)
126         EXE_SDL=$(EXE_UNIXSDL)
127         EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
128         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
129         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
130 endif
131
132 # BSD configuration
133 ifeq ($(DP_MAKE_TARGET), bsd)
134 ifeq ($(DP_ARCH),FreeBSD)
135         DEFAULT_SNDAPI=OSS
136 else
137         DEFAULT_SNDAPI=BSD
138 endif
139         OBJ_CD=$(OBJ_BSDCD)
140
141         OBJ_CL=$(OBJ_GLX)
142         OBJ_ICON=
143         OBJ_ICON_NEXUIZ=
144
145         LDFLAGS_CL=$(LDFLAGS_BSDCL)
146         LDFLAGS_SV=$(LDFLAGS_BSDSV)
147         LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
148
149         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
150         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
151         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
152
153         EXE_CL=$(EXE_UNIXCL)
154         EXE_SV=$(EXE_UNIXSV)
155         EXE_SDL=$(EXE_UNIXSDL)
156         EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
157         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
158         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
159 endif
160
161 # Win32 configuration
162 ifeq ($(WIN32RELEASE), 1)
163 #       TARGET=i686-pc-mingw32
164 #       CC=$(TARGET)-g++
165 #       WINDRES=$(TARGET)-windres
166         CPUOPTIMIZATIONS=-march=i686 -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math -DUSE_WSPIAPI_H
167         LDFLAGS_WINCOMMON=-Wl,--large-address-aware
168 else
169         LDFLAGS_WINCOMMON=
170 endif
171
172 ifeq ($(WIN64RELEASE), 1)
173 #       TARGET=x86_64-pc-mingw32
174 #       CC=$(TARGET)-g++
175 #       WINDRES=$(TARGET)-windres
176 endif
177
178 ifeq ($(D3D), 1)
179         CFLAGS_D3D=-DSUPPORTD3D -DSUPPORTDIRECTX
180         CFLAGS_WARNINGS=-Wall
181         LDFLAGS_D3D=-ld3d9
182 else
183         CFLAGS_D3D=
184         CFLAGS_WARNINGS=-Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement
185         LDFLAGS_D3D=
186 endif
187
188
189 ifeq ($(DP_MAKE_TARGET), mingw)
190         DEFAULT_SNDAPI=WIN
191         OBJ_CD=$(OBJ_WINCD)
192
193         OBJ_CL=$(OBJ_WGL)
194         OBJ_ICON=darkplaces.o
195         OBJ_ICON_NEXUIZ=nexuiz.o
196
197         LDFLAGS_CL=$(LDFLAGS_WINCL)
198         LDFLAGS_SV=$(LDFLAGS_WINSV)
199         LDFLAGS_SDL=$(LDFLAGS_WINSDL)
200
201         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
202         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
203         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
204
205         EXE_CL=$(EXE_WINCL)
206         EXE_SV=$(EXE_WINSV)
207         EXE_SDL=$(EXE_WINSDL)
208         EXE_CLNEXUIZ=$(EXE_WINCLNEXUIZ)
209         EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
210         EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
211 endif
212
213 ##### Sound configuration #####
214
215 ifndef DP_SOUND_API
216         DP_SOUND_API=$(DEFAULT_SNDAPI)
217 endif
218
219 # NULL: no sound
220 ifeq ($(DP_SOUND_API), NULL)
221         OBJ_SOUND=$(OBJ_SND_NULL)
222         LIB_SOUND=$(LIB_SND_NULL)
223 endif
224
225 # OSS: Open Sound System
226 ifeq ($(DP_SOUND_API), OSS)
227         OBJ_SOUND=$(OBJ_SND_OSS)
228         LIB_SOUND=$(LIB_SND_OSS)
229 endif
230
231 # ALSA: Advanced Linux Sound Architecture
232 ifeq ($(DP_SOUND_API), ALSA)
233         OBJ_SOUND=$(OBJ_SND_ALSA)
234         LIB_SOUND=$(LIB_SND_ALSA)
235 endif
236
237 # COREAUDIO: Core Audio
238 ifeq ($(DP_SOUND_API), COREAUDIO)
239         OBJ_SOUND=$(OBJ_SND_COREAUDIO)
240         LIB_SOUND=$(LIB_SND_COREAUDIO)
241 endif
242
243 # BSD: BSD / Sun audio API
244 ifeq ($(DP_SOUND_API), BSD)
245         OBJ_SOUND=$(OBJ_SND_BSD)
246         LIB_SOUND=$(LIB_SND_BSD)
247 endif
248
249 # WIN: DirectX and Win32 WAVE output
250 ifeq ($(DP_SOUND_API), WIN)
251         OBJ_SOUND=$(OBJ_SND_WIN)
252         LIB_SOUND=$(LIB_SND_WIN)
253 endif
254
255 ifeq ($(DP_SOUND_API),3DRAS)
256         OBJ_SOUND=$(OBJ_SND_3DRAS)
257         LIB_SOUND=$(LIB_SND_3DRAS)
258 endif
259
260 ##### Extra CFLAGS #####
261
262 CFLAGS_MAKEDEP?=-MMD
263 ifdef DP_FS_BASEDIR
264         CFLAGS_FS=-DDP_FS_BASEDIR='\"$(DP_FS_BASEDIR)\"'
265 else
266         CFLAGS_FS=
267 endif
268
269 CFLAGS_PRELOAD=
270 ifneq ($(DP_MAKE_TARGET), mingw)
271 ifdef DP_PRELOAD_DEPENDENCIES
272 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
273 # dynamically so they won't get loaded at runtime using dlopen
274         LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
275         LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
276         LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
277         CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
278 endif
279 endif
280
281 ##### GNU Make specific definitions #####
282
283 DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
284
285
286 ##### Definitions shared by all makefiles #####
287 include makefile.inc
288
289
290 ##### Dependency files #####
291
292 -include *.d