diff --git a/kernel/Makefile b/kernel/Makefile index 3f4f76b..7771d54 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -32,11 +32,9 @@ user_dir := ../user user_bin_path := $(user_dir)/target/$(arch)-ucore/debug user_bins := $(patsubst $(user_bin_path)/%.d, $(user_bin_path)/%, $(wildcard $(user_bin_path)/*.d)) user_obj := build/$(arch)/user.o -sfsroot := $(user_dir)/build/sfsroot-$(arch) -sfsimg := $(user_dir)/build/user-$(arch).img export ARCH = $(arch) -export SFSIMG = $(sfsimg) +export SFSIMG = $(user_dir)/build/user-$(arch).img ### qemu options ### ifeq ($(arch), x86_64) @@ -105,7 +103,7 @@ cc := $(prefix)gcc as := $(prefix)as gdb := $(prefix)gdb -.PHONY: all clean run build asm doc justrun debug kernel install +.PHONY: all clean run build asm doc justrun debug kernel sfsimg install all: kernel @@ -116,12 +114,12 @@ clean: doc: @cargo rustdoc -- --document-private-items -run: build justrun +run: build sfsimg justrun -justrun: $(sfsimg) +justrun: @qemu-system-$(arch) $(qemu_opts) || [ $$? -eq 11 ] # run qemu and assert it exit 11 -debug: $(kernel) $(bin) $(sfsimg) +debug: $(kernel) $(bin) @qemu-system-$(arch) $(qemu_opts) -s -S & @sleep 1 @$(gdb) $(kernel) -x ../tools/gdbinit @@ -166,7 +164,7 @@ ifeq ($(arch), x86_64) kernel: @bootimage build $(build_args) else -kernel: $(sfsimg) +kernel: sfsimg ifeq ($(arch), riscv32) @-patch -p0 -N -b \ $(shell rustc --print sysroot)/lib/rustlib/src/rust/src/libcore/sync/atomic.rs \ @@ -178,7 +176,7 @@ endif ### user programs ### -$(sfsimg): $(sfsroot) +sfsimg: @cd $(user_dir) && make sfsimg # make user.o from binary files diff --git a/user/Makefile b/user/Makefile index 9b0648b..6c5f860 100644 --- a/user/Makefile +++ b/user/Makefile @@ -35,16 +35,20 @@ build-c: build: build-rust build-c +$(user_rust_bins): build-rust + +$(user_c_bins): 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)/ +$(sfsroot): $(user_bins) + @mkdir -p $@ + @cp $^ $@/ -$(sfsimg): mksfs $(sfsroot) +$(sfsimg): $(user_bins) $(sfsroot) | mksfs @echo Creating SFS image at $@ @$(mksfs) zip $(sfsroot) $@