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