- Toggled "strip executable" in the Dev-C++ project file and updated the version...
[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 ##### BSD specific variables #####
173
174 OBJ_BSDSOUND=$(OBJ_COMMONSOUND) snd_bsd.o
175 #OBJ_BSDSOUND=$(OBJ_NOSOUND)
176 LIB_BSDSOUND=
177
178 #if you want CD sound in BSD
179 OBJ_BSDCD=cd_bsd.o
180 #if you want no CD audio
181 #OBJ_BSDCD=$(OBJ_NOCD)
182
183 # Link
184 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
185 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
186 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
187
188
189 ##### Win32 specific variables #####
190
191 OBJ_WINSOUND=$(OBJ_COMMONSOUND) snd_win.o
192 #OBJ_WINSOUND=$(OBJ_NOSOUND)
193 LIB_WINSOUND=
194
195 #if you want CD sound in Win32
196 OBJ_WINCD=cd_win.o
197 #if you want no CD audio
198 #OBJ_WINCD=$(OBJ_NOCD)
199
200 OBJ_WGL= builddate.c darkplaces.o sys_win.o vid_wgl.o conproc.o $(OBJ_WINSOUND) $(OBJ_WINCD) $(OBJ_COMMON)
201
202 # Link
203 LDFLAGS_WINCOMMON=-lwinmm -lwsock32
204 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
205 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole
206 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) `sdl-config --libs`
207 EXE_WINCL=darkplaces.exe
208 EXE_WINSV=darkplaces-dedicated.exe
209 EXE_WINSDL=darkplaces-sdl.exe
210
211
212 ##### Commands #####
213
214 .PHONY : clean help \
215          debug profile release \
216          cl-debug cl-profile cl-release \
217          sv-debug sv-profile sv-release \
218          sdl-debug sdl-profile sdl-release
219
220 help:
221         @echo
222         @echo "===== Choose one ====="
223         @echo "* $(MAKE) clean       : delete all files produced by the build"
224         @echo "* $(MAKE) help        : this help"
225         @echo "* $(MAKE) debug       : make client and server binaries (debug versions)"
226         @echo "* $(MAKE) profile     : make client and server binaries (profile versions)"
227         @echo "* $(MAKE) release     : make client and server binaries (release versions)"
228         @echo "* $(MAKE) cl-debug    : make client (debug version)"
229         @echo "* $(MAKE) cl-profile  : make client (profile version)"
230         @echo "* $(MAKE) cl-release  : make client (release version)"
231         @echo "* $(MAKE) sv-debug    : make dedicated server (debug version)"
232         @echo "* $(MAKE) sv-profile  : make dedicated server (profile version)"
233         @echo "* $(MAKE) sv-release  : make dedicated server (release version)"
234         @echo "* $(MAKE) sdl-debug   : make SDL client (debug version)"
235         @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
236         @echo "* $(MAKE) sdl-release : make SDL client (release version)"
237         @echo
238
239 debug :
240         $(MAKE) cl-debug sv-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET)
241
242 profile :
243         $(MAKE) cl-profile sv-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET)
244
245 release :
246         $(MAKE) cl-release sv-release DP_MAKE_TARGET=$(DP_MAKE_TARGET)
247
248 cl-debug :
249         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
250                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
251
252 cl-profile :
253         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
254                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
255
256 cl-release :
257         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
258                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
259
260 sv-debug :
261         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
262                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
263
264 sv-profile :
265         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
266                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
267
268 sv-release :
269         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
270                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
271
272 sdl-debug :
273         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
274                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
275
276 sdl-profile :
277         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
278                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
279
280 sdl-release :
281         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
282                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
283
284 bin-debug :
285         @echo
286         @echo "========== $(EXE) (debug) =========="
287         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
288                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
289                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
290
291 bin-profile :
292         @echo
293         @echo "========== $(EXE) (profile) =========="
294         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
295                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
296                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
297
298 bin-release :
299         @echo
300         @echo "========== $(EXE) (release) =========="
301         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
302                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
303                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
304         strip $(EXE)
305
306 vid_glx.o: vid_glx.c
307         $(DO_CC) -I/usr/X11R6/include
308
309 vid_sdl.o: vid_sdl.c
310         $(DO_CC) `sdl-config --cflags`
311
312 sys_sdl.o: sys_sdl.c
313         $(DO_CC) `sdl-config --cflags`
314
315 snd_sdl.o: snd_sdl.c
316         $(DO_CC) `sdl-config --cflags`
317
318 cd_sdl.o: cd_sdl.c
319         $(DO_CC) `sdl-config --cflags`
320
321 darkplaces.o: %.o : %.rc
322         windres -o $@ $<
323
324 .c.o:
325         $(DO_CC)
326
327 $(EXE_CL): $(OBJ_CL)
328         $(DO_LD)
329
330 $(EXE_SV): $(OBJ_SV)
331         $(DO_LD)
332
333 $(EXE_SDL): $(OBJ_SDL)
334         $(DO_LD)
335
336 clean:
337         -$(CMD_RM) $(EXE_CL)
338         -$(CMD_RM) $(EXE_SV)
339         -$(CMD_RM) $(EXE_SDL)
340         -$(CMD_RM) *.o
341         -$(CMD_RM) *.d