-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (40 loc) · 1.18 KB
/
Makefile
File metadata and controls
52 lines (40 loc) · 1.18 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
49
50
51
52
LIBS =
CFLAGS = -std=c99 -ggdb -O0 -Wall -Wextra -Wcast-align
SRC=main.c emforth.c interpreter.c builtins.c
HEADERS=$(wildcard *.h)
OBJ=$(SRC:.c=.o)
BUILD_DIR=build
OBJ_FILES=$(addprefix $(BUILD_DIR)/,$(OBJ))
BINARY=$(BUILD_DIR)/emforth
EMSCRIPTEM_BIN=$(BUILD_DIR)/emforth.js
EMCC_SRC=$(SRC) platform_web.c
EMCC_FLAGS= -s USE_PTHREADS=0 \
-s ASYNCIFY=1 \
-s WASM=1 \
-s EXPORT_NAME="EmforthModule" \
-s MODULARIZE=1 \
-s NO_EXIT_RUNTIME=1 \
-s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall']" \
-s ALLOW_MEMORY_GROWTH=1 \
-s ASSERTIONS=1
all: $(BINARY)
web: $(EMSCRIPTEM_BIN)
# note, i got incorrect syntax in emforth.js, had to manuall fix a "== =" to "===", might get same again
cp template.html $(BUILD_DIR)/
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BINARY): $(OBJ_FILES) | $(BUILD_DIR)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
$(BUILD_DIR)/%.o: %.c $(HEADERS) | $(BUILD_DIR)
$(CC) -c $(CFLAGS) $< -o $@
$(EMSCRIPTEM_BIN): $(EMCC_SRC) | $(BUILD_DIR)
emcc $^ -o $@ $(EMCC_FLAGS)
clean:
rm -rf $(BUILD_DIR)
strip: $(BINARY)
strip --strip-unneeded $^
cloc:
cloc --exclude-dir=reference,.vscode .
format:
clang-format -i -- **.c **.h
.PHONY: clean cloc strip format