-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.w64
287 lines (253 loc) · 5.9 KB
/
Makefile.w64
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# GNU Makefile for compiling Win64 quakespasm.exe using MinGW-w64.
# Usage: "make -f Makefile.w64"
# To cross-compile on Linux hosts, see the "build_cross_win32*.sh" scripts.
# "make DEBUG=1" to build a debug client.
# "make SDL_CONFIG=/path/to/sdl-config" to override the locally included SDL versions.
# "make WINSOCK2=0" to use the old WinSock 1.1 api (NOT RECOMMENDED)
### Enable/disable SDL2
USE_SDL2=0
### Enable/disable codecs for streaming music support
USE_CODEC_WAVE=1
USE_CODEC_FLAC=1
USE_CODEC_MP3=1
USE_CODEC_VORBIS=1
USE_CODEC_OPUS=1
# either mikmod (preferred) or modplug, not both
USE_CODEC_MIKMOD=1
USE_CODEC_MODPLUG=0
USE_CODEC_UMX=1
# which library to use for mp3 decoding: mad or mpg123
MP3LIB=mad
# which library to use for ogg decoding: vorbis or tremor
VORBISLIB=vorbis
# ---------------------------
# Helper functions
# ---------------------------
check_gcc = $(shell if echo | $(CC) $(1) -Werror -S -o /dev/null -xc - > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi;)
# ---------------------------
DEBUG ?= 0
WINSOCK2?= 1
# ---------------------------
# build variables
# ---------------------------
CC = gcc
LINKER = $(CC)
WINDRES = windres
STRIP = strip
CPUFLAGS=
LDFLAGS =
DFLAGS ?=
CFLAGS ?= -Wall -Wno-trigraphs
CFLAGS += $(CPUFLAGS)
ifneq ($(DEBUG),0)
DFLAGS += -DDEBUG
CFLAGS += -g
do_strip=
else
DFLAGS += -DNDEBUG
CFLAGS += -O2
CFLAGS += $(call check_gcc,-fweb,)
CFLAGS += $(call check_gcc,-frename-registers,)
cmd_strip=$(STRIP) $(1)
define do_strip
$(call cmd_strip,$(1));
endef
endif
ifeq ($(USE_SDL2),1)
CFLAGS += -DUSE_SDL2
endif
# default to our local SDL[2] for build
ifeq ($(USE_SDL2),1)
SDL_CONFIG ?=../Windows/SDL2/bin/sdl2-config --prefix=../Windows/SDL2 --lib-suffix=64
else
SDL_CONFIG ?=../Windows/SDL/bin/sdl-config --prefix=../Windows/SDL --lib-suffix=64
endif
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
SDL_LIBS := $(shell $(SDL_CONFIG) --libs)
ifeq ($(WINSOCK2),1)
DEFWINSOCK :=-D_USE_WINSOCK2
LIBWINSOCK := -lws2_32
else
DEFWINSOCK :=
LIBWINSOCK := -lwsock32
endif
CFLAGS += $(DEFWINSOCK)
NET_LIBS := $(LIBWINSOCK)
ifneq ($(VORBISLIB),vorbis)
ifneq ($(VORBISLIB),tremor)
$(error Invalid VORBISLIB setting)
endif
endif
ifneq ($(MP3LIB),mpg123)
ifneq ($(MP3LIB),mad)
$(error Invalid MP3LIB setting)
endif
endif
ifeq ($(MP3LIB),mad)
mp3_obj=snd_mp3.o
lib_mp3dec=-lmad
endif
ifeq ($(MP3LIB),mpg123)
mp3_obj=snd_mpg123.o
lib_mp3dec=-lmpg123
endif
ifeq ($(VORBISLIB),vorbis)
cpp_vorbisdec=
lib_vorbisdec=-lvorbisfile -lvorbis -logg
endif
ifeq ($(VORBISLIB),tremor)
cpp_vorbisdec=-DVORBIS_USE_TREMOR
lib_vorbisdec=-lvorbisidec -logg
endif
CODECLIBS :=
ifeq ($(USE_CODEC_WAVE),1)
CFLAGS+= -DUSE_CODEC_WAVE
endif
ifeq ($(USE_CODEC_FLAC),1)
CFLAGS+= -DUSE_CODEC_FLAC
CODEC_INC = -I../Windows/codecs/include
CODEC_LINK= -L../Windows/codecs/x64
CODECLIBS+= -lFLAC
endif
ifeq ($(USE_CODEC_OPUS),1)
CFLAGS+= -DUSE_CODEC_OPUS
CODEC_INC = -I../Windows/codecs/include
CODEC_LINK= -L../Windows/codecs/x64
CODECLIBS+= -lopusfile -lopus -logg
endif
ifeq ($(USE_CODEC_VORBIS),1)
CFLAGS+= -DUSE_CODEC_VORBIS $(cpp_vorbisdec)
CODEC_INC = -I../Windows/codecs/include
CODEC_LINK= -L../Windows/codecs/x64
CODECLIBS+= $(lib_vorbisdec)
endif
ifeq ($(USE_CODEC_MP3),1)
CFLAGS+= -DUSE_CODEC_MP3
CODEC_INC = -I../Windows/codecs/include
CODEC_LINK= -L../Windows/codecs/x64
CODECLIBS+= $(lib_mp3dec)
endif
ifeq ($(USE_CODEC_MIKMOD),1)
CFLAGS+= -DUSE_CODEC_MIKMOD
CODEC_INC = -I../Windows/codecs/include
CODEC_LINK= -L../Windows/codecs/x64
CODECLIBS+= -lmikmod
endif
ifeq ($(USE_CODEC_MODPLUG),1)
CFLAGS+= -DUSE_CODEC_MODPLUG
CODEC_INC = -I../Windows/codecs/include
CODEC_LINK= -L../Windows/codecs/x64
CODECLIBS+= -lmodplug
endif
ifeq ($(USE_CODEC_UMX),1)
CFLAGS+= -DUSE_CODEC_UMX
endif
CFLAGS+= $(CODEC_INC)
COMMON_LIBS:= -lm -lopengl32 -lwinmm
LIBS := $(COMMON_LIBS) $(NET_LIBS) $(CODEC_LINK) $(CODECLIBS)
# ---------------------------
# targets
# ---------------------------
.PHONY: clean debug release
DEFAULT_TARGET := quakespasm.exe
# ---------------------------
# rules
# ---------------------------
%.o: %.c
$(CC) $(DFLAGS) -c $(CFLAGS) $(SDL_CFLAGS) -o $@ $^
%.res: ../Windows/%.rc
$(WINDRES) --output-format=coff -I../Windows -o $@ $^
# ----------------------------------------------------------------------------
# objects
# ----------------------------------------------------------------------------
MUSIC_OBJS:= bgmusic.o \
snd_codec.o \
snd_flac.o \
snd_wave.o \
snd_vorbis.o \
snd_opus.o \
$(mp3_obj) \
snd_mikmod.o \
snd_modplug.o \
snd_umx.o
COMOBJ_SND := snd_dma.o snd_mix.o snd_mem.o $(MUSIC_OBJS)
SYSOBJ_SND := snd_sdl.o
SYSOBJ_CDA := cd_sdl.o
SYSOBJ_INPUT := in_sdl.o
SYSOBJ_GL_VID:= gl_vidsdl.o
SYSOBJ_NET := net_win.o net_wins.o net_wipx.o
SYSOBJ_SYS := pl_win.o sys_sdl_win.o
SYSOBJ_MAIN:= main_sdl.o
SYSOBJ_RES := QuakeSpasm.res
GLOBJS = \
gl_refrag.o \
gl_rlight.o \
gl_rmain.o \
gl_fog.o \
gl_rmisc.o \
r_part.o \
r_world.o \
gl_screen.o \
gl_sky.o \
gl_warp.o \
$(SYSOBJ_GL_VID) \
gl_draw.o \
image.o \
gl_texmgr.o \
gl_mesh.o \
r_sprite.o \
r_alias.o \
r_brush.o \
gl_model.o
OBJS := strlcat.o \
strlcpy.o \
$(GLOBJS) \
$(SYSOBJ_INPUT) \
$(COMOBJ_SND) \
$(SYSOBJ_SND) \
$(SYSOBJ_CDA) \
$(SYSOBJ_NET) \
net_dgrm.o \
net_loop.o \
net_main.o \
chase.o \
cl_demo.o \
cl_input.o \
cl_main.o \
cl_parse.o \
cl_tent.o \
console.o \
keys.o \
menu.o \
sbar.o \
view.o \
wad.o \
cmd.o \
common.o \
crc.o \
cvar.o \
cfgfile.o \
host.o \
host_cmd.o \
mathlib.o \
pr_cmds.o \
pr_edict.o \
pr_exec.o \
sv_main.o \
sv_move.o \
sv_phys.o \
sv_user.o \
world.o \
zone.o \
$(SYSOBJ_SYS) $(SYSOBJ_MAIN) $(SYSOBJ_RES)
# ------------------------
# MinGW-w64 build rules
# ------------------------
quakespasm.exe: $(OBJS)
$(LINKER) $(OBJS) $(LDFLAGS) $(LIBS) $(SDL_LIBS) -o $@
$(call do_strip,$@)
release: quakespasm.exe
debug:
$(error Use "make DEBUG=1")
clean:
rm -f $(shell find . \( -name '*~' -o -name '#*#' -o -name '*.o' -o -name '*.res' -o -name $(DEFAULT_TARGET) \) -print)