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