-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
284 lines (219 loc) · 6.3 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
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
PORT ?= ORIGINAL
COMMON_SRC = \
src/wipeout/race.c \
src/wipeout/camera.c \
src/wipeout/object.c \
src/wipeout/droid.c \
src/wipeout/ui.c \
src/wipeout/hud.c \
src/wipeout/image.c \
src/wipeout/game.c \
src/wipeout/menu.c \
src/wipeout/main_menu.c \
src/wipeout/ingame_menus.c \
src/wipeout/title.c \
src/wipeout/scene.c \
src/wipeout/ship.c \
src/wipeout/ship_ai.c \
src/wipeout/ship_player.c \
src/wipeout/track.c \
src/wipeout/weapon.c \
src/wipeout/particle.c \
src/types.c \
src/system.c \
src/input.c
SFX_SRC= src/wipeout/sfx.c
ifeq ($(PORT), Saturn)
# DEBUG=ON PORT=Saturn make -j16 -C ..
DEBUG?=OFF
NO_SFX?=OFF
DEDICATED_SRC = \
src/saturn/math.c \
src/saturn/mem.c \
src/saturn/platform_yaul.c \
src/saturn/render_saturn.c \
src/saturn/render_vdp1.c \
src/saturn/render_vdp2.c \
src/saturn/utils.c \
src/saturn/tex.c \
src/saturn/fix16_mat44.c \
src/saturn/vdp1_tex.c
ifeq ($(strip $(YAUL_INSTALL_ROOT)),)
$(error Undefined YAUL_INSTALL_ROOT (install root directory))
endif
SH_SPECS:= yaul.specs yaul-main.specs src/saturn/wipeout.specs
include $(YAUL_INSTALL_ROOT)/share/build.pre.mk
ifeq ($(DEBUG), ON)
NO_SFX=ON
PORT_MSG?=ON
USER_CFLAGS += -DDEBUG_PRINT
ifeq ($(PORT_MSG), ON)
USER_CFLAGS += -DLOGD="printf"
endif
else
PORT_MSG?=OFF
ifeq ($(PORT_MSG), ON)
USER_CFLAGS += -DDEBUG_PRINT
endif
endif
SH_LIBRARIES:=
SH_CFLAGS+= -O3 \
-I. \
-I/usr/include/stb \
-Isrc/libs/ \
-Isrc/ \
-Isrc/saturn \
-std=gnu99 \
-Wall \
-Wno-unused-variable \
-DSATURN \
-DNO_QUIT \
-DNO_ATTRACT_MODE \
-DMEM_HUNK_BYTES=0x200000 \
$(USER_CFLAGS)
IP_VERSION:= V1.000
IP_RELEASE_DATE:= 20230923
IP_AREAS:= JTUBKAEL
IP_PERIPHERALS:= JAMKST
IP_TITLE:= Wipeout Reborn
IP_MASTER_STACK_ADDR:= 0x06004000
IP_SLAVE_STACK_ADDR:= 0x06001E00
IP_1ST_READ_ADDR:= 0x06004000
IP_1ST_READ_SIZE:= 0
SH_PROGRAM:= wipeout-reborn
SH_SRCS:= \
$(COMMON_SRC) \
$(DEDICATED_SRC)
ifeq ($(NO_SFX), OFF)
SH_SRCS += $(SFX_SRC)
else
SH_SRCS += src/saturn/no_sfx.c
endif
include $(YAUL_INSTALL_ROOT)/share/build.post.iso-cue.mk
else
CC ?= cc
EMCC ?= emcc
UNAME_S := $(shell uname -s)
RENDERER ?= GL
USE_GLX ?= false
DEBUG ?= false
USER_CFLAGS ?=
L_FLAGS ?= -lm
C_FLAGS ?= -Isrc/libs/ -std=gnu99 -Wall -Wno-unused-variable $(USER_CFLAGS)
ifeq ($(DEBUG), true)
C_FLAGS := $(C_FLAGS) -g
else
C_FLAGS := $(C_FLAGS) -O3
endif
# Rendeder ---------------------------------------------------------------------
ifeq ($(RENDERER), GL)
RENDERER_SRC = src/render_gl.c
C_FLAGS := $(C_FLAGS) -DRENDERER_GL
else ifeq ($(RENDERER), SOFTWARE)
RENDERER_SRC = src/render_software.c
C_FLAGS := $(C_FLAGS) -DRENDERER_SOFTWARE
else
$(error Unknown RENDERER)
endif
ifeq ($(GL_VERSION), GLES2)
C_FLAGS := $(C_FLAGS) -DUSE_GLES2
endif
# macOS ------------------------------------------------------------------------
ifeq ($(UNAME_S), Darwin)
BREW_HOME := $(shell brew --prefix)
C_FLAGS := $(C_FLAGS) -x objective-c -I/opt/homebrew/include -D_THREAD_SAFE -w
L_FLAGS := $(L_FLAGS) -L$(BREW_HOME)/lib -framework Foundation
ifeq ($(RENDERER), GL)
L_FLAGS := $(L_FLAGS) -lGLEW -GLU -framework OpenGL
endif
L_FLAGS_SDL = -lSDL2
L_FLAGS_SOKOL = -framework Cocoa -framework QuartzCore -framework AudioToolbox
# Linux ------------------------------------------------------------------------
else ifeq ($(UNAME_S), Linux)
ifeq ($(RENDERER), GL)
L_FLAGS := $(L_FLAGS) -lGLEW
# Prefer modern GLVND instead of legacy X11-only GLX
ifeq ($(USE_GLX), true)
L_FLAGS := $(L_FLAGS) -lGL
else
L_FLAGS := $(L_FLAGS) -lOpenGL
endif
endif
L_FLAGS_SDL = -lSDL2
L_FLAGS_SOKOL = -lX11 -lXcursor -pthread -lXi -ldl -lasound
# Windows MSYS ------------------------------------------------------------------
else ifeq ($(shell uname -o), Msys)
ifeq ($(RENDERER), GL)
L_FLAGS := $(L_FLAGS) -lglew32 -lopengl32
endif
C_FLAGS := $(C_FLAGS) -DSDL_MAIN_HANDLED -D__MSYS__
L_FLAGS_SDL = -lSDL2 -lSDL2main
L_FLAGS_SOKOL = --pthread -ldl -lasound
# Windows NON-MSYS ---------------------------------------------------------------
else ifeq ($(OS), Windows_NT)
$(error TODO: FLAGS for windows have not been set up. Please modify this makefile and send a PR!)
else
$(error Unknown environment)
endif
# Source files -----------------------------------------------------------------
TARGET_NATIVE ?= wipegame
BUILD_DIR = build/obj/native
BUILD_DIR_WASM = build/obj/wasm
WASM_RELEASE_DIR ?= build/wasm
TARGET_WASM ?= $(WASM_RELEASE_DIR)/wipeout.js
TARGET_WASM_MINIMAL ?= $(WASM_RELEASE_DIR)/wipeout-minimal.js
DEDICATED_SRC = \
src/mem.c \
src/utils.c \
src/wipeout/intro.c
PORT_SRC= \
$(COMMON_SRC) \
$(DEDICATED_SRC) \
$(RENDERER_SRC) \
$(SFX_SRC)
# Targets native ---------------------------------------------------------------
COMMON_OBJ = $(patsubst %.c, $(BUILD_DIR)/%.o, $(PORT_SRC))
COMMON_DEPS = $(patsubst %.c, $(BUILD_DIR)/%.d, $(PORT_SRC))
sdl: $(BUILD_DIR)/src/platform_sdl.o
sdl: $(COMMON_OBJ)
$(CC) $^ -o $(TARGET_NATIVE) $(L_FLAGS) $(L_FLAGS_SDL)
sokol: $(BUILD_DIR)/src/platform_sokol.o
sokol: $(COMMON_OBJ)
$(CC) $^ -o $(TARGET_NATIVE) $(L_FLAGS) $(L_FLAGS_SOKOL)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%.o: %.c
mkdir -p $(dir $@)
$(CC) $(C_FLAGS) -MMD -MP -c $< -o $@
-include $(COMMON_DEPS)
# Targets wasm -----------------------------------------------------------------
COMMON_OBJ_WASM = $(patsubst %.c, $(BUILD_DIR_WASM)/%.o, $(PORT_SRC))
COMMON_DEPS_WASM = $(patsubst %.c, $(BUILD_DIR_WASM)/%.d, $(PORT_SRC))
wasm: wasm_full wasm_minimal
cp src/wasm-index.html $(WASM_RELEASE_DIR)/game.html
wasm_full: $(BUILD_DIR_WASM)/src/platform_sokol.o
wasm_full: $(COMMON_OBJ_WASM)
mkdir -p $(WASM_RELEASE_DIR)
$(EMCC) $^ -o $(TARGET_WASM) -lGLEW -lGL \
-s ALLOW_MEMORY_GROWTH=1 \
-s ENVIRONMENT=web \
--preload-file wipeout
wasm_minimal: $(BUILD_DIR_WASM)/src/platform_sokol.o
wasm_minimal: $(COMMON_OBJ_WASM)
mkdir -p $(WASM_RELEASE_DIR)
$(EMCC) $^ -o $(TARGET_WASM_MINIMAL) -lGLEW -lGL \
-s ALLOW_MEMORY_GROWTH=1 \
-s ENVIRONMENT=web \
--preload-file wipeout \
--exclude-file wipeout/music \
--exclude-file wipeout/intro.mpeg
$(BUILD_DIR_WASM):
mkdir -p $(BUILD_DIR_WASM)
$(BUILD_DIR_WASM)/%.o: %.c
mkdir -p $(dir $@)
$(EMCC) $(C_FLAGS) -MMD -MP -c $< -o $@
-include $(COMMON_DEPS_WASM)
.PHONY: clean
clean:
$(RM) -rf $(BUILD_DIR) $(BUILD_DIR_WASM) $(WASM_RELEASE_DIR)
endif