2020-11-18 14:29:53 +04:00
|
|
|
TARGET := riscv64gc-unknown-none-elf
|
2020-12-02 05:40:00 +04:00
|
|
|
MODE := release
|
2020-11-18 14:29:53 +04:00
|
|
|
APP_DIR := src/bin
|
|
|
|
TARGET_DIR := target/$(TARGET)/$(MODE)
|
2020-11-19 00:33:06 +04:00
|
|
|
APPS := $(wildcard $(APP_DIR)/*.rs)
|
|
|
|
ELFS := $(patsubst $(APP_DIR)/%.rs, $(TARGET_DIR)/%, $(APPS))
|
|
|
|
BINS := $(patsubst $(APP_DIR)/%.rs, $(TARGET_DIR)/%.bin, $(APPS))
|
2020-11-18 14:29:53 +04:00
|
|
|
|
|
|
|
OBJDUMP := rust-objdump --arch-name=riscv64
|
|
|
|
OBJCOPY := rust-objcopy --binary-architecture=riscv64
|
2022-06-23 22:25:30 +04:00
|
|
|
CP := cp
|
|
|
|
|
|
|
|
TEST ?=
|
2020-11-18 14:29:53 +04:00
|
|
|
|
2020-11-28 21:31:36 +04:00
|
|
|
elf: $(APPS)
|
2020-12-02 05:40:00 +04:00
|
|
|
@cargo build --release
|
2022-06-23 22:25:30 +04:00
|
|
|
ifeq ($(TEST), 1)
|
|
|
|
@$(CP) $(TARGET_DIR)/usertests $(TARGET_DIR)/initproc
|
|
|
|
endif
|
2020-11-18 14:29:53 +04:00
|
|
|
|
|
|
|
binary: elf
|
2023-02-01 17:16:45 +04:00
|
|
|
@$(foreach elf, $(ELFS), $(OBJCOPY) $(elf) --strip-all -O binary $(patsubst $(TARGET_DIR)/%, $(TARGET_DIR)/%.bin, $(elf));)
|
2020-11-18 14:29:53 +04:00
|
|
|
|
|
|
|
build: binary
|
2020-11-28 12:22:29 +04:00
|
|
|
|
|
|
|
clean:
|
2020-11-29 00:01:38 +04:00
|
|
|
@cargo clean
|
|
|
|
|
2021-02-23 23:34:59 +04:00
|
|
|
.PHONY: elf binary build clean
|