]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - makefile.inc
-CVS: ----------------------------------------------------------------------
[xonotic/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         mvm_cmds.o \
83         svvm_cmds.o \
84         prvm_cmds.o \
85         prvm_edict.o \
86         prvm_exec.o \
87         r_crosshairs.o \
88         r_explosion.o \
89         r_lerpanim.o \
90         r_light.o \
91         r_lightning.o \
92         r_modules.o \
93         r_shadow.o \
94         r_sky.o \
95         r_sprites.o \
96         sbar.o \
97         sv_main.o \
98         sv_move.o \
99         sv_phys.o \
100         sv_user.o \
101         sys_shared.o \
102         ui.o \
103         vid_shared.o \
104         view.o \
105         wad.o \
106         winding.o \
107         world.o \
108         zone.o
109
110 # note that builddate.c is very intentionally not compiled to a .o before
111 # being linked, because it should be recompiled every time an executable is
112 # built to give the executable a proper date string
113 OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_NOSOUND) $(OBJ_NOCD) $(OBJ_COMMON)
114 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_COMMONSOUND) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
115
116
117 # Compilation
118 # CFLAGS_COMMON=-MD -Wall -Werror
119 CFLAGS_COMMON=-MD -Wall
120 CFLAGS_DEBUG=-ggdb
121 CFLAGS_PROFILE=-g -pg -ggdb
122 CFLAGS_RELEASE=
123
124 OPTIM_DEBUG=
125 OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
126
127 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
128
129
130 # Link
131 LDFLAGS_DEBUG=-g -ggdb
132 LDFLAGS_PROFILE=-g -pg
133 LDFLAGS_RELEASE=
134
135
136 ##### UNIX specific variables #####
137
138 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
139
140 LDFLAGS_UNIXCOMMON=-lm
141 #LDFLAGS_UNIXCL=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
142 LDFLAGS_UNIXCL=$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
143 LDFLAGS_UNIXSDL=`sdl-config --libs`
144 EXE_UNIXCL=darkplaces-glx
145 EXE_UNIXSV=darkplaces-dedicated
146 EXE_UNIXSDL=darkplaces-sdl
147
148 CMD_UNIXRM=rm -rf
149
150
151 ##### Linux specific variables #####
152
153 # Recommended for: anyone not using ALSA
154 OBJ_LINUXSOUND=$(OBJ_OSSSOUND)
155 LIB_LINUXSOUND=$(LIB_OSSSOUND)
156 # Recommended for: anyone using ALSA
157 #OBJ_LINUXSOUND=$(OBJ_COMMONSOUND) snd_alsa.o
158 #LIB_LINUXSOUND=-lasound
159 # Recommended for: anyone who can't use the above drivers
160 #OBJ_LINUXSOUND=$(OBJ_NOSOUND)
161 #LIB_LINUXSOUND=
162
163 # If you want CD sound in Linux
164 OBJ_LINUXCD=cd_linux.o
165 # If you want no CD audio
166 #OBJ_LINUXCD=$(OBJ_NOCD)
167
168 # Link
169 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
170 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
171 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
172
173
174 ##### Mac OS X specific variables #####
175
176 #OBJ_MACOSXSOUND=$(OBJ_COMMONSOUND) snd_coreaudio.c
177 OBJ_MACOSXSOUND=$(OBJ_NOSOUND)
178 LIB_MACOSXSOUND=
179
180 # If you want CD sound in Mac OS X
181 #OBJ_MACOSXCD=cd_macosx.o
182 # If you want no CD audio
183 OBJ_MACOSXCD=$(OBJ_NOCD)
184
185 # Link
186 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
187 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
188 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
189
190 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
191
192
193 ##### BSD specific variables #####
194
195 OBJ_BSDSOUND=$(OBJ_COMMONSOUND) snd_bsd.o
196 #OBJ_BSDSOUND=$(OBJ_NOSOUND)
197 LIB_BSDSOUND=
198
199 #if you want CD sound in BSD
200 OBJ_BSDCD=cd_bsd.o
201 #if you want no CD audio
202 #OBJ_BSDCD=$(OBJ_NOCD)
203
204 # Link
205 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
206 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
207 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
208
209
210 ##### Win32 specific variables #####
211
212 OBJ_WINSOUND=$(OBJ_COMMONSOUND) snd_win.o
213 #OBJ_WINSOUND=$(OBJ_NOSOUND)
214 LIB_WINSOUND=
215
216 #if you want CD sound in Win32
217 OBJ_WINCD=cd_win.o
218 #if you want no CD audio
219 #OBJ_WINCD=$(OBJ_NOCD)
220
221 OBJ_WGL= builddate.c darkplaces.o sys_win.o vid_wgl.o conproc.o $(OBJ_WINSOUND) $(OBJ_WINCD) $(OBJ_COMMON)
222
223 # Link
224 LDFLAGS_WINCOMMON=-lwinmm -lwsock32
225 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
226 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole
227 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) `sdl-config --libs`
228 EXE_WINCL=darkplaces.exe
229 EXE_WINSV=darkplaces-dedicated.exe
230 EXE_WINSDL=darkplaces-sdl.exe
231
232
233 ##### Commands #####
234
235 .PHONY : clean help \
236          debug profile release \
237          cl-debug cl-profile cl-release \
238          sv-debug sv-profile sv-release \
239          sdl-debug sdl-profile sdl-release
240
241 help:
242         @echo
243         @echo "===== Choose one ====="
244         @echo "* $(MAKE) clean       : delete all files produced by the build"
245         @echo "* $(MAKE) help        : this help"
246         @echo "* $(MAKE) debug       : make client and server binaries (debug versions)"
247         @echo "* $(MAKE) profile     : make client and server binaries (profile versions)"
248         @echo "* $(MAKE) release     : make client and server binaries (release versions)"
249         @echo "* $(MAKE) cl-debug    : make client (debug version)"
250         @echo "* $(MAKE) cl-profile  : make client (profile version)"
251         @echo "* $(MAKE) cl-release  : make client (release version)"
252         @echo "* $(MAKE) sv-debug    : make dedicated server (debug version)"
253         @echo "* $(MAKE) sv-profile  : make dedicated server (profile version)"
254         @echo "* $(MAKE) sv-release  : make dedicated server (release version)"
255         @echo "* $(MAKE) sdl-debug   : make SDL client (debug version)"
256         @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
257         @echo "* $(MAKE) sdl-release : make SDL client (release version)"
258         @echo
259
260 debug :
261         $(MAKE) sdl-debug cl-debug sv-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET)
262
263 profile :
264         $(MAKE) sdl-profile cl-profile sv-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET)
265
266 release :
267         $(MAKE) sdl-release cl-release sv-release DP_MAKE_TARGET=$(DP_MAKE_TARGET)
268
269 cl-debug :
270         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
271                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
272
273 cl-profile :
274         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
275                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
276
277 cl-release :
278         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
279                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
280
281 sv-debug :
282         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
283                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
284
285 sv-profile :
286         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
287                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
288
289 sv-release :
290         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
291                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
292
293 sdl-debug :
294         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
295                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
296
297 sdl-profile :
298         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
299                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
300
301 sdl-release :
302         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
303                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
304
305 bin-debug :
306         @echo
307         @echo "========== $(EXE) (debug) =========="
308         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
309                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
310                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
311
312 bin-profile :
313         @echo
314         @echo "========== $(EXE) (profile) =========="
315         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
316                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
317                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
318
319 bin-release :
320         @echo
321         @echo "========== $(EXE) (release) =========="
322         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
323                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
324                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
325         strip $(EXE)
326
327 vid_glx.o: vid_glx.c
328         $(DO_CC) -I/usr/X11R6/include
329
330 vid_sdl.o: vid_sdl.c
331         $(DO_CC) `sdl-config --cflags`
332
333 sys_sdl.o: sys_sdl.c
334         $(DO_CC) `sdl-config --cflags`
335
336 snd_sdl.o: snd_sdl.c
337         $(DO_CC) `sdl-config --cflags`
338
339 cd_sdl.o: cd_sdl.c
340         $(DO_CC) `sdl-config --cflags`
341
342 darkplaces.o: %.o : %.rc
343         windres -o $@ $<
344
345 .c.o:
346         $(DO_CC)
347
348 $(EXE_CL): $(OBJ_CL)
349         $(DO_LD)
350
351 $(EXE_SV): $(OBJ_SV)
352         $(DO_LD)
353
354 $(EXE_SDL): $(OBJ_SDL)
355         $(DO_LD)
356
357 clean:
358         -$(CMD_RM) $(EXE_CL)
359         -$(CMD_RM) $(EXE_SV)
360         -$(CMD_RM) $(EXE_SDL)
361         -$(CMD_RM) *.o
362         -$(CMD_RM) *.d