Changes necessary to build and run on Solaris 10 x86
[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         protocol.o \
79         mvm_cmds.o \
80         svvm_cmds.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 ##### Mac OS X specific variables #####
172
173 #OBJ_MACOSXSOUND=$(OBJ_COMMONSOUND) snd_coreaudio.c
174 OBJ_MACOSXSOUND=$(OBJ_NOSOUND)
175 LIB_MACOSXSOUND=
176
177 # If you want CD sound in Mac OS X
178 #OBJ_MACOSXCD=cd_macosx.o
179 # If you want no CD audio
180 OBJ_MACOSXCD=$(OBJ_NOCD)
181
182 # Link
183 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
184 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
185 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
186
187 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
188
189 ##### SunOS specific variables #####
190
191 OBJ_SUNOSSOUND=$(OBJ_OSSSOUND)
192 LIB_SUNOSSOUND=$(LIB_OSSSOUND)
193
194 # No CD support available
195 OBJ_SUNOSCD=$(OBJ_NOCD)
196
197 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP
198
199 # Link
200 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXCL)
201 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl
202 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
203
204
205 ##### BSD specific variables #####
206
207 OBJ_BSDSOUND=$(OBJ_COMMONSOUND) snd_bsd.o
208 #OBJ_BSDSOUND=$(OBJ_NOSOUND)
209 LIB_BSDSOUND=
210
211 #if you want CD sound in BSD
212 OBJ_BSDCD=cd_bsd.o
213 #if you want no CD audio
214 #OBJ_BSDCD=$(OBJ_NOCD)
215
216 # Link
217 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
218 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
219 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
220
221
222 ##### Win32 specific variables #####
223
224 OBJ_WINSOUND=$(OBJ_COMMONSOUND) snd_win.o
225 #OBJ_WINSOUND=$(OBJ_NOSOUND)
226 LIB_WINSOUND=
227
228 #if you want CD sound in Win32
229 OBJ_WINCD=cd_win.o
230 #if you want no CD audio
231 #OBJ_WINCD=$(OBJ_NOCD)
232
233 OBJ_WGL= builddate.c darkplaces.o sys_win.o vid_wgl.o conproc.o $(OBJ_WINSOUND) $(OBJ_WINCD) $(OBJ_COMMON)
234
235 # Link
236 LDFLAGS_WINCOMMON=-lwinmm -lwsock32
237 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
238 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole
239 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) `sdl-config --libs`
240 EXE_WINCL=darkplaces.exe
241 EXE_WINSV=darkplaces-dedicated.exe
242 EXE_WINSDL=darkplaces-sdl.exe
243
244
245 ##### Commands #####
246
247 .PHONY : clean help \
248          debug profile release \
249          cl-debug cl-profile cl-release \
250          sv-debug sv-profile sv-release \
251          sdl-debug sdl-profile sdl-release
252
253 help:
254         @echo
255         @echo "===== Choose one ====="
256         @echo "* $(MAKE) clean       : delete all files produced by the build"
257         @echo "* $(MAKE) help        : this help"
258         @echo "* $(MAKE) debug       : make client and server binaries (debug versions)"
259         @echo "* $(MAKE) profile     : make client and server binaries (profile versions)"
260         @echo "* $(MAKE) release     : make client and server binaries (release versions)"
261         @echo "* $(MAKE) cl-debug    : make client (debug version)"
262         @echo "* $(MAKE) cl-profile  : make client (profile version)"
263         @echo "* $(MAKE) cl-release  : make client (release version)"
264         @echo "* $(MAKE) sv-debug    : make dedicated server (debug version)"
265         @echo "* $(MAKE) sv-profile  : make dedicated server (profile version)"
266         @echo "* $(MAKE) sv-release  : make dedicated server (release version)"
267         @echo "* $(MAKE) sdl-debug   : make SDL client (debug version)"
268         @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
269         @echo "* $(MAKE) sdl-release : make SDL client (release version)"
270         @echo
271
272 debug :
273         $(MAKE) sdl-debug cl-debug sv-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET)
274
275 profile :
276         $(MAKE) sdl-profile cl-profile sv-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET)
277
278 release :
279         $(MAKE) sdl-release cl-release sv-release DP_MAKE_TARGET=$(DP_MAKE_TARGET)
280
281 cl-debug :
282         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
283                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
284
285 cl-profile :
286         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
287                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
288
289 cl-release :
290         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
291                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
292
293 sv-debug :
294         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
295                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
296
297 sv-profile :
298         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
299                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
300
301 sv-release :
302         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
303                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
304
305 sdl-debug :
306         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
307                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
308
309 sdl-profile :
310         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
311                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
312
313 sdl-release :
314         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
315                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
316
317 bin-debug :
318         @echo
319         @echo "========== $(EXE) (debug) =========="
320         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
321                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
322                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
323
324 bin-profile :
325         @echo
326         @echo "========== $(EXE) (profile) =========="
327         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
328                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
329                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
330
331 bin-release :
332         @echo
333         @echo "========== $(EXE) (release) =========="
334         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
335                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
336                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
337         strip $(EXE)
338
339 vid_glx.o: vid_glx.c
340         $(DO_CC) -I/usr/X11R6/include
341
342 vid_sdl.o: vid_sdl.c
343         $(DO_CC) `sdl-config --cflags`
344
345 sys_sdl.o: sys_sdl.c
346         $(DO_CC) `sdl-config --cflags`
347
348 snd_sdl.o: snd_sdl.c
349         $(DO_CC) `sdl-config --cflags`
350
351 cd_sdl.o: cd_sdl.c
352         $(DO_CC) `sdl-config --cflags`
353
354 darkplaces.o: %.o : %.rc
355         windres -o $@ $<
356
357 .c.o:
358         $(DO_CC)
359
360 $(EXE_CL): $(OBJ_CL)
361         $(DO_LD)
362
363 $(EXE_SV): $(OBJ_SV)
364         $(DO_LD)
365
366 $(EXE_SDL): $(OBJ_SDL)
367         $(DO_LD)
368
369 clean:
370         -$(CMD_RM) $(EXE_CL)
371         -$(CMD_RM) $(EXE_SV)
372         -$(CMD_RM) $(EXE_SDL)
373         -$(CMD_RM) *.o
374         -$(CMD_RM) *.d