waforth/Makefile

68 lines
1.5 KiB
Makefile
Raw Permalink Normal View History

2019-03-11 16:34:15 +01:00
WASM2WAT=wasm2wat
2018-05-12 21:09:19 +02:00
WAT2WASM=wat2wasm
2019-11-09 20:04:11 +01:00
WAT2WASM_FLAGS=
2018-05-12 21:09:19 +02:00
ifeq ($(DEBUG),1)
WAT2WASM_FLAGS:=$(WAT2WASM_FLAGS) --debug-names
2018-05-12 21:09:19 +02:00
endif
2022-04-13 17:02:46 +02:00
all:
2024-02-22 21:10:04 +01:00
npm run build
2018-05-12 21:09:19 +02:00
2022-04-13 17:02:46 +02:00
dev:
2024-02-22 21:10:04 +01:00
npm run dev
2022-04-13 17:02:46 +02:00
2022-04-17 09:28:53 +02:00
check:
2024-02-22 21:10:04 +01:00
npm test
2022-04-13 17:02:46 +02:00
2022-04-17 09:28:53 +02:00
check-watch:
2024-02-22 21:10:04 +01:00
npm run test-watch
2018-05-29 08:48:08 +02:00
2022-04-17 09:28:53 +02:00
lint:
2024-02-22 21:10:04 +01:00
npm run lint
2022-04-17 09:28:53 +02:00
2022-04-23 11:09:32 +02:00
wasm: src/waforth.assembled.wat scripts/word.wasm.hex
2018-05-12 21:09:19 +02:00
2022-05-01 22:55:32 +02:00
src/web/benchmarks/sieve/sieve-c.js:
2022-12-18 16:24:35 +01:00
emcc src/web/benchmarks/sieve/sieve.c -O2 -o $@ \
-sSINGLE_FILE -sMODULARIZE -sINITIAL_MEMORY=100Mb \
-sEXPORTED_FUNCTIONS=_sieve -sEXPORTED_RUNTIME_METHODS=ccall,cwrap
2022-05-01 20:45:10 +02:00
2022-05-28 22:08:12 +02:00
.PHONY: standalone
standalone:
$(MAKE) -C src/standalone
2022-11-16 21:54:37 +01:00
.PHONY: waforthc
waforthc:
$(MAKE) -C src/waforthc
2022-05-01 22:55:32 +02:00
%.wasm: %.wat
2018-05-12 21:09:19 +02:00
$(WAT2WASM) $(WAT2WASM_FLAGS) -o $@ $<
2022-05-01 22:55:32 +02:00
%.wasm.hex: %.wasm
2022-04-23 12:09:28 +02:00
hexdump -v -e '16/1 "_%02X" "\n"' $< | sed 's/_/\\/g; s/\\u //g; s/.*/ "&"/' > $@
2018-05-12 21:09:19 +02:00
clean:
2022-04-23 11:09:32 +02:00
-rm -rf $(WASM_FILES) scripts/word.wasm scripts/word.wasm.hex src/waforth.wat.tmp \
2022-12-21 15:56:45 +01:00
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"
2019-03-09 20:13:00 +01:00