-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
67 lines (47 loc) · 1.48 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
57
58
59
60
61
62
63
64
65
66
WASM2WAT=wasm2wat
WAT2WASM=wat2wasm
WAT2WASM_FLAGS=
ifeq ($(DEBUG),1)
WAT2WASM_FLAGS:=$(WAT2WASM_FLAGS) --debug-names
endif
all:
npm run build
dev:
npm run dev
check:
npm test
check-watch:
npm run test-watch
lint:
npm run lint
wasm: src/waforth.assembled.wat scripts/word.wasm.hex
src/web/benchmarks/sieve/sieve-c.js:
emcc src/web/benchmarks/sieve/sieve.c -O2 -o $@ \
-sSINGLE_FILE -sMODULARIZE -sINITIAL_MEMORY=100Mb \
-sEXPORTED_FUNCTIONS=_sieve -sEXPORTED_RUNTIME_METHODS=ccall,cwrap
.PHONY: standalone
standalone:
$(MAKE) -C src/standalone
.PHONY: waforthc
waforthc:
$(MAKE) -C src/waforthc
%.wasm: %.wat
$(WAT2WASM) $(WAT2WASM_FLAGS) -o $@ $<
%.wasm.hex: %.wasm
hexdump -v -e '16/1 "_%02X" "\n"' $< | sed 's/_/\\/g; s/\\u //g; s/.*/ "&"/' > $@
clean:
-rm -rf $(WASM_FILES) scripts/word.wasm scripts/word.wasm.hex src/waforth.wat.tmp \
public/waforth run_sieve.*
################################################################################
# Sieve benchmark
################################################################################
run_sieve.c: src/web/benchmarks/sieve/sieve.c
(echo "#include <stdio.h>" && cat $< && echo "int main() { printf(\"%d\\\n\", sieve(90000000)); return 0; }") > $@
run_sieve: run_sieve.c
$(CC) -O2 -o $@ $<
run-sieve: run_sieve
time ./run_sieve
run-sieve-gforth:
time gforth -m 100000 src/examples/sieve.f -e "90000000 sieve bye"
run-sieve-gforth-fast:
time gforth-fast -m 100000 src/examples/sieve.f -e "90000000 sieve bye"