-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
227 lines (206 loc) · 4.76 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#
# Quake2 Makefile for Linux, BSD and OS X.
#
# Check OS type.
PLATFORM=$(shell uname -s|tr A-Z a-z)
# Installation directory
DESTDIR=$(HOME)/.quake2
ifneq ($(PLATFORM),linux)
ifneq ($(PLATFORM),freebsd)
ifneq ($(PLATFORM),darwin)
$(error OS $(PLATFORM) is not supported)
endif
endif
endif
CC=gcc
CFLAGS=-funsigned-char -pipe $(shell sdl2-config --cflags) -DGL_QUAKE -DUSE_SDL -DUSE_CURL
ifeq ($(PLATFORM),darwin)
CFLAGS += -D__APPLE__ -I/opt/local/include
endif
DEBUG_CFLAGS=$(CFLAGS) -g -Wall
RELEASE_CFLAGS=$(CFLAGS) -g -O2 -Wall -DNDEBUG
ifeq ($(PLATFORM),freebsd)
LDFLAGS=-lm
else
LDFLAGS=-lm -ldl
endif
LDFLAGS += $(shell sdl2-config --libs)
LDFLAGS += $(shell curl-config --libs)
LDFLAGS += -ljpeg -lpng -lz
all: debug
bin:
mkdir -p bin
# Debug target.
debug: bin
$(MAKE) targets CFLAGS="$(DEBUG_CFLAGS)"
# Release target.
release: bin
$(MAKE) targets CFLAGS="$(RELEASE_CFLAGS)"
# Engine and game module targets.
targets: bin/quake2 bin/game.so
# Game module compilation target.
src/game/%.o : src/game/%.c
@mkdir -p $(shell dirname $@)
@echo " [CC] $(shell basename $@)"
@$(CC) $(CFLAGS) -fPIC -o $@ -c $<
# Executable compilation target.
src/%.o : src/%.c
@mkdir -p $(shell dirname $@)
@echo " [CC] $(shell basename $@)"
@$(CC) $(CFLAGS) -o $@ -c $<
QUAKE2_OBJS = \
src/client/cl_cin.o \
src/client/cl_demo.o \
src/client/cl_draw.o \
src/client/cl_ents.o \
src/client/cl_fx.o \
src/client/cl_http.o \
src/client/cl_input.o \
src/client/cl_inv.o \
src/client/cl_loc.o \
src/client/cl_main.o \
src/client/cl_newfx.o \
src/client/cl_parse.o \
src/client/cl_pred.o \
src/client/cl_scrn.o \
src/client/cl_tent.o \
src/client/cl_view.o \
src/client/console.o \
src/client/keys.o \
src/client/snd_dma.o \
src/client/snd_mem.o \
src/client/snd_mix.o \
\
src/game/m_flash.o \
src/game/q_shared.o \
\
src/include/minizip/ioapi.o \
src/include/minizip/unzip.o \
\
src/linux/cd_linux.o \
src/linux/glob.o \
src/linux/qgl_linux.o \
src/linux/q_shlinux.o \
src/linux/rw_linux.o \
src/linux/rw_sdl.o \
src/linux/snd_sdl.o \
src/linux/sys_linux.o \
src/linux/vid_so.o \
\
src/qcommon/cmd.o \
src/qcommon/cmodel.o \
src/qcommon/common.o \
src/qcommon/crc.o \
src/qcommon/cvar.o \
src/qcommon/files.o \
src/qcommon/md4.o \
src/qcommon/net_chan.o \
src/qcommon/net.o \
src/qcommon/pmove.o \
src/qcommon/q_msg.o \
\
src/ref_gl/gl_decal.o \
src/ref_gl/gl_draw.o \
src/ref_gl/gl_image.o \
src/ref_gl/gl_light.o \
src/ref_gl/gl_mesh.o \
src/ref_gl/gl_model.o \
src/ref_gl/gl_rmain.o \
src/ref_gl/gl_rmisc.o \
src/ref_gl/gl_rsurf.o \
src/ref_gl/gl_warp.o \
\
src/server/sv_ccmds.o \
src/server/sv_ents.o \
src/server/sv_game.o \
src/server/sv_init.o \
src/server/sv_main.o \
src/server/sv_send.o \
src/server/sv_user.o \
src/server/sv_world.o \
\
src/ui/qmenu.o \
src/ui/ui_addressbook.o \
src/ui/ui_atoms.o \
src/ui/ui_controls.o \
src/ui/ui_credits.o \
src/ui/ui_demos.o \
src/ui/ui_dmoptions.o \
src/ui/ui_download.o \
src/ui/ui_game.o \
src/ui/ui_joinserver.o \
src/ui/ui_keys.o \
src/ui/ui_loadsavegame.o \
src/ui/ui_main.o \
src/ui/ui_multiplayer.o \
src/ui/ui_newoptions.o \
src/ui/ui_playerconfig.o \
src/ui/ui_quit.o \
src/ui/ui_startserver.o \
src/ui/ui_video.o
# The game executable.
bin/quake2 : $(QUAKE2_OBJS)
@echo "[LD] quake2"
@$(CC) -o $@ $(QUAKE2_OBJS) $(LDFLAGS)
GAME_OBJS = \
src/game/g_ai.o \
src/game/g_chase.o \
src/game/g_cmds.o \
src/game/g_combat.o \
src/game/g_func.o \
src/game/g_items.o \
src/game/g_main.o \
src/game/g_misc.o \
src/game/g_monster.o \
src/game/g_phys.o \
src/game/g_save.o \
src/game/g_spawn.o \
src/game/g_svcmds.o \
src/game/g_target.o \
src/game/g_trigger.o \
src/game/g_turret.o \
src/game/g_utils.o \
src/game/g_weapon.o \
src/game/m_actor.o \
src/game/m_berserk.o \
src/game/m_boss2.o \
src/game/m_boss31.o \
src/game/m_boss32.o \
src/game/m_boss3.o \
src/game/m_brain.o \
src/game/m_chick.o \
src/game/m_flash.o \
src/game/m_flipper.o \
src/game/m_float.o \
src/game/m_flyer.o \
src/game/m_gladiator.o \
src/game/m_gunner.o \
src/game/m_hover.o \
src/game/m_infantry.o \
src/game/m_insane.o \
src/game/m_medic.o \
src/game/m_move.o \
src/game/m_mutant.o \
src/game/m_parasite.o \
src/game/m_soldier.o \
src/game/m_supertank.o \
src/game/m_tank.o \
src/game/p_client.o \
src/game/p_hud.o \
src/game/p_trail.o \
src/game/p_view.o \
src/game/p_weapon.o \
src/game/q_shared.o
# The game shared library.
bin/game.so : $(GAME_OBJS)
@echo "[LD] game.so"
@$(CC) $(CFLAGS) -shared -o $@ $(GAME_OBJS)
# The install target
install: targets
install -d "$(DESTDIR)/baseq2"
install bin/quake2 "$(DESTDIR)"
install bin/game.so "$(DESTDIR)/baseq2"
install data/install-data.py "$(DESTDIR)"
# The clean target.
clean:
@rm -rf $(QUAKE2_OBJS) $(GAME_OBJS) bin/*