RetroArch/Makefile.emscripten

133 lines
3.0 KiB
Makefile
Raw Normal View History

2021-01-06 13:04:38 +00:00
ifeq ($(TARGET),)
ifeq ($(LIBRETRO),)
TARGET := retroarch.js
2021-01-06 13:04:38 +00:00
else
TARGET := $(LIBRETRO)_libretro.js
endif
endif
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
2016-09-22 21:37:41 +00:00
PTHREAD = 0
2014-09-14 01:38:36 +00:00
OS = Emscripten
OBJ :=
2018-01-12 02:16:15 +00:00
DEFINES := -DRARCH_INTERNAL -DHAVE_MAIN -s USE_PTHREADS=$(PTHREAD)
DEFINES += -DHAVE_FILTERS_BUILTIN
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
HAVE_GLSL = 1
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
HAVE_VIDEO_LAYOUT = 0
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
HAVE_RPNG = 1
2014-09-14 01:22:04 +00:00
HAVE_EMSCRIPTEN = 1
HAVE_MENU = 1
HAVE_GFX_WIDGETS = 1
HAVE_RGUI = 1
HAVE_SDL = 0
HAVE_SDL2 = 0
HAVE_ZLIB = 1
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
HAVE_CONFIGFILE = 1
2020-06-30 17:35:41 +00:00
HAVE_CHEATS = 1
HAVE_IBXM = 1
HAVE_CORE_INFO_CACHE = 1
HAVE_7ZIP = 1
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
MEMORY ?= 134217728
PRECISE_F32 = 1
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
LIBS := -s USE_ZLIB=1
LDFLAGS := -L. --no-heap-copy -s $(LIBS) -s TOTAL_MEMORY=$(MEMORY) -s NO_EXIT_RUNTIME=0 -s FULL_ES2=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']" \
-s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot']" \
--js-library emscripten/library_rwebaudio.js \
--js-library emscripten/library_rwebcam.js \
--js-library emscripten/library_errno_codes.js
ifneq ($(PTHREAD), 0)
2016-09-24 00:48:50 +00:00
LDFLAGS += -s USE_PTHREADS=$(PTHREAD) -s PTHREAD_POOL_SIZE=2
endif
2016-09-29 00:32:14 +00:00
ifeq ($(ASYNC), 1)
2016-09-24 00:48:50 +00:00
LDFLAGS += -s ASYNCIFY=$(ASYNC)
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
CFLAGS += $(DEF_FLAGS) -Ideps -Ideps/stb
libretro = libretro_emscripten.bc
ifneq ($(V), 1)
Q := @
endif
ifeq ($(DEBUG), 1)
LDFLAGS += -O0 -g
CFLAGS += -O0 -g
else
LDFLAGS += -O3 -s WASM=1
# 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)
ifeq ($(LTO), 1)
LDFLAGS += --llvm-lto 3
endif
CFLAGS += -O3
endif
CFLAGS += -Wall -I. -Ilibretro-common/include -std=gnu99 $(LIBS) \
-s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_take_screenshot']"
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
all: $(TARGET)
$(TARGET): $(RARCH_OBJ) $(libretro)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(LD) -o $@ $(RARCH_OBJ) $(libretro) $(LIBS) $(LDFLAGS)
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
2016-08-29 05:23:58 +00:00
$(Q)$(CC) $(CFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
2016-08-29 05:23:58 +00:00
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
clean:
rm -rf $(OBJDIR)
2013-08-07 22:37:05 +00:00
rm -f $(TARGET)
.PHONY: all clean