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