-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.wasm
66 lines (56 loc) · 1.42 KB
/
Makefile.wasm
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
OUT_FILE := main.js
OUT_DIR := build
INC_DIR := src
SRC_DIR := src
OBJ_DIR := obj/wasm
# CXX := EMCC_WASM_BACKEND=1 em++
# LINKER := EMCC_WASM_BACKEND=1 em++
CXX := em++
LINKER := em++
INC_DIRS := -I$(INC_DIR)
CXX_FLAGS = \
-std=c++11 \
-std=c++14 \
-Wall \
-Wno-missing-braces \
-Wextra \
-Wshadow \
-pedantic \
-Oz \
-s USE_SDL=2 \
-s USE_SDL_IMAGE=2 \
-s USE_SDL_TTF=2 \
-s SDL2_IMAGE_FORMATS='["png"]' \
-s MODULARIZE=1 \
-s DISABLE_EXCEPTION_CATCHING=0 \
-s WASM=1 \
-s "BINARYEN_METHOD='native-wasm'" \
-s ASSERTIONS=1 \
-s TOTAL_MEMORY=160MB \
#-D DRAW_FPS \
-D DRAW_COLLISION
EXEC_FLAGS = \
--preload-file assets \
-s EXPORTED_FUNCTIONS='["_initialize", "_resize"]' \
--emrun
LIBS :=
SRC_FILES := $(shell find $(SRC_DIR) -name '*.cpp')
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES))
DEPFILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.d,$(SRC_FILES))
$(OUT_DIR)/$(OUT_FILE): $(OBJ_FILES)
$(LINKER) $(CXX_FLAGS) $(EXEC_FLAGS) $^ $(LIBS) -o $@
clean:
rm -rf $(OBJ_DIR) $(OUT_DIR)/main*.{js,data,wasm,wast}
list:
@echo "$(SRC_FILES)"
@echo "$(OBJ_FILES)"
depends:
rm -rf $(OBJ_DIR)/*.d
$(MAKE) $(DEPFILES)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(@D)
$(CXX) $(CXX_FLAGS) $(INC_DIRS) -c $< -o $@
$(OBJ_DIR)/%.d: $(SRC_DIR)/%.cpp
@mkdir -p $(@D)
$(CXX) $(CXX_FLAGS) $(INC_DIRS) -MM $< | tr '\n\r\\' ' ' | sed -e 's%^%$@ %' -e 's% % $(OBJ_DIR)/%' > $@
-include $(DEPFILES)