makefile: add compilation steps for host program
This commit is contained in:
@ -1,33 +1,67 @@
|
|||||||
WAMRC := /opt/wamr-wamrc/wamrc
|
# Paths
|
||||||
IWASM := /opt/wamr-iwasm/iwasm
|
WAMR_ROOT := /opt/wamr
|
||||||
|
WAMRC := /opt/wamr-wamrc/wamrc
|
||||||
|
IWASM := /opt/wamr-iwasm/iwasm
|
||||||
|
WAMRC_LIB := /opt/wamr-libvmlib
|
||||||
|
IWASM_LIB := /opt/wamr-libiwasm
|
||||||
|
|
||||||
WASI_SDK := /opt/wasi-sdk
|
WASI_ROOT := /opt/wasi-sdk
|
||||||
SYSROOT := $(WASI_SDK)/share/wasi-sysroot
|
WASI_CC := $(WASI_ROOT)/bin/clang
|
||||||
CLANG := $(WASI_SDK)/bin/clang
|
WASI_CFLAGS := --target=wasm32-wasi \
|
||||||
CFLAGS := --target=wasm32-wasi \
|
--sysroot=$(WASI_ROOT)/share/wasi-sysroot \
|
||||||
--sysroot=$(SYSROOT) \
|
-O0 -g -Wall
|
||||||
-O2
|
|
||||||
|
|
||||||
SRCS := $(wildcard *.c)
|
# Embedding
|
||||||
WASMS := $(SRCS:.c=.wasm)
|
EMBED_CC := gcc
|
||||||
AOTS := $(WASMS:.wasm=.aot)
|
EMBED_INCL := -I$(WAMR_ROOT)/core/iwasm/include \
|
||||||
|
-I$(WAMR_ROOT)/core/iwasm/common \
|
||||||
|
-I$(WAMR_ROOT)/core/shared/platform/linux \
|
||||||
|
-I$(WAMR_ROOT)/core/shared/utils \
|
||||||
|
-I$(WAMR_ROOT)/core/shared/utils/uncommon
|
||||||
|
EMBED_SOURCES := $(WAMR_ROOT)/core/shared/utils/uncommon/bh_read_file.c
|
||||||
|
EMBED_CFLAGS := -O0 -g -Wall $(EMBED_INCL) $(EMBED_SOURCES)
|
||||||
|
AOT_LDFLAGS := -Wl,-rpath,$(WAMRC_LIB)
|
||||||
|
AOT_LDLIBS := -L$(WAMRC_LIB) -lvmlib -lm
|
||||||
|
INTER_LDFLAGS := -Wl,-rpath,$(IWASM_LIB)
|
||||||
|
INTER_LDLIBS := -L$(IWASM_LIB) -liwasm -lm
|
||||||
|
|
||||||
.PHONY: build-all build-wasms build-aots clean
|
# Files
|
||||||
|
SRCS := $(wildcard *.c)
|
||||||
|
WASMS := $(SRCS:.c=.wasm)
|
||||||
|
AOTS := $(WASMS:.wasm=.aot)
|
||||||
|
OBJS := $(SRCS:.c=.o)
|
||||||
|
DEPS := $(OBJS:.o=.d)
|
||||||
|
|
||||||
build-all: build-wasms build-aots
|
|
||||||
|
.PHONY: all build-wasms build-aots clean embed_host
|
||||||
|
|
||||||
|
all: build-wasms build-aots embed_host
|
||||||
|
|
||||||
# Compile to wasm bytecode using wasi-sdk
|
# Compile to wasm bytecode using wasi-sdk
|
||||||
build-wasms: $(WASMS)
|
build-wasms: $(WASMS)
|
||||||
|
|
||||||
%.wasm: %.c
|
%.wasm: %.c
|
||||||
$(CLANG) $(CFLAGS) $< -o $@
|
$(WASI_CC) $(WASI_CFLAGS) $< -o $@
|
||||||
|
|
||||||
# Compile ahead-of-time module using wamrc
|
# Compile ahead-of-time module using wamrc
|
||||||
build-aots: $(AOTS)
|
build-aots: $(AOTS)
|
||||||
|
|
||||||
%.aot: %.wasm
|
%.aot: %.wasm
|
||||||
$(WAMRC) -o $@ $<
|
$(WAMRC) -o $@ $<
|
||||||
|
# $(WAMRC) --enable-wasi -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.wasm
|
rm -f *.wasm
|
||||||
rm -f *.aot
|
rm -f *.aot
|
||||||
|
rm -f *.d
|
||||||
|
rm -f *.o
|
||||||
|
|
||||||
|
# Compile to C-embedded
|
||||||
|
# embed: $(OBJS)
|
||||||
|
# $(EMBED_CC) $(OBJS) -o embed $(AOT_LDFLAGS) $(AOT_LDLIBS)
|
||||||
|
|
||||||
|
# %.o: %.c
|
||||||
|
# $(EMBED_CC) $(EMBED_CFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
embed_host:
|
||||||
|
$(EMBED_CC) $(EMBED_CFLAGS) embed/host.c -o host $(INTER_LDFLAGS) $(INTER_LDLIBS)
|
||||||
|
|||||||
Reference in New Issue
Block a user