]> git.xonotic.org Git - xonotic/darkplaces.git/blob - makefile
PROPERLY load the icon in SDL/X11
[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
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) $(SDLCONFIG_UNIXCFLAGS_X11)
65         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
66         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
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
75         # libjpeg dependency (set these to "" if you want to use dynamic loading instead)
76         CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
77         LIB_JPEG=-ljpeg
78 endif
79
80 # Mac OS X configuration
81 ifeq ($(DP_MAKE_TARGET), macosx)
82         DEFAULT_SNDAPI=COREAUDIO
83         OBJ_CD=$(OBJ_MACOSXCD)
84
85         OBJ_CL=$(OBJ_AGL)
86         OBJ_ICON=
87         OBJ_ICON_NEXUIZ=
88
89         LDFLAGS_CL=$(LDFLAGS_MACOSXCL)
90         LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
91         LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
92
93         SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
94         SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
95         SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
96
97         EXE_CL=$(EXE_MACOSXCL)
98         EXE_SV=$(EXE_UNIXSV)
99         EXE_SDL=$(EXE_UNIXSDL)
100         EXE_CLNEXUIZ=$(EXE_MACOSXCLNEXUIZ)
101         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
102         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
103
104         ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
105                 CFLAGS_MAKEDEP=
106         endif
107
108         # libjpeg dependency (set these to "" if you want to use dynamic loading instead)
109         # we don't currently link to libjpeg on Mac because the OS does not have an easy way to load libjpeg and we provide our own in the .app
110         CFLAGS_LIBJPEG=
111         LIB_JPEG=
112 endif
113
114 # SunOS configuration (Solaris)
115 ifeq ($(DP_MAKE_TARGET), sunos)
116         DEFAULT_SNDAPI=BSD
117         OBJ_CD=$(OBJ_SUNOSCD)
118
119         OBJ_CL=$(OBJ_GLX)
120         OBJ_ICON=
121         OBJ_ICON_NEXUIZ=
122
123         CFLAGS_EXTRA=$(CFLAGS_SUNOS)
124
125         LDFLAGS_CL=$(LDFLAGS_SUNOSCL)
126         LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
127         LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
128
129         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
130         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
131         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
132
133         EXE_CL=$(EXE_UNIXCL)
134         EXE_SV=$(EXE_UNIXSV)
135         EXE_SDL=$(EXE_UNIXSDL)
136         EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
137         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
138         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
139
140         # libjpeg dependency (set these to "" if you want to use dynamic loading instead)
141         CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
142         LIB_JPEG=-ljpeg
143 endif
144
145 # BSD configuration
146 ifeq ($(DP_MAKE_TARGET), bsd)
147 ifeq ($(DP_ARCH),FreeBSD)
148         DEFAULT_SNDAPI=OSS
149 else
150         DEFAULT_SNDAPI=BSD
151 endif
152         OBJ_CD=$(OBJ_BSDCD)
153
154         OBJ_CL=$(OBJ_GLX)
155         OBJ_ICON=
156         OBJ_ICON_NEXUIZ=
157
158         LDFLAGS_CL=$(LDFLAGS_BSDCL)
159         LDFLAGS_SV=$(LDFLAGS_BSDSV)
160         LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
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         # libjpeg dependency (set these to "" if you want to use dynamic loading instead)
174         CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
175         LIB_JPEG=-ljpeg
176 endif
177
178 # Win32 configuration
179 ifeq ($(WIN32RELEASE), 1)
180 #       TARGET=i686-pc-mingw32
181 #       CC=$(TARGET)-g++
182 #       WINDRES=$(TARGET)-windres
183         CPUOPTIMIZATIONS=-march=i686 -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
184 #       CPUOPTIMIZATIONS+=-DUSE_WSPIAPI_H -DSUPPORTIPV6
185         LDFLAGS_WINCOMMON=-Wl,--large-address-aware
186 else
187         LDFLAGS_WINCOMMON=
188 endif
189
190 ifeq ($(WIN64RELEASE), 1)
191 #       TARGET=x86_64-pc-mingw32
192 #       CC=$(TARGET)-g++
193 #       WINDRES=$(TARGET)-windres
194 endif
195
196 ifeq ($(D3D), 1)
197         CFLAGS_D3D=-DSUPPORTD3D -DSUPPORTDIRECTX
198         CFLAGS_WARNINGS=-Wall
199         LDFLAGS_D3D=-ld3d9
200 else
201         CFLAGS_D3D=
202         CFLAGS_WARNINGS=-Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement
203         LDFLAGS_D3D=
204 endif
205
206
207 ifeq ($(DP_MAKE_TARGET), mingw)
208         DEFAULT_SNDAPI=WIN
209         OBJ_CD=$(OBJ_WINCD)
210
211         OBJ_CL=$(OBJ_WGL)
212         OBJ_ICON=darkplaces.o
213         OBJ_ICON_NEXUIZ=nexuiz.o
214
215         LDFLAGS_CL=$(LDFLAGS_WINCL)
216         LDFLAGS_SV=$(LDFLAGS_WINSV)
217         LDFLAGS_SDL=$(LDFLAGS_WINSDL)
218
219         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
220         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
221         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
222
223         EXE_CL=$(EXE_WINCL)
224         EXE_SV=$(EXE_WINSV)
225         EXE_SDL=$(EXE_WINSDL)
226         EXE_CLNEXUIZ=$(EXE_WINCLNEXUIZ)
227         EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
228         EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
229
230         # libjpeg dependency (set these to "" if you want to use dynamic loading instead)
231         CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
232         LIB_JPEG=-ljpeg
233 endif
234
235 ##### Sound configuration #####
236
237 ifndef DP_SOUND_API
238         DP_SOUND_API=$(DEFAULT_SNDAPI)
239 endif
240
241 # NULL: no sound
242 ifeq ($(DP_SOUND_API), NULL)
243         OBJ_SOUND=$(OBJ_SND_NULL)
244         LIB_SOUND=$(LIB_SND_NULL)
245 endif
246
247 # OSS: Open Sound System
248 ifeq ($(DP_SOUND_API), OSS)
249         OBJ_SOUND=$(OBJ_SND_OSS)
250         LIB_SOUND=$(LIB_SND_OSS)
251 endif
252
253 # ALSA: Advanced Linux Sound Architecture
254 ifeq ($(DP_SOUND_API), ALSA)
255         OBJ_SOUND=$(OBJ_SND_ALSA)
256         LIB_SOUND=$(LIB_SND_ALSA)
257 endif
258
259 # COREAUDIO: Core Audio
260 ifeq ($(DP_SOUND_API), COREAUDIO)
261         OBJ_SOUND=$(OBJ_SND_COREAUDIO)
262         LIB_SOUND=$(LIB_SND_COREAUDIO)
263 endif
264
265 # BSD: BSD / Sun audio API
266 ifeq ($(DP_SOUND_API), BSD)
267         OBJ_SOUND=$(OBJ_SND_BSD)
268         LIB_SOUND=$(LIB_SND_BSD)
269 endif
270
271 # WIN: DirectX and Win32 WAVE output
272 ifeq ($(DP_SOUND_API), WIN)
273         OBJ_SOUND=$(OBJ_SND_WIN)
274         LIB_SOUND=$(LIB_SND_WIN)
275 endif
276
277 ifeq ($(DP_SOUND_API),3DRAS)
278         OBJ_SOUND=$(OBJ_SND_3DRAS)
279         LIB_SOUND=$(LIB_SND_3DRAS)
280 endif
281
282 ##### Extra CFLAGS #####
283
284 CFLAGS_MAKEDEP?=-MMD
285 ifdef DP_FS_BASEDIR
286         CFLAGS_FS=-DDP_FS_BASEDIR='\"$(DP_FS_BASEDIR)\"'
287 else
288         CFLAGS_FS=
289 endif
290
291 CFLAGS_PRELOAD=
292 ifneq ($(DP_MAKE_TARGET), mingw)
293 ifdef DP_PRELOAD_DEPENDENCIES
294 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
295 # dynamically so they won't get loaded at runtime using dlopen
296         LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
297         LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
298         LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
299         CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
300 endif
301 endif
302
303 ##### GNU Make specific definitions #####
304
305 DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
306
307
308 ##### Definitions shared by all makefiles #####
309 include makefile.inc
310
311
312 ##### Dependency files #####
313
314 -include *.d