-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
38 lines (29 loc) · 992 Bytes
/
Makefile
File metadata and controls
38 lines (29 loc) · 992 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
MAKEFLAGS += -j$(shell nproc)
USR_DIR = ./example
BUILD_DIR = ./build
USRS = $(wildcard $(USR_DIR)/*.c)
SRCS = $(wildcard ./src/*.c)
USER_OBJS = $(patsubst $(USR_DIR)/%.c,$(BUILD_DIR)/%.so,$(USRS))
# Define the compiler and flags
CC = gcc
CFLAGS = -I./include -shared -fPIC -Og -Wno-unused-result -ggdb3 -Wall
LDFLAGS = -L$(BUILD_DIR) -lmicrokit -Wl,-rpath,$(BUILD_DIR)
.PHONY: all clean microkit
all: $(BUILD_DIR)/libmicrokit.so $(USER_OBJS) microkit
# Build the shared library from C sources
$(BUILD_DIR)/libmicrokit.so: $(SRCS) | $(BUILD_DIR)
$(CC) $(CFLAGS) -o $@ $^
# Build user objects from example C files
$(BUILD_DIR)/%.so: $(USR_DIR)/%.c $(BUILD_DIR)/libmicrokit.so | $(BUILD_DIR)
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
$(BUILD_DIR):
mkdir -p $@
# Assumes Cargo.toml and src/main.rs exist in the project root.
microkit:
cargo build
cp target/debug/linux_microkit .
clean:
rm -f $(BUILD_DIR)/libmicrokit.so microkit
rm -rf $(BUILD_DIR)
rm -f linux_microkit
cargo clean