-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
48 lines (35 loc) · 1.08 KB
/
Copy pathmakefile
File metadata and controls
48 lines (35 loc) · 1.08 KB
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
CC=gcc
EMCC=emcc
WARN_FLAGS = -Wall -Wextra
DEBUG_FLAGS = -g
PERF_FLAGS = -O3 -march=native -flto
EM_FLAGS = -O3 -msimd128 -flto \
-sFILESYSTEM=0 \
-s EXPORT_ES6 \
-s "EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap', 'UTF8ToString', 'stringToNewUTF8']" \
-s "EXPORTED_FUNCTIONS=['_malloc', '_free']"
SRC_DIR = src
BUILD_DIR = build
BUILD_DIR_WASM = html/build
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
WASM_SRCS = $(filter-out $(SRC_DIR)/file_io.c, $(wildcard $(SRC_DIR)/*.c))
.PHONY: all debug wasm clean
$(shell mkdir -p $(BUILD_DIR))
$(shell mkdir -p $(BUILD_DIR_WASM))
all: native wasm
native: CFLAGS = $(WARN_FLAGS) $(PERF_FLAGS)
native: LDFLAGS = $(PERF_FLAGS)
native: face-remove
debug: CFLAGS = $(WARN_FLAGS) $(DEBUG_FLAGS)
debug: LDFLAGS =
debug: face-remove
wasm: $(WASM_SRCS)
$(EMCC) $(EM_FLAGS) -o $(BUILD_DIR_WASM)/face-remove.js $^
face-remove: $(OBJS)
$(CC) $(LDFLAGS) -o $(BUILD_DIR)/$@ $^ -lm
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
$(RM) -r $(BUILD_DIR)/*
$(RM) -r $(BUILD_DIR_WASM)/*