-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
484 lines (390 loc) · 12.1 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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# build native or web version of mupen64-plus
# to build web version: 'make web'
# to build native version: 'make native'
# to run web version: 'make run-web'
# to run native version: 'make run-native'
# to specify a rom to load, make sure it's in the ROMS_DIR and load as:
# make ROM="rom.name.n64" run-web
GAMES_DIR ?= ./games
ROM_DIR_NAME ?= roms
ROMS_DIR ?= $(abspath $(ROM_DIR_NAME))
ROM ?= m64p_test_rom.v64
DEFAULT_ROM := m64p_test_rom.v64
PLATFORM ?= web
BIN_DIR ?= $(abspath ./bin/$(PLATFORM))
SCRIPTS_DIR := ./scripts
TARGET_ROM = $(BIN_DIR)/roms/$(ROM)
SOURCE_ROM = $(ROMS_DIR)/$(ROM)
POSTFIX ?= -web
SO_EXTENSION ?= .js
UI ?= mupen64plus-ui-console
UI_DIR = $(UI)/projects/unix
CORE ?= mupen64plus-core
CORE_DIR = $(CORE)/projects/unix
CORE_LIB = $(CORE)$(POSTFIX)$(SO_EXTENSION)
AUDIO ?= mupen64plus-audio-web
AUDIO_DIR = $(AUDIO)/projects/unix/
AUDIO_LIB = $(AUDIO).js
NATIVE_AUDIO := mupen64plus-audio-sdl
NATIVE_AUDIO_DIR = $(NATIVE_AUDIO)/projects/unix
NATIVE_AUDIO_LIB = $(NATIVE_AUDIO).so
VIDEO ?= mupen64plus-video-glide64mk2
VIDEO_DIR = $(VIDEO)/projects/unix
VIDEO_LIB = $(VIDEO)$(POSTFIX)$(SO_EXTENSION)
RICE = mupen64plus-video-rice
RICE_VIDEO_LIB = $(RICE)$(POSTFIX)$(SO_EXTENSION)
RICE_VIDEO_DIR = $(RICE)/projects/unix/
INPUT ?= mupen64plus-input-sdl
INPUT_DIR = $(INPUT)/projects/unix
INPUT_LIB = $(INPUT)$(POSTFIX)$(SO_EXTENSION)
RSP ?= mupen64plus-rsp-hle
RSP_DIR = $(RSP)/projects/unix
RSP_LIB = $(RSP)$(POSTFIX)$(SO_EXTENSION)
TARGET ?= mupen64plus
PLUGINS_DIR = $(BIN_DIR)/plugins
OUTPUT_ROMS_DIR = $(BIN_DIR)/$(ROMS_DIR)
TARGET_LIB = $(TARGET)$(POSTFIX)$(SO_EXTENSION)
TARGET_HTML ?= index.html
INDEX_TEMPLATE = $(abspath $(SCRIPTS_DIR)/index.template.html)
MODULE_JS = module.js
BOOST_DIR := ./boost_1_59_0
BOOST_LIB_DIR = $(abspath $(BOOST_DIR)/stage/lib)
BOOST_FILESYSTEM_LIB = $(BOOST_LIB_DIR)/libboost_filesystem.a
PLUGINS = $(PLUGINS_DIR)/$(CORE_LIB) \
$(PLUGINS_DIR)/$(AUDIO_LIB) \
$(PLUGINS_DIR)/$(VIDEO_LIB) \
$(PLUGINS_DIR)/$(INPUT_LIB) \
$(PLUGINS_DIR)/$(RSP_LIB) \
$(PLUGINS_DIR)/$(RICE_VIDEO_LIB)
INPUT_FILES = \
$(BIN_DIR)/data/InputAutoCfg.ini \
$(BIN_DIR)/data/Glide64mk2.ini \
$(BIN_DIR)/data/RiceVideoLinux.ini \
$(BIN_DIR)/stats.min.js \
$(BIN_DIR)/data/mupencheat.txt \
$(INDEX_TEMPLATE) \
$(BIN_DIR)/$(MODULE_JS) \
$(BIN_DIR)/data/mupen64plus.cfg \
$(BIN_DIR)/data/mupen64plus.ini \
OPT_LEVEL ?= -O3
DEBUG_LEVEL ?=
#MEMORY = 524288
MEMORY = 402653184
#MEMORY = 268435456
#MEMORY = 134217728
NATIVE_BIN := bin
NATIVE_PLUGINS := \
$(NATIVE_BIN)/libmupen64plus.so.2 \
$(NATIVE_BIN)/mupen64plus-input-sdl.so \
$(NATIVE_BIN)/mupen64plus-rsp-hle.so \
$(NATIVE_BIN)/mupen64plus-video-glide64mk2.so \
$(NATIVE_BIN)/mupen64plus-video-rice.so \
$(NATIVE_BIN)/mupen64plus-audio-sdl.so \
NATIVE_EXE := $(NATIVE_BIN)/mupen64plus
NATIVE_DEPS := $(NATIVE_PLUGINS) $(NATIVE_EXE)
WEB_DEPS := $(BIN_DIR)/$(TARGET_HTML) $(TARGET_ROM)
ALL_DEPS := $(WEB_DEPS)
ifeq ($(PLATFORM), native)
ALL_DEPS := $(NATIVE_DEPS)
endif
all: $(ALL_DEPS)
.FORCE:
native: .FORCE
$(MAKE) PLATFORM=native
web: .FORCE
$(MAKE) PLATFORM=web
RICE_CFG_DIR := cfg/rice
GLIDE_CFG_DIR := cfg/glide
DATA_DIR := mupen64plus-core/data
CFG_DIR := $(GLIDE_CFG_DIR)
ifdef rice
CFG_DIR := $(RICE_CFG_DIR)
endif
NATIVE_ARGS ?=
run-native: native
./$(NATIVE_EXE) $(ROM) \
$(NATIVE_ARGS) \
--corelib $(NATIVE_BIN)/libmupen64plus.so.2 \
--configdir $(CFG_DIR) \
--datadir $(CFG_DIR) \
$(ROMS_DIR)/$(ROM)
# use browser=chromium arg (or chrome etc) to test in broser
# e.g. 'make run-web browser=chromium'
BROWSER ?= firefox
ifeq ($(browser), chromium)
BROWSER := $(shell which chromium-browser)
endif
EMRUN ?= --emrun
FORWARDSLASH ?= %2F
run-web: web
emrun $ --browser $(BROWSER) $(BIN_DIR)/index.html --nospeedlimit $(FORWARDSLASH)$(ROM_DIR_NAME)$(FORWARDSLASH)$(ROM)
run: run-web
clean-native:
cd mupen64plus-ui-console/projects/unix && $(MAKE) clean
cd $(CORE_DIR) && $(MAKE) clean
cd $(INPUT_DIR) && $(MAKE) clean
cd $(RSP_DIR) && $(MAKE) clean
cd $(VIDEO_DIR) && $(MAKE) clean
cd $(RICE_VIDEO_DIR) && $(MAKE) clean
cd $(AUDIO_DIR) && $(MAKE) clean
clean: clean-web clean-native
rebuild: clean all
$(NATIVE_BIN):
mkdir $(NATIVE_BIN)
$(NATIVE_EXE): $(NATIVE_BIN) mupen64plus-ui-console/projects/unix/mupen64plus
cp mupen64plus-ui-console/projects/unix/mupen64plus $@
mupen64plus-ui-console/projects/unix/mupen64plus:
cd mupen64plus-ui-console/projects/unix && $(MAKE) all
$(NATIVE_BIN)/libmupen64plus.so.2: $(NATIVE_BIN) $(CORE_DIR)/libmupen64plus.so.2.0.0
cp $(CORE_DIR)/libmupen64plus.so.2.0.0 $@
$(CORE_DIR)/libmupen64plus.so.2.0.0:
cd $(CORE_DIR) && $(MAKE) all
$(NATIVE_BIN)/mupen64plus-input-sdl.so: $(NATIVE_BIN) $(INPUT_DIR)/mupen64plus-input-sdl.so
cp $(INPUT_DIR)/mupen64plus-input-sdl.so $@
$(INPUT_DIR)/mupen64plus-input-sdl.so:
cd $(INPUT_DIR) && $(MAKE) all
$(RSP_DIR)/mupen64plus-rsp-hle.so:
cd $(RSP_DIR) && $(MAKE) all
$(NATIVE_BIN)/mupen64plus-rsp-hle.so: $(NATIVE_BIN) $(RSP_DIR)/mupen64plus-rsp-hle.so
cp $(RSP_DIR)/mupen64plus-rsp-hle.so $@
$(VIDEO_DIR)/mupen64plus-video-glide64mk2.so:
cd $(VIDEO_DIR) && $(MAKE) all
$(NATIVE_BIN)/mupen64plus-video-glide64mk2.so: $(NATIVE_BIN) $(VIDEO_DIR)/mupen64plus-video-glide64mk2.so
cp $(VIDEO_DIR)/mupen64plus-video-glide64mk2.so $@
$(RICE_VIDEO_DIR)/mupen64plus-video-rice.so:
cd $(RICE_VIDEO_DIR) && $(MAKE) all
$(NATIVE_BIN)/mupen64plus-video-rice.so: $(NATIVE_BIN) $(RICE_VIDEO_DIR)/mupen64plus-video-rice.so
cp $(RICE_VIDEO_DIR)/mupen64plus-video-rice.so $@
$(NATIVE_AUDIO_DIR)/mupen64plus-audio-sdl.so:
cd $(NATIVE_AUDIO_DIR) && $(MAKE) all
$(NATIVE_BIN)/mupen64plus-audio-sdl.so: $(NATIVE_BIN) $(NATIVE_AUDIO_DIR)/mupen64plus-audio-sdl.so
cp $(NATIVE_AUDIO_DIR)/mupen64plus-audio-sdl.so $@
ifeq ($(config), debug)
OPT_LEVEL = -O0
DEBUG_LEVEL = -g2 -s ASSERTIONS=1
else
OPT_LEVEL = -O3 -s AGGRESSIVE_VARIABLE_ELIMINATION=1
endif
OPT_FLAGS := $(OPT_LEVEL) \
$(DEBUG_LEVEL) \
-s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"ccall\", \"cwrap\", \"getValue\"]' \
-DEMSCRIPTEN=1 \
-DUSE_FRAMESKIPPER=1
#$(PLUGINS_DIR)/%.js : %/projects/unix/%.js
# cp "$<" "$@"
# libmupen64plus.so.2 deviates from standard naming
$(PLUGINS_DIR)/$(CORE_LIB) : $(CORE_DIR)/$(CORE_LIB)
mkdir -p $(PLUGINS_DIR)
cp "$<" "$@"
$(PLUGINS_DIR)/$(AUDIO_LIB) : $(AUDIO_DIR)/$(AUDIO_LIB)
mkdir -p $(PLUGINS_DIR)
cp "$<" "$@"
$(PLUGINS_DIR)/$(VIDEO_LIB) : $(VIDEO_DIR)/$(VIDEO_LIB)
mkdir -p $(PLUGINS_DIR)
cp "$<" "$@"
$(PLUGINS_DIR)/$(RICE_VIDEO_LIB) : $(RICE_VIDEO_DIR)/$(RICE_VIDEO_LIB)
mkdir -p $(PLUGINS_DIR)
cp -f "$<" "$@"
$(PLUGINS_DIR)/$(INPUT_LIB) : $(INPUT_DIR)/$(INPUT_LIB)
mkdir -p $(PLUGINS_DIR)
cp "$<" "$@"
$(PLUGINS_DIR)/$(RSP_LIB) : $(RSP_DIR)/$(RSP_LIB)
mkdir -p $(PLUGINS_DIR)
cp "$<" "$@"
$(TARGET_ROM): $(SOURCE_ROM)
mkdir -p $(@D)
rm -f $(OUTPUT_ROMS_DIR)/*
cp "$<" "$@"
$(BIN_DIR) :
#Creating output directory
mkdir -p $(BIN_DIR)
$(BOOST_FILESYSTEM_LIB):
cd $(BOOST_DIR) && ./bootstrap.sh && ./b2 --test-config=user-config.jam toolset=emscripten link=static --with-filesystem
rice: $(RICE_VIDEO_DIR)/$(RICE_VIDEO_LIB)
$(RICE_VIDEO_DIR)/$(RICE_VIDEO_LIB):
cd $(RICE_VIDEO_DIR) && \
emmake $(MAKE) \
CROSS_COMPILE="" \
POSTFIX=-web\
UNAME=Linux \
USE_FRAMESKIPPER=1 \
EMSCRIPTEN=1 \
SO_EXTENSION="js" \
USE_GLES=1 NO_ASM=1 \
ZLIB_CFLAGS="-s USE_ZLIB=1" \
PKG_CONFIG="" \
LIBPNG_CFLAGS="-s USE_LIBPNG=1" \
SDL_CFLAGS="-s USE_SDL=2" \
FREETYPE2_CFLAGS="-s USE_FREETYPE=1" \
GL_CFLAGS="" \
GLU_CFLAGS="" \
V=1 \
LOADLIBES="../../../boost_1_59_0/stage/lib/libboost_filesystem.a ../../../boost_1_59_0/stage/lib/libboost_system.a" \
OPTFLAGS="$(OPT_FLAGS) -s FULL_ES2=1 -DNO_FILTER_THREAD=1 -s SIDE_MODULE=1 -I../../../boost_1_59_0" \
all
# input files helpers
$(BIN_DIR)/data/InputAutoCfg.ini: $(CFG_DIR)/InputAutoCfg.ini
mkdir -p $(@D)
cp $< $@
$(BIN_DIR)/data/Glide64mk2.ini: $(GLIDE_CFG_DIR)/Glide64mk2.ini
mkdir -p $(@D)
cp $< $@
$(BIN_DIR)/data/RiceVideoLinux.ini: $(RICE_CFG_DIR)/RiceVideoLinux.ini
mkdir -p $(@D)
cp $< $@
$(BIN_DIR)/$(MODULE_JS): $(SCRIPTS_DIR)/$(MODULE_JS)
mkdir -p $(@D)
cp $< $@
$(BIN_DIR)/stats.min.js: $(SCRIPTS_DIR)/stats.min.js
cp $< $@
$(BIN_DIR)/data/mupen64plus.cfg: $(CFG_DIR)/mupen64plus-web.cfg
cp $< $@
$(BIN_DIR)/data/mupen64plus.ini: $(CFG_DIR)/mupen64plus.ini
cp $< $@
$(BIN_DIR)/data/mupencheat.txt: $(CFG_DIR)/mupencheat.txt
cp $< $@
$(BIN_DIR)/$(TARGET_HTML): $(INDEX_TEMPLATE) $(PLUGINS) $(INPUT_FILES)
@mkdir -p $(BIN_DIR)
rm -f $@
# building UI (program entry point)
cd $(UI_DIR) && \
EMCC_FORCE_STDLIBS=1 emmake make \
POSTFIX=-web \
TARGET=$(BIN_DIR)/$(TARGET_HTML) \
UNAME=Linux \
EMSCRIPTEN=1 \
EXEEXT=".html" \
USE_GLES=1 NO_ASM=1 \
ZLIB_CFLAGS="-s USE_ZLIB=1" \
PKG_CONFIG="" \
LIBPNG_CFLAGS="-s USE_LIBPNG=1" \
SDL_CFLAGS="-s USE_SDL=2" \
FREETYPE2_CFLAGS="-s USE_FREETYPE=1" \
GL_CFLAGS="" \
GLU_CFLAGS="" \
V=1 \
OPTFLAGS="$(OPT_FLAGS) -s MAIN_MODULE=1 \
--preload-file $(BIN_DIR)/plugins@plugins \
--preload-file $(BIN_DIR)/data@data \
--shell-file $(INDEX_TEMPLATE) \
-s TOTAL_MEMORY=$(MEMORY) \
-s USE_ZLIB=1 \
-s USE_SDL=2 \
-s USE_LIBPNG=1 \
-s FULL_ES2=1 \
-DEMSCRIPTEN=1 -DINPUT_ROM=$(DEFAULT_ROM) $(EMRUN)" \
all
core: $(CORE_DIR)/$(CORE_LIB)
$(CORE_DIR)/$(CORE_LIB) :
cd $(CORE_DIR) && \
emmake make \
POSTFIX=-web \
UNAME=Linux \
EMSCRIPTEN=1 \
TARGET="$(CORE_LIB)" \
SONAME="" \
USE_GLES=1 NO_ASM=1 \
ZLIB_CFLAGS="-s USE_ZLIB=1" \
PKG_CONFIG="" \
LIBPNG_CFLAGS="-s USE_LIBPNG=1" \
SDL_CFLAGS="-s USE_SDL=2" \
FREETYPE2_CFLAGS="-s USE_FREETYPE=1" \
GL_CFLAGS="" \
GLU_CFLAGS="" \
V=1 \
OPTFLAGS="$(OPT_FLAGS) -s SIDE_MODULE=1 -DONSCREEN_FPS=1" \
all
audio: $(AUDIO_DIR)/$(AUDIO_LIB)
$(AUDIO_DIR)/$(AUDIO_LIB) :
cd $(AUDIO_DIR) && \
emmake make \
POSTFIX=-web \
UNAME="Linux" \
EMSCRIPTEN=1 \
NO_SRC=1 \
NO_SPEEX=1 \
NO_OSS=1 \
SO_EXTENSION="js" \
USE_GLES=1 NO_ASM=1 \
ZLIB_CFLAGS="-s USE_ZLIB=1" \
PKG_CONFIG="" \
LIBPNG_CFLAGS="-s USE_LIBPNG=1" \
SDL_CFLAGS="-s USE_SDL=2" \
FREETYPE2_CFLAGS="-s USE_FREETYPE=1" \
GL_CFLAGS="" \
GLU_CFLAGS="" \
V=1 \
OPTFLAGS="$(OPT_FLAGS) -s SIDE_MODULE=1 -DNO_FILTER_THREAD=1"\
all
glide: $(VIDEO_DIR)/$(VIDEO_LIB)
$(VIDEO_DIR)/$(VIDEO_LIB) : $(BOOST_FILESYSTEM_LIB)
cd $(VIDEO_DIR) && \
emmake make \
POSTFIX=-web \
USE_FRAMESKIPPER=1 \
EMSCRIPTEN=1 \
SO_EXTENSION="js" \
USE_GLES=1 NO_ASM=1 \
ZLIB_CFLAGS="-s USE_ZLIB=1" \
PKG_CONFIG="" \
LIBPNG_CFLAGS="-s USE_LIBPNG=1" \
SDL_CFLAGS="-s USE_SDL=2" \
FREETYPE2_CFLAGS="-s USE_FREETYPE=1" \
GL_CFLAGS="" \
GLU_CFLAGS="" \
V=1 \
LOADLIBES="../../../boost_1_59_0/stage/lib/libboost_filesystem.a ../../../boost_1_59_0/stage/lib/libboost_system.a" \
OPTFLAGS="$(OPT_FLAGS) -s SIDE_MODULE=1 -I../../../boost_1_59_0 \ -s FULL_ES2=1 -DNO_FILTER_THREAD=1" \
all
input: $(INPUT_DIR)/$(INPUT_LIB)
$(INPUT_DIR)/$(INPUT_LIB) : $(BOOST_FILESYSTEM_LIB)
cd $(INPUT_DIR) && \
emmake make \
POSTFIX=-web \
UNAME="Linux" \
EMSCRIPTEN=1 \
SO_EXTENSION="js" \
USE_GLES=1 NO_ASM=1 \
ZLIB_CFLAGS="-s USE_ZLIB=1" \
PKG_CONFIG="" \
LIBPNG_CFLAGS="-s USE_LIBPNG=1" \
SDL_CFLAGS="-s USE_SDL=2" \
FREETYPE2_CFLAGS="-s USE_FREETYPE=1" \
GL_CFLAGS="" \
GLU_CFLAGS="" \
V=1 \
OPTFLAGS="$(OPT_FLAGS) -s SIDE_MODULE=1 -I../../../boost_1_59_0 "\
all
rsp: $(RSP_DIR)/$(RSP_LIB)
$(RSP_DIR)/$(RSP_LIB) :
cd $(RSP_DIR)&& \
emmake make \
POSTFIX=-web \
UNAME=Linux \
EMSCRIPTEN=1 \
SO_EXTENSION="js" \
USE_GLES=1 NO_ASM=1 NO_OSS=1 NO_SRC=1 NO_SPEEX=1\
ZLIB_CFLAGS="-s USE_ZLIB=1" \
PKG_CONFIG="" \
LIBPNG_CFLAGS="-s USE_LIBPNG=1" \
SDL_CFLAGS="-s USE_SDL=2" \
FREETYPE2_CFLAGS="-s USE_FREETYPE=1" \
GL_CFLAGS="" \
GLU_CFLAGS="" \
V=1 \
OPTFLAGS="$(OPT_FLAGS) -s SIDE_MODULE=1 -DVIDEO_HLE_ALLOWED=1" \
all
clean-web:
rm -fr $(BIN_DIR)
rm -f $(CORE_DIR)/$(CORE_LIB)
rm -fr $(CORE_DIR)/_obj$(POSTFIX)
rm -f $(AUDIO_DIR)/$(AUDIO_LIB)
rm -fr $(AUDIO_DIR)/_obj$(POSTFIX)
rm -f $(VIDEO_DIR)/$(VIDEO_LIB)
rm -fr $(VIDEO_DIR)/_obj$(POSTFIX)
rm -f $(INPUT_DIR)/$(INPUT_LIB)
rm -fr $(INPUT_DIR)/_obj$(POSTFIX)
rm -f $(RSP_DIR)/$(RSP_LIB)
rm -fr $(RSP_DIR)/_obj$(POSTFIX)
rm -f $(RICE_VIDEO_DIR)/$(RICE_VIDEO_LIB)
rm -fr $(RICE_VIDEO_DIR)/_obj$(POSTFIX)