1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-23 08:26:17 +04:00
rCore/user/Makefile

56 lines
1.1 KiB
Makefile
Raw Normal View History

2018-11-28 20:39:44 +04:00
# arch = {riscv32, x86_64, aarch64}
# mode = {debug, release}
arch ?= riscv32
mode ?= debug
2018-07-13 18:17:24 +04:00
2018-11-28 20:39:44 +04:00
rust_src_dir := src/bin
rust_bin_path := target/$(arch)-ucore/$(mode)
user_rust_bins := $(patsubst $(rust_src_dir)/%.rs, $(rust_bin_path)/%, $(wildcard $(rust_src_dir)/*.rs))
c_src_dir :=
c_bin_path :=
user_c_bins :=
user_bins := $(user_rust_bins) $(user_c_bins)
build_path := build
sfsroot := $(build_path)/sfsroot-$(arch)
sfsimg := $(build_path)/user-$(arch).img
mksfs := mksfs
build_args := --target $(arch)-ucore.json
ifeq ($(mode), release)
build_args := $(build_args) --release
endif
.PHONY: all clean build-rust build-c build mksfs sfsimg
all: $(sfsimg)
build-rust:
@echo Building user rust programs
@cargo xbuild $(build_args)
build-c:
@echo Building user C programs
build: build-rust build-c
mksfs:
ifeq ($(shell which $(mksfs)),)
@cargo install --git https://github.com/wangrunji0408/SimpleFileSystem-Rust --features="std"
endif
$(sfsroot): build
@mkdir -p $(sfsroot)/
@cp $(user_bins) $(sfsroot)/
$(sfsimg): mksfs $(sfsroot)
@echo Creating SFS image at $@
@$(mksfs) zip $(sfsroot) $@
sfsimg: $(sfsimg)
clean:
@cargo clean
@rm -rf $(build_path)