-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
58 lines (45 loc) · 1.73 KB
/
Makefile
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
EMXX := em++
CXX := g++
EMPPFLAGS := -DASSETS=\"assets/\"
CPPFLAGS := -DASSETS=\"build/apps/assets/\"
EMXXFLAGS := -sUSE_SDL=2 -sALLOW_MEMORY_GROWTH -sUSE_ZLIB=1 -sUSE_SDL_MIXER=1 -sUSE_SDL_TTF=2 -sFETCH -s'EXTRA_EXPORTED_RUNTIME_METHODS=["UTF8ToString"]' -sNO_DISABLE_EXCEPTION_CATCHING -fdeclspec --embed-file build/apps/assets/font.ttf@assets/font.ttf
CXXFLAGS := -w
LDFLAGS := -LC:/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -lSDL2_mixer -lSDL2_ttf -lz
BUILD := ./build
OBJ_DIR := $(BUILD)/objects
OBJ_DIR_LOCAL := $(OBJ_DIR)/local
OBJ_DIR_WASM := $(OBJ_DIR)/wasm
APP_DIR := $(BUILD)/apps
TARGET_LOCAL := a.exe
TARGET_WASM := index.html
INCLUDE := -Iinclude/ -Iinclude/asmodean/ -IC:/x86_64-w64-mingw32/include
SRC := \
$(wildcard src/asmodean/*.cpp) \
$(wildcard src/*.cpp) \
OBJECTS_LOCAL := $(SRC:%.cpp=$(OBJ_DIR_LOCAL)/%.o)
OBJECTS_WASM := $(SRC:%.cpp=$(OBJ_DIR_WASM)/%.o)
# DEP = $(<:%.cpp=$(OBJ_DIR)/%.d)
DEP = $(patsubst %.o,%.d,$@)
DEPENDENCIES_LOCAL := $(OBJECTS_LOCAL:.o=.d)
DEPENDENCIES_WASM := $(OBJECTS_WASM:.o=.d)
MKDIR = if not exist "$(@D)" mkdir "$(@D)"
all: local wasm
wasm: $(APP_DIR)/$(TARGET_WASM)
local: $(APP_DIR)/$(TARGET_LOCAL)
$(OBJ_DIR_LOCAL)/%.o: %.cpp
@$(MKDIR)
$(CXX) -o $@ -c $< $(CXXFLAGS) $(INCLUDE) -MMD -MF $(DEP) $(CPPFLAGS)
$(OBJ_DIR_WASM)/%.o: %.cpp
@$(MKDIR)
$(EMXX) -o $@ -c $< $(EMXXFLAGS) $(CXXFLAGS) $(INCLUDE) -MMD -MF $(DEP) $(EMPPFLAGS)
$(APP_DIR)/$(TARGET_LOCAL): $(OBJECTS_LOCAL)
@$(MKDIR)
$(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
$(APP_DIR)/$(TARGET_WASM): $(OBJECTS_WASM)
@$(MKDIR)
$(EMXX) -o $@ $^ $(EMXXFLAGS) $(CXXFLAGS)
$(OBJ_DIR)/%.d:
@$(MKDIR)
-include $(DEPENDENCIES_LOCAL)
-include $(DEPENDENCIES_WASM)
.PHONY: all