-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
52 lines (38 loc) · 1.26 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
CC = g++
SRCDIR = src
OBJDIR = obj
SRCS = $(wildcard $(SRCDIR)/*.cpp)
SRCS += $(wildcard $(SRCDIR)/*/*.cpp)
SRCS += $(wildcard vecmath/src/*.cpp)
OBJS := $(SRCS:%.cpp=$(OBJDIR)/%.o)
PROG = proj
CFLAGS = -O2 -Wall -Wextra -std=c++20
INCFLAGS = -Ivecmath/include
all: $(PROG)
$(PROG): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $@ $(LINKFLAGS)
$(OBJDIR)/%.o: %.cpp
@echo "COMPILING SOURCE $< INTO OBJECT $@"
@mkdir -p '$(@D)'
@$(CC) $(CFLAGS) $< -c -o $@ $(INCFLAGS)
EMCC = ~/emsdk/upstream/emscripten/emcc
EMOBJDIR = emobj
EMOBJS = $(SRCS:%.cpp=$(EMOBJDIR)/%.o)
WEBDIR = front/web
WEBJS = $(WEBDIR)/index.js
WEBWASM = $(WEBDIR)/index.wasm
WEBDATA = $(WEBDIR)/index.data
EMCFLAGS = -O3 -Wall -Wextra -std=c++20
EMFLAGS = --bind -sALLOW_MEMORY_GROWTH -sASYNCIFY -sENVIRONMENT=web -sMODULARIZE=1 -s'EXPORT_NAME="initModule"' -s'EXPORTED_RUNTIME_METHODS=["FS"]' --preload-file scene
web: $(WEBJS)
$(WEBJS): $(EMOBJS)
mkdir -p $(WEBDIR)
$(EMCC) $(EMCFLAGS) $(EMOBJS) -o $@ $(LINKFLAGS) $(EMFLAGS)
$(EMOBJDIR)/%.o: %.cpp
@echo "COMPILING SOURCE $< INTO OBJECT $@"
@mkdir -p '$(@D)'
@$(EMCC) $(EMCFLAGS) $< -c -o $@ $(INCFLAGS)
clean:
rm -rf *.bak $(OBJDIR) core.* $(PROG) $(EMOBJDIR) $(WEBJS) $(WEBWASM) $(WEBDATA)
cleanTarget:
rm -rf $(PROG) $(WEBJS) $(WEBWASM) $(WEBDATA)