]> git.xonotic.org Git - xonotic/darkplaces.git/blob - makefile
darkplaces-dedicated.exe now builds
[xonotic/darkplaces.git] / makefile
1 ##### Variables that you may want to modify #####
2
3 #choose the compiler you want to use
4 CC=gcc
5
6 #recommended for: anyone not using ALSA 0.5
7 OBJ_SND=snd_oss.o snd_dma.o snd_mix.o snd_mem.o
8 SOUNDLIB=
9 #recommended for: anyone using ALSA 0.5
10 #OBJ_SND=snd_alsa_0_5.o snd_dma.o snd_mix.o snd_mem.o
11 #SOUNDLIB=-lasound
12 #recommended for: no one (this driver needs to be updated, it doesn't compile anymore)
13 #OBJ_SND=snd_alsa_0_9.o snd_dma.o snd_mix.o snd_mem.o
14 #SOUNDLIB=-lasound
15 #recommended for: anyone who can't use the above drivers
16 #OBJ_SND=snd_null.o
17 #SOUNDLIB=
18
19 #if you want CD sound in Linux
20 OBJ_CD=cd_linux.o
21 #if you want no CD audio
22 #OBJ_CD=cd_null.o
23
24 #K6/athlon optimizations
25 #CPUOPTIMIZATIONS=-march=k6
26 #note: don't use -march=athlon, every gcc which has it currently (2.96-3.1)
27 #have optimizer bugs (like entities disappearing randomly - a bug with
28 #compiling BOX_ON_PLANE_SIDE in mathlib.h)
29 #CPUOPTIMIZATIONS=-march=athlon
30 #686 optimizations
31 #CPUOPTIMIZATIONS=-march=i686
32 #no specific CPU
33 CPUOPTIMIZATIONS=
34
35
36 ##### Variables that you shouldn't care about #####
37
38 # Objects
39 CLIENTOBJECTS=  cgame.o cgamevm.o chase.o cl_collision.o cl_demo.o cl_input.o \
40                 cl_main.o cl_parse.o cl_particles.o cl_screen.o cl_video.o \
41                 console.o dpvsimpledecode.o fractalnoise.o gl_backend.o \
42                 gl_draw.o gl_models.o gl_rmain.o gl_rsurf.o gl_textures.o \
43                 jpeg.o keys.o menu.o meshqueue.o r_crosshairs.o r_explosion.o \
44                 r_lerpanim.o r_light.o r_modules.o r_sky.o \
45                 r_sprites.o sbar.o ui.o vid_shared.o view.o wavefile.o \
46                 r_shadow.o
47 SERVEROBJECTS=  pr_cmds.o pr_edict.o pr_exec.o sv_light.o sv_main.o sv_move.o \
48                 sv_phys.o sv_user.o
49 SHAREDOBJECTS=  builddate.o cmd.o collision.o common.o crc.o cvar.o \
50                 filematch.o host.o host_cmd.o image.o mathlib.o matrixlib.o \
51                 model_alias.o model_brush.o model_shared.o model_sprite.o \
52                 net_bsd.o net_dgrm.o net_loop.o net_main.o net_master.o \
53                 net_udp.o palette.o portals.o protocol.o fs.o \
54                 sys_shared.o world.o wad.o zone.o
55 COMMONOBJECTS= $(CLIENTOBJECTS) $(SERVEROBJECTS) $(SHAREDOBJECTS)
56
57 # objects used by glx target
58 OBJ_GLX= sys_linux.o vid_glx.o $(OBJ_CD) $(OBJ_SND) $(COMMONOBJECTS)
59 # objects used by dedicated target
60 OBJ_DED= sys_linux.o vid_null.o cd_null.o snd_null.o $(COMMONOBJECTS)
61
62
63 # Compilation
64 CFLAGS_COMMON=-MD -Wall -Werror
65 CFLAGS_DEBUG=-ggdb
66 CFLAGS_PROFILE=-g -pg -ggdb
67 CFLAGS_RELEASE=
68
69 OPTIM_DEBUG=
70 OPTIM_RELEASE=  -O9 -fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS)
71
72 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
73
74
75 # Link
76 # LordHavoc note: I have been informed that system libraries must come last
77 # on the linker line, and that -lm must always be last
78 LDFLAGS_COMMON=-ldl -lm
79 LDFLAGS_DEBUG=-g -ggdb
80 LDFLAGS_PROFILE=-g -pg
81 LDFLAGS_RELEASE=
82
83 EXE_GLX=darkplaces-glx
84 EXE_DED=darkplaces-dedicated
85
86 GLX_LIB=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(SOUNDLIB)
87
88 DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
89
90
91 ##### Commands #####
92
93 .PHONY : clean help \
94          debug profile release \
95          glx-debug glx-profile glx-release \
96          ded-debug ded-profile ded-release \
97
98 help:
99         @echo
100         @echo "===== Choose one ====="
101         @echo "* $(MAKE) clean       : delete the binaries, and .o and .d files"
102         @echo "* $(MAKE) help        : this help"
103         @echo "* $(MAKE) debug       : make GLX and dedicated binaries (debug versions)"
104         @echo "* $(MAKE) profile     : make GLX and dedicated binaries (profile versions)"
105         @echo "* $(MAKE) release     : make GLX and dedicated binaries (release versions)"
106         @echo "* $(MAKE) glx-debug   : make GLX binary (debug version)"
107         @echo "* $(MAKE) glx-profile : make GLX binary (profile version)"
108         @echo "* $(MAKE) glx-release : make GLX binary (release version)"
109         @echo "* $(MAKE) ded-debug   : make dedicated server (debug version)"
110         @echo "* $(MAKE) ded-profile : make dedicated server (profile version)"
111         @echo "* $(MAKE) ded-release : make dedicated server (release version)"
112         @echo
113
114 debug :
115         $(MAKE) glx-debug ded-debug
116
117 profile :
118         $(MAKE) glx-profile ded-profile
119
120 release :
121         $(MAKE) glx-release ded-release
122
123 glx-debug :
124         $(MAKE) bin-debug EXE="$(EXE_GLX)"
125
126 glx-profile :
127         $(MAKE) bin-profile EXE="$(EXE_GLX)"
128
129 glx-release :
130         $(MAKE) bin-release EXE="$(EXE_GLX)"
131
132 ded-debug :
133         $(MAKE) bin-debug EXE="$(EXE_DED)"
134
135 ded-profile :
136         $(MAKE) bin-profile EXE="$(EXE_DED)"
137
138 ded-release :
139         $(MAKE) bin-release EXE="$(EXE_DED)"
140
141 bin-debug :
142         @echo
143         @echo "========== $(EXE) (debug) =========="
144         $(MAKE) builddate
145         $(MAKE) $(EXE) \
146                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
147                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
148
149 bin-profile :
150         @echo
151         @echo "========== $(EXE) (profile) =========="
152         $(MAKE) builddate
153         $(MAKE) $(EXE) \
154                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
155                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
156
157 bin-release :
158         @echo
159         @echo "========== $(EXE) (release) =========="
160         $(MAKE) builddate
161         $(MAKE) $(EXE) \
162                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
163                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
164         strip $(EXE)
165
166 builddate:
167         touch builddate.c
168
169 vid_glx.o: vid_glx.c
170         $(DO_CC) -I/usr/X11R6/include
171
172 .c.o:
173         $(DO_CC)
174
175 $(EXE_GLX):  $(OBJ_GLX)
176         $(DO_LD) $(GLX_LIB)
177
178 $(EXE_DED): $(OBJ_DED)
179         $(DO_LD)
180
181 clean:
182         rm -f $(EXE_GLX) $(EXE_DED) *.o *.d
183
184 -include *.d