-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (26 loc) · 791 Bytes
/
Makefile
File metadata and controls
40 lines (26 loc) · 791 Bytes
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
include ../../toolchains/wali.mk
.PHONY: dir clean all elf
# For ELF
ELF_LFLAGS := -lm -lpthread
WASM_DIR := wasm
ELF_DIR := elf
OS := $(shell uname -s)
SRC_C := $(wildcard *.c)
# Generate ELF files only on linux platforms
ifeq ($(OS),Linux)
SRC_O := $(SRC_C:.c=.o)
endif
SRC_WASM := $(SRC_C:.c=.wasm)
HOST_PLATFORM := $(shell $(WALI_LLVM_BIN_DIR)/llvm-config --host-target)
all: dir $(SRC_WASM) $(SRC_O)
dir:
mkdir -p $(WASM_DIR)
mkdir -p $(ELF_DIR)
%.o: %.c
$(WALI_CC) --target=$(HOST_PLATFORM) -D_GNU_SOURCE -O1 -o $(ELF_DIR)/$* $< $(ELF_LFLAGS)
%.wasm: %.c
$(WALI_CC) $(WALI_COMMON_CFLAGS) -D_GNU_SOURCE $(WALI_COMMON_LDFLAGS) -o $(WASM_DIR)/$*.wasm $<
wasm2wat --enable-threads $(WASM_DIR)/$*.wasm -o $(WASM_DIR)/$*.wat
clean:
rm -rf $(WASM_DIR)
rm -rf $(ELF_DIR)