2022-08-05 21:51:34 +00:00
|
|
|
HAVE_STATIC_DUMMY ?= 0
|
2021-01-06 13:04:38 +00:00
|
|
|
ifeq ($(TARGET),)
|
|
|
|
ifeq ($(LIBRETRO),)
|
2016-08-29 00:14:42 +00:00
|
|
|
TARGET := retroarch.js
|
2023-11-02 20:25:50 +00:00
|
|
|
LIBRETRO = dummy
|
2021-01-06 13:04:38 +00:00
|
|
|
else
|
|
|
|
TARGET := $(LIBRETRO)_libretro.js
|
|
|
|
endif
|
|
|
|
endif
|
2013-07-18 00:26:01 +00:00
|
|
|
|
2018-01-19 04:57:00 +00:00
|
|
|
EOPT = USE_ZLIB=1 # Emscripten specific options
|
2016-08-29 05:23:58 +00:00
|
|
|
EOPTS = $(addprefix -s $(EMPTY), $(EOPT)) # Add '-s ' to each option
|
|
|
|
|
2014-09-14 01:38:36 +00:00
|
|
|
OS = Emscripten
|
2014-09-13 22:04:42 +00:00
|
|
|
OBJ :=
|
2023-02-27 18:56:12 +00:00
|
|
|
DEFINES := -DRARCH_INTERNAL -DHAVE_MAIN
|
2019-08-07 01:51:18 +00:00
|
|
|
DEFINES += -DHAVE_FILTERS_BUILTIN
|
2023-01-07 04:15:36 +00:00
|
|
|
HAVE_PATCH = 1
|
2020-07-02 00:13:04 +00:00
|
|
|
HAVE_DSP_FILTER = 1
|
2020-07-02 04:28:14 +00:00
|
|
|
HAVE_VIDEO_FILTER = 1
|
2018-01-12 02:16:15 +00:00
|
|
|
HAVE_OVERLAY = 1
|
2019-08-07 01:51:18 +00:00
|
|
|
HAVE_GLSL = 1
|
2020-07-01 15:47:13 +00:00
|
|
|
HAVE_SCREENSHOTS = 1
|
2020-07-01 19:04:05 +00:00
|
|
|
HAVE_REWIND = 1
|
2019-07-11 09:51:06 +00:00
|
|
|
HAVE_AUDIOMIXER = 1
|
2016-12-12 11:48:04 +00:00
|
|
|
HAVE_CC_RESAMPLER = 1
|
2015-11-20 16:41:50 +00:00
|
|
|
HAVE_EGL = 1
|
2016-09-16 22:38:35 +00:00
|
|
|
HAVE_OPENGLES = 1
|
2016-09-17 07:01:59 +00:00
|
|
|
HAVE_RJPEG = 0
|
2020-01-03 01:56:52 +00:00
|
|
|
HAVE_RPNG = 1
|
2014-09-14 01:22:04 +00:00
|
|
|
HAVE_EMSCRIPTEN = 1
|
2019-01-06 22:30:50 +00:00
|
|
|
HAVE_MENU = 1
|
2020-02-17 20:28:42 +00:00
|
|
|
HAVE_GFX_WIDGETS = 1
|
2013-07-18 00:26:01 +00:00
|
|
|
HAVE_RGUI = 1
|
2013-09-11 00:21:48 +00:00
|
|
|
HAVE_SDL = 0
|
2018-01-13 06:05:07 +00:00
|
|
|
HAVE_SDL2 = 0
|
2013-07-18 00:26:01 +00:00
|
|
|
HAVE_ZLIB = 1
|
2018-01-15 10:53:44 +00:00
|
|
|
HAVE_SHADERPIPELINE = 1
|
2017-12-07 04:54:54 +00:00
|
|
|
HAVE_STATIC_VIDEO_FILTERS = 1
|
|
|
|
HAVE_STATIC_AUDIO_FILTERS = 1
|
2018-09-30 22:39:14 +00:00
|
|
|
HAVE_STB_FONT = 1
|
2020-02-02 20:27:38 +00:00
|
|
|
HAVE_CONFIGFILE = 1
|
2023-02-24 21:06:04 +00:00
|
|
|
HAVE_COMMAND = 1
|
|
|
|
HAVE_STDIN_CMD = 1
|
2020-06-30 17:35:41 +00:00
|
|
|
HAVE_CHEATS = 1
|
2020-11-21 20:30:19 +00:00
|
|
|
HAVE_IBXM = 1
|
2021-10-14 13:57:28 +00:00
|
|
|
HAVE_CORE_INFO_CACHE = 1
|
2022-02-01 12:53:03 +00:00
|
|
|
HAVE_7ZIP = 1
|
2023-01-26 04:46:39 +00:00
|
|
|
HAVE_BSV_MOVIE = 1
|
2023-07-14 13:59:45 +00:00
|
|
|
HAVE_AL = 1
|
|
|
|
|
|
|
|
# WARNING -- READ BEFORE ENABLING
|
|
|
|
# The rwebaudio driver is known to have several audio bugs, such as
|
|
|
|
# minor crackling, or the entire page freezing/crashing.
|
|
|
|
# It works perfectly on chrome, but even firefox has really bad audio quality.
|
|
|
|
# I should also note, the driver on iOS is completely broken (crashes the page).
|
|
|
|
# You have been warned.
|
|
|
|
HAVE_RWEBAUDIO = 0
|
2021-01-06 13:04:38 +00:00
|
|
|
|
|
|
|
ASYNC ?= 0
|
|
|
|
ifeq ($(LIBRETRO), mupen64plus)
|
|
|
|
ASYNC = 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
LTO ?= 0
|
|
|
|
ifeq ($(LIBRETRO), tyrquake)
|
|
|
|
LTO = 0
|
|
|
|
endif
|
2016-09-29 00:32:14 +00:00
|
|
|
|
2023-02-27 18:56:12 +00:00
|
|
|
PTHREAD ?= 0
|
|
|
|
|
2021-01-08 14:52:52 +00:00
|
|
|
MEMORY ?= 134217728
|
2019-08-07 01:51:18 +00:00
|
|
|
|
2018-01-16 03:01:25 +00:00
|
|
|
PRECISE_F32 = 1
|
2013-07-18 00:26:01 +00:00
|
|
|
|
2018-01-15 10:53:27 +00:00
|
|
|
OBJDIR := obj-emscripten
|
|
|
|
|
2016-08-01 14:29:56 +00:00
|
|
|
#if you compile with SDL2 flag add this Emscripten flag "-s USE_SDL=2" to LDFLAGS:
|
2016-07-31 15:09:56 +00:00
|
|
|
|
2020-01-03 01:56:52 +00:00
|
|
|
LIBS := -s USE_ZLIB=1
|
2023-11-02 20:25:50 +00:00
|
|
|
LDFLAGS := -L. --no-heap-copy -s $(LIBS) -s TOTAL_MEMORY=$(MEMORY) -s NO_EXIT_RUNTIME=0 -s FULL_ES2=1 \
|
|
|
|
-s "EXPORTED_RUNTIME_METHODS=['callMain', 'FS', 'PATH', 'ERRNO_CODES']" \
|
|
|
|
-s ALLOW_MEMORY_GROWTH=1 -s "EXPORTED_FUNCTIONS=['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot']" \
|
2023-11-15 21:18:41 +00:00
|
|
|
-s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="libretro_$(subst -,_,$(LIBRETRO))" \
|
2023-11-02 20:25:50 +00:00
|
|
|
-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 \
|
2023-07-14 13:59:45 +00:00
|
|
|
--js-library emscripten/library_errno_codes.js \
|
|
|
|
--js-library emscripten/library_rwebcam.js
|
|
|
|
|
|
|
|
ifeq ($(HAVE_RWEBAUDIO), 1)
|
|
|
|
LDFLAGS += --js-library emscripten/library_rwebaudio.js
|
|
|
|
DEFINES += -DHAVE_RWEBAUDIO
|
|
|
|
endif
|
|
|
|
ifeq ($(HAVE_AL), 1)
|
|
|
|
LDFLAGS += -lopenal
|
|
|
|
DEFINES += -DHAVE_AL
|
2023-08-06 23:20:59 +00:00
|
|
|
ASYNC = 1
|
2023-07-14 13:59:45 +00:00
|
|
|
endif
|
2023-02-27 18:56:12 +00:00
|
|
|
|
2016-09-23 15:16:45 +00:00
|
|
|
ifneq ($(PTHREAD), 0)
|
2023-02-27 18:56:12 +00:00
|
|
|
LDFLAGS += -s WASM_MEM_MAX=1073741824 -pthread -s PTHREAD_POOL_SIZE=$(PTHREAD)
|
|
|
|
CFLAGS += -pthread
|
2023-03-07 23:10:59 +00:00
|
|
|
HAVE_THREADS=1
|
|
|
|
else
|
|
|
|
HAVE_THREADS=0
|
2016-09-24 00:48:50 +00:00
|
|
|
endif
|
|
|
|
|
2016-09-29 00:32:14 +00:00
|
|
|
ifeq ($(ASYNC), 1)
|
2023-11-02 20:25:50 +00:00
|
|
|
LDFLAGS += -s ASYNCIFY=$(ASYNC) -s ASYNCIFY_STACK_SIZE=8192
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
LDFLAGS += -s ASYNCIFY_DEBUG=1 # -s ASYNCIFY_ADVISE
|
|
|
|
endif
|
2018-01-13 06:05:07 +00:00
|
|
|
endif
|
2014-09-13 22:55:17 +00:00
|
|
|
|
2018-01-14 20:42:57 +00:00
|
|
|
ifeq ($(HAVE_SDL2), 1)
|
|
|
|
LIBS += -s USE_SDL=2
|
|
|
|
DEFINES += -DHAVE_SDL2
|
|
|
|
endif
|
|
|
|
|
2014-09-13 22:11:08 +00:00
|
|
|
include Makefile.common
|
|
|
|
|
2019-07-25 07:56:57 +00:00
|
|
|
CFLAGS += $(DEF_FLAGS) -Ideps -Ideps/stb
|
2022-08-05 21:51:34 +00:00
|
|
|
|
|
|
|
libretro :=
|
|
|
|
|
|
|
|
ifeq ($(HAVE_STATIC_DUMMY),1)
|
|
|
|
DEFINES += -DHAVE_STATIC_DUMMY
|
|
|
|
else
|
|
|
|
libretro += libretro_emscripten.bc
|
|
|
|
endif
|
2013-07-18 00:26:01 +00:00
|
|
|
|
|
|
|
ifneq ($(V), 1)
|
|
|
|
Q := @
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
2023-11-02 20:25:50 +00:00
|
|
|
LDFLAGS += -O0 -g -gsource-map -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2 -s ASSERTIONS=1
|
|
|
|
CFLAGS += -O0 -g -gsource-map -s SAFE_HEAP=1 -s SAFE_HEAP_LOG=1 -s STACK_OVERFLOW_CHECK=2 -s ASSERTIONS=1
|
2013-07-18 00:26:01 +00:00
|
|
|
else
|
2019-12-15 02:24:41 +00:00
|
|
|
LDFLAGS += -O3 -s WASM=1
|
2013-08-18 06:50:10 +00:00
|
|
|
# WARNING: some optimizations can break some cores (ex: LTO breaks tyrquake)
|
2013-12-29 21:19:07 +00:00
|
|
|
LDFLAGS += -s PRECISE_F32=$(PRECISE_F32)
|
2013-08-18 06:50:10 +00:00
|
|
|
ifeq ($(LTO), 1)
|
|
|
|
LDFLAGS += --llvm-lto 3
|
|
|
|
endif
|
2019-12-15 02:24:41 +00:00
|
|
|
CFLAGS += -O3
|
2013-07-18 00:26:01 +00:00
|
|
|
endif
|
|
|
|
|
2023-11-02 20:25:50 +00:00
|
|
|
# 128 * 1024, double the usual emscripten stack size
|
|
|
|
LDFLAGS += -s STACK_SIZE=131072
|
|
|
|
|
|
|
|
LDFLAGS += --extern-pre-js emscripten/pre.js
|
|
|
|
|
|
|
|
CFLAGS += -Wall -I. -Ilibretro-common/include -std=gnu99 #\
|
2023-02-27 18:56:12 +00:00
|
|
|
# -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_take_screenshot']"
|
2013-07-18 00:26:01 +00:00
|
|
|
|
2018-01-15 10:53:27 +00:00
|
|
|
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
|
|
|
|
|
2013-07-18 00:26:01 +00:00
|
|
|
all: $(TARGET)
|
|
|
|
|
2018-01-16 03:01:25 +00:00
|
|
|
$(TARGET): $(RARCH_OBJ) $(libretro)
|
2013-07-18 00:26:01 +00:00
|
|
|
@$(if $(Q), $(shell echo echo LD $@),)
|
2018-01-15 10:53:27 +00:00
|
|
|
$(Q)$(LD) -o $@ $(RARCH_OBJ) $(libretro) $(LIBS) $(LDFLAGS)
|
2013-07-18 00:26:01 +00:00
|
|
|
|
2018-01-15 10:53:27 +00:00
|
|
|
$(OBJDIR)/%.o: %.c
|
|
|
|
@mkdir -p $(dir $@)
|
2013-07-18 00:26:01 +00:00
|
|
|
@$(if $(Q), $(shell echo echo CC $<),)
|
2016-08-29 05:23:58 +00:00
|
|
|
$(Q)$(CC) $(CFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
|
2013-07-18 00:26:01 +00:00
|
|
|
|
2018-01-15 10:53:27 +00:00
|
|
|
$(OBJDIR)/%.o: %.cpp
|
|
|
|
@mkdir -p $(dir $@)
|
2013-07-18 00:26:01 +00:00
|
|
|
@$(if $(Q), $(shell echo echo CXX $<),)
|
2016-08-29 05:23:58 +00:00
|
|
|
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
|
2013-07-18 00:26:01 +00:00
|
|
|
|
|
|
|
clean:
|
2018-01-15 10:53:27 +00:00
|
|
|
rm -rf $(OBJDIR)
|
2013-08-07 22:37:05 +00:00
|
|
|
rm -f $(TARGET)
|
2013-07-18 00:26:01 +00:00
|
|
|
|
|
|
|
.PHONY: all clean
|