This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
56 lines (40 loc) · 1.12 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
buildtype = release
PROJECT = game-of-life-rs
TARGET = asmjs-unknown-emscripten
DOCS_DIR = docs
DOCS_PORT = 8080
JS_FILE = $(PROJECT).js
CARGO_OUTDIR = target/$(TARGET)/$(buildtype)
CARGO = cargo
EMCC = emcc
CARGO_OPTION = --target $(TARGET)
EMCC_OPTION = -s USE_SDL=2
ifeq ($(buildtype),release)
CARGO_OPTION += --release
EMCC_OPTION += -O3
else ifeq ($(buildtype),debug)
CARGO_OPTION +=
EMCC_OPTION += -g4
DOCS_FILES = $(DOCS_DIR)/$(JS_FILE)
else
$(error "unknown buildtype")
endif
all: $(DOCS_DIR)/$(JS_FILE)
.PHONY: all
clean:
$(CARGO) clean
$(RM) $(DOCS_DIR)/*.js $(DOCS_DIR)/*.js.mem
.PHONY: clean
serve: all
ruby -run -e httpd $(DOCS_DIR) -p $(DOCS_PORT)
FORCE:
.PHONY: FORCE
$(CARGO_OUTDIR)/$(JS_FILE): build-deps FORCE
$(RM) $(DOCS_DIR)/*.js $(DOCS_DIR)/*.js.mem
EMMAKEN_CFLAGS="$(EMCC_OPTION)" $(CARGO) build $(CARGO_OPTION)
$(DOCS_DIR)/$(JS_FILE): $(CARGO_OUTDIR)/$(JS_FILE) FORCE
find $(CARGO_OUTDIR) \( -name '*.js' -or -name '*.js.mem' \) -exec cp {} $(DOCS_DIR) \;
# https:/kripken/emscripten/issues/4151#issuecomment-193909827
build-deps:
embuilder.py build sdl2 gl libc dlmalloc
.PHONY: build-deps