-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (27 loc) · 993 Bytes
/
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
CC = gcc
LN = gcc
CFLAGS = -Wall -Werror -O0 -g
LDFLAGS = -lgcc
EMCC = emcc
SRC_FILES = $(shell find src/ -type f -name '*.c')
TEST_FILES = $(shell find test/ -type f -name '*.c')
SRC_TEST_OBJECTS = $(patsubst %.c, build/test/%.o, $(SRC_FILES)) $(patsubst %.c, build/test/%.o, $(TEST_FILES))
WASM_SRC_TEST_OBJECTS = $(patsubst %.c, build/wasm/%.o, $(SRC_FILES)) $(patsubst %.c, build/wasm/%.o, $(TEST_FILES))
DEP_FILES = $(shell find build/ -type f -name '*.d')
-include $(DEP_FILES)
build/wasm/%.o: %.c
@mkdir -p $(@D)
$(EMCC) $(CFLAGS) -c -o $@ $<
build/wasm_test_runner.js: $(WASM_SRC_TEST_OBJECTS)
$(EMCC) $(CFLAGS) -s EXPORTED_FUNCTIONS="_main" -o $@ $(WASM_SRC_TEST_OBJECTS)
build/test/%.o build/test/%.d: %.c
@mkdir -p $(@D)
# $(CC) -MM $^ -MF "$(@:.o=.d)" -MT"$@"
$(CC) $(CFLAGS) -c -o $@ $<
build/test_runner: $(SRC_TEST_OBJECTS)
$(LN) -g -o build/test_runner $(SRC_TEST_OBJECTS)
.PHONY: test clean
test: build/test_runner
build/test_runner
clean:
rm -rfd build/