-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMakefile.wasm
More file actions
96 lines (75 loc) · 2.14 KB
/
Makefile.wasm
File metadata and controls
96 lines (75 loc) · 2.14 KB
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
CC = emcc
CXX = em++
OBJC = em++
LN = emcc
FIND = find src -type f -name
DOTTO = dotto.html
LIB_DIRS += $(shell find dependencies -type d)
CPP_FLAGS += $(patsubst %,-I%,$(LIB_DIRS))
SRC_DIRS += $(shell find src -type d)
SRC_DIRS += $(LIB_DIRS)
CPP_FLAGS += -Isrc
CPP_FLAGS += -MMD -MP
CPP_FLAGS += -DUSE_SDL2
CPP_FLAGS += -DNO_THREADS
CPP_FLAGS += -DNO_NETWORK
FLAGS += -s USE_SDL=2
FLAGS += -s USE_FREETYPE=1
FLAGS += -s USE_LIBJPEG=1
FLAGS += -s USE_SDL_IMAGE=2
FLAGS += -s SDL2_IMAGE_FORMATS='["bmp","xpm","jpg"]'
FLAGS += -s USE_LIBPNG=1
LN_FLAGS += -s ALLOW_MEMORY_GROWTH=1
LN_FLAGS += -s USE_WEBGL2=1
LN_FLAGS += -s EXPORTED_FUNCTIONS=_main,_onPointerEvent
LN_FLAGS += -s EXPORTED_RUNTIME_METHODS=cwrap
LN_FLAGS += --preload-file data
CPP_FILES += $(shell find src -type f -name '*.cpp')
CPP_FILES += $(shell find dependencies -type f -name '*.cpp')
C_FLAGS := $(CPP_FLAGS)
C_FILES += $(shell find src -type f -name '*.c')
C_FILES += $(shell find dependencies -type f -name '*.c')
LN_FLAGS += $(SO_FILES)
#BEGIN V8 SUPPORT
# CPP_FLAGS += -DSCRIPT_ENGINE_V8
# CPP_FLAGS += $(shell $(PKGCONFIG) --cflags v8)
# CPP_FLAGS += $(shell $(PKGCONFIG) --cflags v8_libplatform)
# LN_FLAGS += $(shell $(PKGCONFIG) --libs v8)
# LN_FLAGS += $(shell $(PKGCONFIG) --libs v8_libplatform)
#END
ODIR = buildwasm
CPP_FLAGS += --std=c++17
CPP_FLAGS += -DCMS_NO_REGISTER_KEYWORD
# FLAGS += -m32 # uncomment for 32-bit build
ifeq ($(DEBUG),true)
FLAGS += -Og -g -D_DEBUG # debug build
POSTBUILD =
else
FLAGS += -O3 # release build
POSTBUILD =
endif
# LN_FLAGS += -lm
# LN_FLAGS += -fsanitize=leak
OBJ = $(patsubst %,$(ODIR)/%.o,$(CPP_FILES))
OBJ += $(patsubst %,$(ODIR)/%.o,$(C_FILES))
DEP := $(OBJ:.o=.d)
$(ODIR)/%.cpp.o: %.cpp
$(info CXX - $<)
@mkdir -p "$$(dirname "$@")"
@$(CXX) $(FLAGS) $(CPP_FLAGS) -c $< -o $@
$(ODIR)/%.c.o: %.c
$(info CC - $<)
@mkdir -p "$$(dirname "$@")"
@$(CC) $(FLAGS) $(C_FLAGS) -c $< -o $@
$(ODIR)/%.mm.o: %.mm
$(info OBJC - $<)
@mkdir -p "$$(dirname "$@")"
@$(OBJC) $(FLAGS) $(CPP_FLAGS) -c $< -o $@
$(DOTTO): $(OBJ)
$(info Linking $@)
@$(LN) $(FLAGS) $^ -o $@ $(LN_FLAGS)
@$(POSTBUILD)
.PHONY: clean
clean:
rm -rf $(ODIR)
-include $(DEP)