]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - makefile.inc
Added CoreAudio (Mac OS X) sound driver. Changed / fixed a couple of Mac OS X related...
[xonotic/darkplaces.git] / makefile.inc
1 # Choose the compiler you want to use
2 CC=gcc
3
4 # athlon optimizations
5 #CPUOPTIMIZATIONS=-march=athlon
6 # athlon xp optimizations
7 #CPUOPTIMIZATIONS=-march=athlon-xp
8 # athlon 64 optimizations
9 #CPUOPTIMIZATIONS=-march=athlon64 -m32
10 # Pentium 3 optimizations
11 #CPUOPTIMIZATIONS=-march=pentium3
12 # Pentium 4 optimizations
13 #CPUOPTIMIZATIONS=-march=pentium4
14 # 686 (Pentium Pro/II) optimizations
15 #CPUOPTIMIZATIONS=-march=i686
16 # No specific CPU (386 compatible)
17 CPUOPTIMIZATIONS=
18
19
20 ###### Sound and audio CD #####
21
22 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o
23
24 # No sound
25 OBJ_SND_NULL=snd_null.o
26 LIB_SND_NULL=
27
28 # Open Sound System (Linux, FreeBSD and Solaris)
29 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
30 LIB_SND_OSS=
31
32 # Advanced Linux Sound Architecture (Linux)
33 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
34 LIB_SND_ALSA=-lasound
35
36 # Core Audio (Mac OS X)
37 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.c
38 LIB_SND_COREAUDIO=-framework CoreAudio
39
40 # BSD / Sun audio API (NetBSD and OpenBSD)
41 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
42 LIB_SND_BSD=
43
44 # DirectX and Win32 WAVE output (Win32)
45 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
46 LIB_SND_WIN=
47
48
49 # CD objects
50 OBJ_NOCD=cd_null.o
51
52
53 ###### Common objects and flags #####
54
55 # Common objects
56 OBJ_COMMON= \
57         cd_shared.o \
58         cgame.o \
59         cgamevm.o \
60         cl_collision.o \
61         cl_demo.o \
62         cl_input.o \
63         cl_main.o \
64         cl_parse.o \
65         cl_particles.o \
66         cl_screen.o \
67         cl_video.o \
68         cmd.o \
69         collision.o \
70         common.o \
71         console.o \
72         curves.o \
73         cvar.o \
74         dpvsimpledecode.o \
75         filematch.o \
76         fractalnoise.o \
77         fs.o \
78         gl_backend.o \
79         gl_draw.o \
80         gl_rmain.o \
81         gl_rsurf.o \
82         gl_textures.o \
83         host.o \
84         host_cmd.o \
85         image.o \
86         jpeg.o \
87         keys.o \
88         lhnet.o \
89         mathlib.o \
90         matrixlib.o \
91         menu.o \
92         meshqueue.o \
93         model_alias.o \
94         model_brush.o \
95         model_shared.o \
96         model_sprite.o \
97         mvm_cmds.o \
98         netconn.o \
99         palette.o \
100         polygon.o \
101         portals.o \
102         protocol.o \
103         prvm_cmds.o \
104         prvm_edict.o \
105         prvm_exec.o \
106         r_crosshairs.o \
107         r_explosion.o \
108         r_lerpanim.o \
109         r_light.o \
110         r_lightning.o \
111         r_modules.o \
112         r_shadow.o \
113         r_sky.o \
114         r_sprites.o \
115         sbar.o \
116         sv_main.o \
117         sv_move.o \
118         sv_phys.o \
119         sv_user.o \
120         svvm_cmds.o \
121         sys_shared.o \
122         ui.o \
123         vid_shared.o \
124         view.o \
125         wad.o \
126         world.o \
127         zone.o
128
129 # note that builddate.c is very intentionally not compiled to a .o before
130 # being linked, because it should be recompiled every time an executable is
131 # built to give the executable a proper date string
132 OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_SND_NULL) $(OBJ_NOCD) $(OBJ_COMMON)
133 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
134
135
136 # Compilation
137 # CFLAGS_COMMON=-MD -Wall -Werror
138 CFLAGS_COMMON=-MD -Wall -Wsign-compare
139 CFLAGS_DEBUG=-ggdb
140 CFLAGS_PROFILE=-g -pg -ggdb
141 CFLAGS_RELEASE=
142
143 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
144 OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
145
146 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
147
148
149 # Link
150 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG)
151 LDFLAGS_PROFILE=-g -pg $(OPTIM_RELEASE)
152 LDFLAGS_RELEASE=$(OPTIM_RELEASE)
153
154
155 ##### UNIX specific variables #####
156
157 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
158
159 LDFLAGS_UNIXCOMMON=-lm
160 #LDFLAGS_UNIXCL=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
161 ifeq ($(DP_MAKE_TARGET), sunos)
162         LDFLAGS_UNIXCL=-R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86vm $(LIB_SOUND)
163 else
164         LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
165 endif
166
167 LDFLAGS_UNIXSDL=`sdl-config --libs`
168 EXE_UNIXCL=darkplaces-glx
169 EXE_UNIXSV=darkplaces-dedicated
170 EXE_UNIXSDL=darkplaces-sdl
171
172 CMD_UNIXRM=rm -rf
173
174
175 ##### Linux specific variables #####
176
177 # If you want CD sound in Linux
178 OBJ_LINUXCD=cd_linux.o
179 # If you want no CD audio
180 #OBJ_LINUXCD=$(OBJ_NOCD)
181
182 # Link
183 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
184 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
185 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
186
187
188 ##### Mac OS X specific variables #####
189
190 # No CD support available
191 OBJ_MACOSXCD=$(OBJ_NOCD)
192
193 # Link
194 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework Carbon $(LIB_SOUND)
195 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
196 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl `sdl-config --static-libs`
197
198 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
199
200 EXE_MACOSXCL=darkplaces-agl
201
202
203 ##### SunOS specific variables #####
204
205 # No CD support available
206 OBJ_SUNOSCD=$(OBJ_NOCD)
207
208 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
209
210 # Link
211 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXCL)
212 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl
213 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
214
215
216 ##### BSD specific variables #####
217
218 #if you want CD sound in BSD
219 OBJ_BSDCD=cd_bsd.o
220 #if you want no CD audio
221 #OBJ_BSDCD=$(OBJ_NOCD)
222
223 # Link
224 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
225 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
226 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
227
228
229 ##### Win32 specific variables #####
230
231 #if you want CD sound in Win32
232 OBJ_WINCD=cd_win.o
233 #if you want no CD audio
234 #OBJ_WINCD=$(OBJ_NOCD)
235
236 OBJ_WGL= builddate.c darkplaces.o sys_win.o vid_wgl.o conproc.o $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_COMMON)
237
238 # Link
239 LDFLAGS_WINCOMMON=-lwinmm -lwsock32
240 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
241 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole
242 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) `sdl-config --libs`
243 EXE_WINCL=darkplaces.exe
244 EXE_WINSV=darkplaces-dedicated.exe
245 EXE_WINSDL=darkplaces-sdl.exe
246
247
248 ##### Commands #####
249
250 .PHONY : clean help \
251          debug profile release \
252          cl-debug cl-profile cl-release \
253          sv-debug sv-profile sv-release \
254          sdl-debug sdl-profile sdl-release
255
256 help:
257         @echo
258         @echo "===== Choose one ====="
259         @echo "* $(MAKE) clean       : delete all files produced by the build"
260         @echo "* $(MAKE) help        : this help"
261         @echo "* $(MAKE) debug       : make client and server binaries (debug versions)"
262         @echo "* $(MAKE) profile     : make client and server binaries (profile versions)"
263         @echo "* $(MAKE) release     : make client and server binaries (release versions)"
264         @echo "* $(MAKE) cl-debug    : make client (debug version)"
265         @echo "* $(MAKE) cl-profile  : make client (profile version)"
266         @echo "* $(MAKE) cl-release  : make client (release version)"
267         @echo "* $(MAKE) sv-debug    : make dedicated server (debug version)"
268         @echo "* $(MAKE) sv-profile  : make dedicated server (profile version)"
269         @echo "* $(MAKE) sv-release  : make dedicated server (release version)"
270         @echo "* $(MAKE) sdl-debug   : make SDL client (debug version)"
271         @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
272         @echo "* $(MAKE) sdl-release : make SDL client (release version)"
273         @echo
274
275 debug :
276         $(MAKE) sv-debug cl-debug sdl-debug
277
278 profile :
279         $(MAKE) sv-profile cl-profile sdl-profile
280
281 release :
282         $(MAKE) sv-release cl-release sdl-release
283
284 cl-debug :
285         $(MAKE) bin-debug \
286                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
287                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
288
289 cl-profile :
290         $(MAKE) bin-profile \
291                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
292                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
293
294 cl-release :
295         $(MAKE) bin-release \
296                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
297                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
298
299 sv-debug :
300         $(MAKE) bin-debug \
301                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
302                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
303
304 sv-profile :
305         $(MAKE) bin-profile \
306                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
307                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
308
309 sv-release :
310         $(MAKE) bin-release \
311                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
312                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
313
314 sdl-debug :
315         $(MAKE) bin-debug \
316                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
317                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
318
319 sdl-profile :
320         $(MAKE) bin-profile \
321                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
322                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
323
324 sdl-release :
325         $(MAKE) bin-release \
326                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
327                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
328
329 bin-debug :
330         @echo
331         @echo "========== $(EXE) (debug) =========="
332         $(MAKE) $(EXE) \
333                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
334                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
335                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
336
337 bin-profile :
338         @echo
339         @echo "========== $(EXE) (profile) =========="
340         $(MAKE) $(EXE) \
341                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
342                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
343                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
344
345 bin-release :
346         @echo
347         @echo "========== $(EXE) (release) =========="
348         $(MAKE) $(EXE) \
349                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
350                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
351                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
352         strip $(EXE)
353
354 vid_glx.o: vid_glx.c
355         $(DO_CC) -I/usr/X11R6/include
356
357 vid_sdl.o: vid_sdl.c
358         $(DO_CC) `sdl-config --cflags`
359
360 sys_sdl.o: sys_sdl.c
361         $(DO_CC) `sdl-config --cflags`
362
363 snd_sdl.o: snd_sdl.c
364         $(DO_CC) `sdl-config --cflags`
365
366 cd_sdl.o: cd_sdl.c
367         $(DO_CC) `sdl-config --cflags`
368
369 darkplaces.o: %.o : %.rc
370         windres -o $@ $<
371
372 .c.o:
373         $(DO_CC)
374
375 $(EXE_CL): $(OBJ_CL)
376         $(DO_LD)
377
378 $(EXE_SV): $(OBJ_SV)
379         $(DO_LD)
380
381 $(EXE_SDL): $(OBJ_SDL)
382         $(DO_LD)
383
384 clean:
385         -$(CMD_RM) $(EXE_CL)
386         -$(CMD_RM) $(EXE_SV)
387         -$(CMD_RM) $(EXE_SDL)
388         -$(CMD_RM) *.o
389         -$(CMD_RM) *.d