2016-08-28 19:14:42 -05:00
|
|
|
TARGET := retroarch.js
|
2013-07-17 20:26:01 -04:00
|
|
|
|
2018-01-18 22:57:00 -06:00
|
|
|
EOPT = USE_ZLIB=1 # Emscripten specific options
|
2016-08-29 00:23:58 -05:00
|
|
|
EOPTS = $(addprefix -s $(EMPTY), $(EOPT)) # Add '-s ' to each option
|
|
|
|
|
2016-09-22 15:37:41 -06:00
|
|
|
PTHREAD = 0
|
2014-09-14 03:38:36 +02:00
|
|
|
OS = Emscripten
|
2014-09-14 00:04:42 +02:00
|
|
|
OBJ :=
|
2018-01-12 03:16:15 +01:00
|
|
|
DEFINES := -DRARCH_INTERNAL -DHAVE_MAIN -s USE_PTHREADS=$(PTHREAD)
|
|
|
|
DEFINES += -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_GLSL -DHAVE_FILTERS_BUILTIN
|
2013-07-17 20:26:01 -04:00
|
|
|
|
2018-01-12 03:16:15 +01:00
|
|
|
HAVE_OVERLAY = 1
|
2016-12-12 12:48:04 +01:00
|
|
|
HAVE_CC_RESAMPLER = 1
|
2015-11-20 17:41:50 +01:00
|
|
|
HAVE_EGL = 1
|
2016-09-17 00:38:35 +02:00
|
|
|
HAVE_OPENGLES = 1
|
2016-09-17 02:01:59 -05:00
|
|
|
HAVE_RJPEG = 0
|
2016-08-01 16:25:02 +02:00
|
|
|
HAVE_RPNG = 1
|
2014-09-14 03:22:04 +02:00
|
|
|
HAVE_EMSCRIPTEN = 1
|
2013-07-17 20:26:01 -04:00
|
|
|
HAVE_RGUI = 1
|
2013-09-10 20:21:48 -04:00
|
|
|
HAVE_SDL = 0
|
2018-01-13 00:05:07 -06:00
|
|
|
HAVE_SDL2 = 0
|
2013-07-17 20:26:01 -04:00
|
|
|
HAVE_ZLIB = 1
|
2015-03-14 05:24:57 +01:00
|
|
|
WANT_ZLIB = 1
|
2018-01-15 04:53:44 -06:00
|
|
|
HAVE_SHADERPIPELINE = 1
|
2017-12-07 05:54:54 +01:00
|
|
|
HAVE_STATIC_VIDEO_FILTERS = 1
|
|
|
|
HAVE_STATIC_AUDIO_FILTERS = 1
|
2016-09-24 12:59:10 -05:00
|
|
|
MEMORY = 536870912
|
2016-09-28 19:32:14 -05:00
|
|
|
|
2018-01-15 21:01:25 -06:00
|
|
|
PRECISE_F32 = 1
|
2013-07-17 20:26:01 -04:00
|
|
|
|
2018-01-15 04:53:27 -06:00
|
|
|
OBJDIR := obj-emscripten
|
|
|
|
|
2013-07-27 14:17:22 -04:00
|
|
|
ifneq ($(NATIVE_ZLIB),)
|
2015-03-14 05:24:57 +01:00
|
|
|
WANT_ZLIB = 0
|
2013-07-27 14:17:22 -04:00
|
|
|
endif
|
|
|
|
|
2016-08-01 16:29:56 +02:00
|
|
|
#if you compile with SDL2 flag add this Emscripten flag "-s USE_SDL=2" to LDFLAGS:
|
2016-07-31 18:09:56 +03:00
|
|
|
|
2018-01-14 14:42:57 -06:00
|
|
|
LIBS := -s USE_ZLIB=1
|
2018-01-15 21:01:25 -06:00
|
|
|
LDFLAGS := -L. --no-heap-copy -s USE_ZLIB=1 -s TOTAL_MEMORY=$(MEMORY) -s NO_EXIT_RUNTIME=0 -s FULL_ES2=1 -s BINARYEN_TRAP_MODE=\"clamp\" \
|
2015-07-27 00:08:14 +02:00
|
|
|
-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
|
2016-09-23 09:16:45 -06:00
|
|
|
ifneq ($(PTHREAD), 0)
|
2016-09-23 19:48:50 -05:00
|
|
|
LDFLAGS += -s USE_PTHREADS=$(PTHREAD) -s PTHREAD_POOL_SIZE=2
|
|
|
|
endif
|
|
|
|
|
2016-09-28 19:32:14 -05:00
|
|
|
ifeq ($(ASYNC), 1)
|
2016-09-23 19:48:50 -05:00
|
|
|
LDFLAGS += -s ASYNCIFY=$(ASYNC)
|
2018-01-13 00:05:07 -06:00
|
|
|
endif
|
2014-09-14 00:55:17 +02:00
|
|
|
|
2018-01-14 14:42:57 -06:00
|
|
|
ifeq ($(HAVE_SDL2), 1)
|
|
|
|
LIBS += -s USE_SDL=2
|
|
|
|
DEFINES += -DHAVE_SDL2
|
|
|
|
endif
|
|
|
|
|
2014-09-14 00:11:08 +02:00
|
|
|
include Makefile.common
|
|
|
|
|
2017-11-06 05:23:53 +01:00
|
|
|
CFLAGS += -Ideps/libz -Ideps -Ideps/stb
|
2013-08-18 02:50:10 -04:00
|
|
|
libretro = libretro_emscripten.bc
|
2013-07-17 20:26:01 -04:00
|
|
|
|
|
|
|
ifneq ($(V), 1)
|
|
|
|
Q := @
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
2013-07-27 14:17:22 -04:00
|
|
|
LDFLAGS += -O0 -g
|
2013-08-18 02:50:10 -04:00
|
|
|
CFLAGS += -O0 -g
|
2013-07-17 20:26:01 -04:00
|
|
|
else
|
2018-01-15 04:00:09 -06:00
|
|
|
LDFLAGS += -O2 -s WASM=1
|
2013-08-18 02:50:10 -04:00
|
|
|
# WARNING: some optimizations can break some cores (ex: LTO breaks tyrquake)
|
2013-12-29 16:19:07 -05:00
|
|
|
LDFLAGS += -s PRECISE_F32=$(PRECISE_F32)
|
2013-08-18 02:50:10 -04:00
|
|
|
ifeq ($(LTO), 1)
|
|
|
|
LDFLAGS += --llvm-lto 3
|
|
|
|
endif
|
|
|
|
CFLAGS += -O2
|
2013-07-17 20:26:01 -04:00
|
|
|
endif
|
|
|
|
|
2018-01-15 04:00:09 -06:00
|
|
|
CFLAGS += -DHAVE_RPNG -Wall -I. -Ilibretro-common/include -std=gnu99 -s USE_ZLIB=1 \
|
2015-07-27 00:08:14 +02:00
|
|
|
-s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_take_screenshot']"
|
2013-07-17 20:26:01 -04:00
|
|
|
|
2018-01-15 04:53:27 -06:00
|
|
|
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
|
|
|
|
|
2013-07-17 20:26:01 -04:00
|
|
|
all: $(TARGET)
|
|
|
|
|
2018-01-15 21:01:25 -06:00
|
|
|
$(TARGET): $(RARCH_OBJ) $(libretro)
|
2013-07-17 20:26:01 -04:00
|
|
|
@$(if $(Q), $(shell echo echo LD $@),)
|
2018-01-15 04:53:27 -06:00
|
|
|
$(Q)$(LD) -o $@ $(RARCH_OBJ) $(libretro) $(LIBS) $(LDFLAGS)
|
2013-07-17 20:26:01 -04:00
|
|
|
|
2018-01-15 04:53:27 -06:00
|
|
|
$(OBJDIR)/%.o: %.c
|
|
|
|
@mkdir -p $(dir $@)
|
2013-07-17 20:26:01 -04:00
|
|
|
@$(if $(Q), $(shell echo echo CC $<),)
|
2016-08-29 00:23:58 -05:00
|
|
|
$(Q)$(CC) $(CFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
|
2013-07-17 20:26:01 -04:00
|
|
|
|
2018-01-15 04:53:27 -06:00
|
|
|
$(OBJDIR)/%.o: %.cpp
|
|
|
|
@mkdir -p $(dir $@)
|
2013-07-17 20:26:01 -04:00
|
|
|
@$(if $(Q), $(shell echo echo CXX $<),)
|
2016-08-29 00:23:58 -05:00
|
|
|
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
|
2013-07-17 20:26:01 -04:00
|
|
|
|
|
|
|
clean:
|
2018-01-15 04:53:27 -06:00
|
|
|
rm -rf $(OBJDIR)
|
2013-08-07 18:37:05 -04:00
|
|
|
rm -f $(TARGET)
|
2013-07-17 20:26:01 -04:00
|
|
|
|
|
|
|
.PHONY: all clean
|