-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebMakefile_Backup.txt
56 lines (40 loc) · 1.45 KB
/
WebMakefile_Backup.txt
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
# Makefile
# Compiler
CXX = emcc
# Current directory where Makefile resides
CUR_DIR = $(shell pwd)
# Include directories with dynamic path for LuaBridge
INCLUDES = -I$(CUR_DIR)/glm -I$(CUR_DIR)/rapidjson
INCLUDES += -I$(CUR_DIR)/Lua -I$(CUR_DIR)/LuaBridge
INCLUDES += -I$(CUR_DIR)/box2d/include -I$(CUR_DIR)/box2d/include/box2d -I$(CUR_DIR)/box2d -I$(CUR_DIR)/box2d/dynamics
INCLUDE += -I$(CUR_DIR)/emsdk/upstream/emscripten/system/include
# Compiler flags
CXXFLAGS = -std=c++17 -Wall -Wextra -O3 $(INCLUDES)
# Verbose mode
ifdef VERBOSE
CXXFLAGS += -v
LDFLAGS += -v
endif
# Emscripten Flags
EM_FLAGS = -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' -s USE_SDL_TTF=2 -s USE_SDL_MIXER=2
EM_FLAGS += -s WASM=1 --preload-file resources
EM_FLAGS += -s ALLOW_MEMORY_GROWTH=1
# Now in your compiler flags or linker flags, you just add $(EM_FLAGS)
CXXFLAGS += $(EM_FLAGS)
# Assuming the Lua library is in $(CUR_DIR)/Lua
LDFLAGS += -L$(CUR_DIR)/Lua -llua $(EM_FLAGS)
# Name of the final executable
EXECUTABLE = game_engine_web.html
# Source files
SOURCES = main.cpp $(wildcard box2d/*.cpp) Actor.cpp
# Object files (ensure they are generated in the current directory or a specific build directory)
OBJECTS = $(SOURCES:%.cpp=%.o)
# Rule for making the final executable
$(EXECUTABLE): $(OBJECTS)
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
# Rule for making object files
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean
clean:
rm -f $(OBJECTS) $(EXECUTABLE)