|
1 | | -lslib/lexer.wat: lib/lexer.wasm |
2 | | - ../wabt/bin/wasm2wat lib/lexer.wasm -o lib/lexer.wat |
| 1 | +# These flags depend on the system and may be overridden |
| 2 | +WASM_CC := ../wasi-sdk-12.0/bin/clang |
| 3 | +WASM_CFLAGS := --sysroot=../wasi-sdk-12.0/share/wasi-sysroot |
| 4 | +WASM_LDFLAGS := -nostartfiles |
3 | 5 |
|
4 | | -lib/lexer.wasm: include-wasm/cjs-module-lexer.h src/lexer.c |
5 | | - @mkdir -p lib |
6 | | - ../wasi-sdk-12.0/bin/clang src/lexer.c -I include-wasm --sysroot=../wasi-sdk-12.0/share/wasi-sysroot -o lib/lexer.wasm -nostartfiles \ |
7 | | - -Wl,-z,stack-size=13312,--no-entry,--compress-relocations,--strip-all,--export=__heap_base,\ |
8 | | - --export=parseCJS,--export=sa,--export=e,--export=re,--export=es,--export=ee,--export=rre,--export=ree,--export=res,--export=ru,--export=us,--export=ue \ |
9 | | - -Wno-logical-op-parentheses -Wno-parentheses \ |
10 | | - -Oz |
| 6 | +WASM2WAT := ../wabt/bin/wasm2wat |
| 7 | +WASM_OPT := ../binaryen/bin/wasm-opt |
| 8 | + |
| 9 | +# These are project-specific and are expected to be kept intact |
| 10 | +WASM_EXTRA_CFLAGS := -I include-wasm/ -Wno-logical-op-parentheses -Wno-parentheses -Oz |
| 11 | +WASM_EXTRA_LDFLAGS := -Wl,-z,stack-size=13312,--no-entry,--compress-relocations,--strip-all |
| 12 | +WASM_EXTRA_LDFLAGS += -Wl,--export=__heap_base,--export=parseCJS,--export=sa |
| 13 | +WASM_EXTRA_LDFLAGS += -Wl,--export=e,--export=re,--export=es,--export=ee |
| 14 | +WASM_EXTRA_LDFLAGS += -Wl,--export=rre,--export=ree,--export=res,--export=ru,--export=us,--export=ue |
| 15 | + |
| 16 | +.PHONY: optimize clean |
| 17 | + |
| 18 | +lib/lexer.wat: lib/lexer.wasm |
| 19 | + $(WASM2WAT) lib/lexer.wasm -o lib/lexer.wat |
| 20 | + |
| 21 | +lib/lexer.wasm: include-wasm/cjs-module-lexer.h src/lexer.c | lib/ |
| 22 | + $(WASM_CC) $(WASM_CFLAGS) $(WASM_EXTRA_CFLAGS) \ |
| 23 | + src/lexer.c -o lib/lexer.wasm \ |
| 24 | + $(WASM_LDFLAGS) $(WASM_EXTRA_LDFLAGS) |
| 25 | + |
| 26 | +lib/: |
| 27 | + @mkdir -p $@ |
11 | 28 |
|
12 | 29 | optimize: lib/lexer.wasm |
13 | | - ../binaryen/bin/wasm-opt -Oz lib/lexer.wasm -o lib/lexer.wasm |
| 30 | + $(WASM_OPT) -Oz lib/lexer.wasm -o lib/lexer.wasm |
14 | 31 |
|
15 | 32 | clean: |
16 | | - rm lib/* |
| 33 | + $(RM) lib/* |
0 commit comments