Added sound support to the NetBSD port. Most of the code comes from the original...
[divverent/darkplaces.git] / makefile.bsd
1 ##### Variables that you may want to modify #####
2
3 #choose the compiler you want to use
4 CC=gcc
5
6 MAKE:=$(MAKE) -f makefile.bsd
7
8 OBJ_BSDSOUND=snd_bsd.o snd_dma.o snd_mix.o snd_mem.o ogg.o
9 #OBJ_BSDSOUND=snd_null.o
10 BSDSOUNDLIB=
11
12 #if you want CD sound in BSD
13 OBJ_BSDCD=cd_shared.o cd_bsd.o
14 #if you want no CD audio
15 #OBJ_BSDCD=cd_null.o
16
17 #K6/athlon optimizations
18 #CPUOPTIMIZATIONS=-march=k6
19 #note: don't use -march=athlon, every gcc which has it currently (2.96-3.1)
20 #have optimizer bugs (like entities disappearing randomly - a bug with
21 #compiling BOX_ON_PLANE_SIDE in mathlib.h)
22 #CPUOPTIMIZATIONS=-march=athlon
23 #686 optimizations
24 #CPUOPTIMIZATIONS=-march=i686
25 #no specific CPU
26 CPUOPTIMIZATIONS=
27
28
29 ##### Variables that you shouldn't care about #####
30
31 CMD_RM=rm -f
32
33 # Objects
34 CLIENTOBJECTS=  cgame.o cgamevm.o cl_collision.o cl_demo.o cl_input.o \
35                 cl_main.o cl_parse.o cl_particles.o cl_screen.o cl_video.o \
36                 console.o dpvsimpledecode.o fractalnoise.o gl_backend.o \
37                 gl_draw.o gl_models.o gl_rmain.o gl_rsurf.o gl_textures.o \
38                 jpeg.o keys.o menu.o meshqueue.o r_crosshairs.o r_explosion.o \
39                 r_lerpanim.o r_light.o r_lightning.o r_modules.o r_sky.o \
40                 r_sprites.o sbar.o ui.o vid_shared.o view.o wavefile.o \
41                 r_shadow.o prvm_exec.o prvm_edict.o prvm_cmds.o
42 SERVEROBJECTS=  pr_cmds.o pr_edict.o pr_exec.o sv_main.o sv_move.o \
43                 sv_phys.o sv_user.o
44 SHAREDOBJECTS=  cmd.o collision.o common.o crc.o cvar.o \
45                 filematch.o host.o host_cmd.o image.o mathlib.o matrixlib.o \
46                 model_alias.o model_brush.o model_shared.o model_sprite.o \
47                 netconn.o lhnet.o palette.o portals.o protocol.o fs.o \
48                 sys_shared.o winding.o world.o wad.o zone.o curves.o
49 COMMONOBJECTS= $(CLIENTOBJECTS) $(SERVEROBJECTS) $(SHAREDOBJECTS)
50
51 # note that builddate.c is very intentionally not compiled to a .o before
52 # being linked, because it should be recompiled every time an executable is
53 # built to give the executable a proper date string
54 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_BSDCD) $(OBJ_BSDSOUND) $(COMMONOBJECTS)
55 OBJ_DED= builddate.c sys_linux.o vid_null.o cd_null.o snd_null.o $(COMMONOBJECTS)
56
57
58 # Compilation
59 # CFLAGS_NONEXECOMMON=-MD -Wall -Werror
60 CFLAGS_NONEXECOMMON=-MD -Wall
61 CFLAGS_DEBUG=-ggdb
62 CFLAGS_PROFILE=-g -pg -ggdb
63 CFLAGS_RELEASE=
64
65 OPTIM_DEBUG=
66 OPTIM_RELEASE=  -O2 -fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS)
67
68 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
69
70
71 # Link
72 # LordHavoc note: I have been informed that system libraries must come last
73 # on the linker line, and that -lm must always be last
74 LDFLAGS_GLX=-lm -lutil
75 LDFLAGS_DED=-lm
76 LDFLAGS_DEBUG=-g -ggdb
77 LDFLAGS_PROFILE=-g -pg
78 LDFLAGS_RELEASE=
79
80 EXE_GLX=darkplaces-glx
81 EXE_DED=darkplaces-dedicated
82
83 DO_LD=$(CC) -o $@ $> $(LDFLAGS)
84
85
86 ##### Commands #####
87
88 .PHONY : clean help \
89          debug profile release \
90          glx-debug glx-profile glx-release \
91          ded-debug ded-profile ded-release
92
93 help:
94         @echo
95         @echo "===== Choose one ====="
96         @echo "* $(MAKE) clean          : delete the binaries, and .o and .d files"
97         @echo "* $(MAKE) help           : this help"
98         @echo "* $(MAKE) debug          : make GLX and dedicated binaries (debug versions)"
99         @echo "* $(MAKE) profile        : make GLX and dedicated binaries (profile versions)"
100         @echo "* $(MAKE) release        : make GLX and dedicated binaries (release versions)"
101         @echo "* $(MAKE) glx-debug      : make GLX client (debug version)"
102         @echo "* $(MAKE) glx-profile    : make GLX client (profile version)"
103         @echo "* $(MAKE) glx-release    : make GLX client (release version)"
104         @echo "* $(MAKE) ded-debug      : make dedicated server (debug version)"
105         @echo "* $(MAKE) ded-profile    : make dedicated server (profile version)"
106         @echo "* $(MAKE) ded-release    : make dedicated server (release version)"
107         @echo
108
109 debug :
110         $(MAKE) glx-debug ded-debug
111
112 profile :
113         $(MAKE) glx-profile ded-profile
114
115 release :
116         $(MAKE) glx-release ded-release
117
118 glx-debug :
119         $(MAKE) bin-debug EXE="$(EXE_GLX)" LDFLAGS_COMMON="$(LDFLAGS_GLX)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
120
121 glx-profile :
122         $(MAKE) bin-profile EXE="$(EXE_GLX)" LDFLAGS_COMMON="$(LDFLAGS_GLX)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
123
124 glx-release :
125         $(MAKE) bin-release EXE="$(EXE_GLX)" LDFLAGS_COMMON="$(LDFLAGS_GLX)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
126
127 ded-debug :
128         $(MAKE) bin-debug EXE="$(EXE_DED)" LDFLAGS_COMMON="$(LDFLAGS_DED)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
129
130 ded-profile :
131         $(MAKE) bin-profile EXE="$(EXE_DED)" LDFLAGS_COMMON="$(LDFLAGS_DED)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
132
133 ded-release :
134         $(MAKE) bin-release EXE="$(EXE_DED)" LDFLAGS_COMMON="$(LDFLAGS_DED)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
135
136 bin-debug :
137         @echo
138         @echo "========== $(EXE) (debug) =========="
139         $(MAKE) $(EXE) \
140                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
141                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
142
143 bin-profile :
144         @echo
145         @echo "========== $(EXE) (profile) =========="
146         $(MAKE) $(EXE) \
147                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
148                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
149
150 bin-release :
151         @echo
152         @echo "========== $(EXE) (release) =========="
153         $(MAKE) $(EXE) \
154                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
155                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
156         strip $(EXE)
157
158 vid_glx.o: vid_glx.c
159         $(DO_CC) -I/usr/X11R6/include
160
161 .c.o:
162         $(DO_CC)
163
164 $(EXE_GLX):  $(OBJ_GLX)
165         $(DO_LD) -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(LINUXSOUNDLIB)
166
167 $(EXE_DED): $(OBJ_DED)
168         $(DO_LD)
169
170 clean:
171         -$(CMD_RM) $(EXE_GLX)
172         -$(CMD_RM) $(EXE_DED)
173         -$(CMD_RM) *.o
174         -$(CMD_RM) *.d
175
176
177 ##### Dependency files #####
178
179 DEPEND_FILES != ls *.d
180 .for i in $(DEPEND_FILES)
181 .       include "$i"
182 .endfor