forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile.emscripten
148 lines (121 loc) · 3.22 KB
/
Makefile.emscripten
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
HAVE_STATIC_DUMMY ?= 0
ifeq ($(TARGET),)
ifeq ($(LIBRETRO),)
TARGET := retroarch.js
else
TARGET := $(LIBRETRO)_libretro.js
endif
endif
EOPT = USE_ZLIB=1 # Emscripten specific options
EOPTS = $(addprefix -s $(EMPTY), $(EOPT)) # Add '-s ' to each option
OS = Emscripten
OBJ :=
DEFINES := -DRARCH_INTERNAL -DHAVE_MAIN
DEFINES += -DHAVE_FILTERS_BUILTIN
HAVE_PATCH = 1
HAVE_DSP_FILTER = 1
HAVE_VIDEO_FILTER = 1
HAVE_OVERLAY = 1
HAVE_GLSL = 1
HAVE_SCREENSHOTS = 1
HAVE_REWIND = 1
HAVE_AUDIOMIXER = 1
HAVE_CC_RESAMPLER = 1
HAVE_EGL = 1
HAVE_OPENGLES = 1
HAVE_RJPEG = 0
HAVE_RPNG = 1
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
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
HAVE_STB_FONT = 1
HAVE_CONFIGFILE = 1
HAVE_COMMAND = 1
HAVE_STDIN_CMD = 1
HAVE_CHEATS = 1
HAVE_IBXM = 1
HAVE_CORE_INFO_CACHE = 1
HAVE_7ZIP = 1
HAVE_BSV_MOVIE = 1
ASYNC ?= 0
ifeq ($(LIBRETRO), mupen64plus)
ASYNC = 1
endif
LTO ?= 0
ifeq ($(LIBRETRO), tyrquake)
LTO = 0
endif
PTHREAD ?= 0
MEMORY ?= 134217728
PRECISE_F32 = 1
OBJDIR := obj-emscripten
#if you compile with SDL2 flag add this Emscripten flag "-s USE_SDL=2" to LDFLAGS:
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)
LDFLAGS += -s WASM_MEM_MAX=1073741824 -pthread -s PTHREAD_POOL_SIZE=$(PTHREAD)
CFLAGS += -pthread
HAVE_THREADS=1
else
HAVE_THREADS=0
endif
ifeq ($(ASYNC), 1)
LDFLAGS += -s ASYNCIFY=$(ASYNC)
endif
ifeq ($(HAVE_SDL2), 1)
LIBS += -s USE_SDL=2
DEFINES += -DHAVE_SDL2
endif
include Makefile.common
CFLAGS += $(DEF_FLAGS) -Ideps -Ideps/stb
libretro :=
ifeq ($(HAVE_STATIC_DUMMY),1)
DEFINES += -DHAVE_STATIC_DUMMY
else
libretro += libretro_emscripten.bc
endif
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)
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 $<),)
$(Q)$(CC) $(CFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
clean:
rm -rf $(OBJDIR)
rm -f $(TARGET)
.PHONY: all clean