-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.wasm
113 lines (83 loc) · 2.36 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# vi:syntax=make
ifneq ($(CALLER),MASTER)
include Makefile.inc
endif
# 1. Directories
OBJDIR_WASM := $(OBJDIR)/wasm
DEPDIR_WASM := $(DEPDIR)/wasm
GENDIR_WASM := $(GENDIR)/wasm
# 2. Files
BIN_WASM := $(BINDIR)/$(DSEKAI).html
ifeq ("$(RESOURCE)","DEFAULT")
DEFINES_RESOURCE := -DRESOURCE_WASM
DSEKAI_C_FILES_RES := unilayer/src/resource/webr.c
endif
DSEKAI_C_FILES_WASM_ONLY := \
src/main.c \
src/pov.c \
src/scparse.c \
unilayer/src/animate.c \
unilayer/src/input/sdli.c \
unilayer/src/graphics/sdlg.c \
unilayer/src/save/web.c \
unilayer/src/memory/fakem.c \
unilayer/src/resource/webr.c
DSEKAI_O_FILES_WASM := \
$(addprefix $(OBJDIR_WASM)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \
$(addprefix $(OBJDIR_WASM)/,$(subst .c,.o,$(DSEKAI_C_FILES_WASM_ONLY))) \
$(addprefix $(OBJDIR_WASM)/,$(subst .c,.o,$(DSEKAI_C_FILES_RES)))
RESEXT_H_WASM := $(GENDIR_WASM)/resext.h
# 3. Programs
CC_WASM := emcc
LD_WASM := emcc
# 4. Arguments
DEFINES_WASM := \
$(DEFINES_DSEKAI) \
$(DEFINES_DEPTH) \
$(DEFINES_RESOURCE) \
-DPLATFORM_SDL \
-DPLATFORM_WASM \
-DNO_QUIT \
-DUSE_SOFTWARE_TEXT \
-DSCREEN_SCALE=$(SCREEN_SCALE)
INCLUDES_WASM := \
$(INCLUDES_UNILAYER) \
-I $(GENDIR_WASM)
CFLAGS_WASM := $(CFLAGS_GCC_GENERIC) $(DEFINES_WASM) $(INCLUDES_WASM) -s USE_SDL=2
LDFLAGS_WASM := $(LDFLAGS_GCC_GENERIC) -s USE_SDL=2 -s FETCH
ifneq ($(BUILD),RELEASE)
LDFLAGS_WASM += -s ASSERTIONS=1
endif
# 5. Targets
# 5a. Packages
platform := wasm
platform_upper := WASM
res_gfx := $(DSEKAI_ASSETS_BITMAPS)
ifneq ("$(RESOURCE)", "DEFAULT")
$(eval $(RESEXT_H_RULE))
else
$(RESEXT_H_WASM):
# TODO
$(MD) $(dir $@)
touch $@
endif
pkg_bin := $(BIN_WASM) \
$(BINDIR)/$(DSEKAI).wasm \
$(BINDIR)/$(DSEKAI).js
pkg_strip := echo
pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH)
pkg_reqs :=
$(eval $(PKG_RULE))
# 5b. Binaries
$(BIN_WASM) $(BINDIR)/$(DSEKAI).wasm $(BINDIR)/$(DSEKAI).js: \
$(DSEKAI_O_FILES_WASM) | $(BINDIR)/$(STAMPFILE)
$(LD_WASM) -o $(BIN_WASM) $^ $(LDFLAGS_WASM)
$(OBJDIR_WASM)/%.o: %.c $(RESEXT_H_WASM) | $(DSEKAI_ASSETS_MAPS_JSON)
$(MD) $(dir $@)
$(CC_WASM) $(CFLAGS_WASM) -c -o $@ $(<:%.o=%)
#$(DEPDIR_WASM)/%.d: %.c $(RESEXT_H_WASM)
# $(MD) $(dir $@)
# $(CC_WASM) $(CFLAGS_WASM) -MM $< \
# -MT $(subst .c,.o,$(addprefix $(DEPDIR_WASM)/,$<)) -MF $@
#
#include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_WASM:.o=.d))