mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-22 01:16:26 +04:00
30 lines
718 B
Makefile
30 lines
718 B
Makefile
TARGET := riscv64gc-unknown-none-elf
|
|
MODE := release
|
|
APP_DIR := src/bin
|
|
TARGET_DIR := target/$(TARGET)/$(MODE)
|
|
APPS := $(wildcard $(APP_DIR)/*.rs)
|
|
ELFS := $(patsubst $(APP_DIR)/%.rs, $(TARGET_DIR)/%, $(APPS))
|
|
BINS := $(patsubst $(APP_DIR)/%.rs, $(TARGET_DIR)/%.bin, $(APPS))
|
|
|
|
OBJDUMP := rust-objdump --arch-name=riscv64
|
|
OBJCOPY := rust-objcopy --binary-architecture=riscv64
|
|
CP := cp
|
|
|
|
TEST ?=
|
|
|
|
elf: $(APPS)
|
|
@cargo build --release
|
|
ifeq ($(TEST), 1)
|
|
@$(CP) $(TARGET_DIR)/usertests $(TARGET_DIR)/initproc
|
|
endif
|
|
|
|
binary: elf
|
|
@$(foreach elf, $(ELFS), $(OBJCOPY) $(elf) --strip-all -O binary $(patsubst $(TARGET_DIR)/%, $(TARGET_DIR)/%.bin, $(elf));)
|
|
|
|
build: binary
|
|
|
|
clean:
|
|
@cargo clean
|
|
|
|
.PHONY: elf binary build clean
|