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

60 lines
1.2 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
2018-12-02 15:51:52 +04:00
$(user_rust_bins): build-rust
$(user_c_bins): build-c
2018-11-28 20:39:44 +04:00
mksfs:
ifeq ($(shell which $(mksfs)),)
@cargo install --git https://github.com/wangrunji0408/SimpleFileSystem-Rust --features="std"
endif
2018-12-02 15:51:52 +04:00
$(sfsroot): $(user_bins)
@mkdir -p $@
@cp $^ $@/
2018-11-28 20:39:44 +04:00
2018-12-02 15:51:52 +04:00
$(sfsimg): $(user_bins) $(sfsroot) | mksfs
2018-11-28 20:39:44 +04:00
@echo Creating SFS image at $@
@$(mksfs) zip $(sfsroot) $@
sfsimg: $(sfsimg)
clean:
@cargo clean
@rm -rf $(build_path)