-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile.emscripten
62 lines (51 loc) · 1.7 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
CC = emcc
DEBUG ?= 0
RENDER_GL ?= 1
SRC = $(wildcard src/*.c src/lib/*.c src/lib/rsa/*.c src/ui/*.c src/custom/*.c)
OBJ = $(SRC:.c=.o)
# remove -fwrapv when code is converted to use unsigned ints or
# overflow checks are added
CFLAGS += -fwrapv
# some platforms require gnu99 instead of c99 to use functions like alloca.
CFLAGS += -std=gnu99 -s USE_SDL=2 -DSDL2
#CFLAGS += -DREVISION_177
# build both wasm and js
LDFLAGS += -sWASM=2
LDFLAGS += -sWEBSOCKET_URL=wss://
LDFLAGS += -lm -lSDL2
ifeq ($(RENDER_GL), 1)
SRC += $(wildcard src/gl/*.c src/gl/textures/*.c)
CFLAGS += -I ./cglm/include -DRENDER_GL
CFLAGS += -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]'
LDFLAGS += -lGLEW -lGL
LDFLAGS += --use-preload-plugins -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]'
LDFLAGS += -s MAX_WEBGL_VERSION=2 -sFULL_ES2 -sFULL_ES3
LDFLAGS += --preload-file ./cache/textures/
else
CFLAGS += -DRENDER_SW
CFLAGS += -s USE_SDL_IMAGE=0
endif
ifeq ($(DEBUG), 1)
CFLAGS += -Wall -Wextra -pedantic -g
LDFLAGS += -s SOCKET_DEBUG=1
else
CFLAGS += -s -O3 -ffast-math -flto
ifeq ($(RENDER_GL), 0)
LDFLAGS += -flto
endif
endif
LDFLAGS += -sEXPORTED_FUNCTIONS=_browser_mouse_moved,_browser_key_pressed,_main
LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall,cwrap
CFLAGS += -s DISABLE_EXCEPTION_THROWING=1
LDFLAGS += -s INITIAL_MEMORY=50MB -s ALLOW_MEMORY_GROWTH=1 -s USE_SDL=2
LDFLAGS += -s ASYNCIFY -s ASYNCIFY_STACK_SIZE=16384
LDFLAGS += -s MIN_FIREFOX_VERSION=52
LDFLAGS += --preload-file ./cache/
LDFLAGS += --shell-file ./web/shell.html
all: mudclient.html
mudclient.html: $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
clean:
rm -f src/*.o src/lib/*.o src/lib/rsa/*.o src/ui/*.o
rm -f src/gl/*.o src/gl/textures/*.o src/custom/*.o
rm -f mudclient mudclient.*