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