user: update Makefiles

master
equation314 6 years ago
parent e86229cb71
commit 710b6d1a28

@ -32,11 +32,9 @@ user_dir := ../user
user_bin_path := $(user_dir)/target/$(arch)-ucore/debug 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_bins := $(patsubst $(user_bin_path)/%.d, $(user_bin_path)/%, $(wildcard $(user_bin_path)/*.d))
user_obj := build/$(arch)/user.o user_obj := build/$(arch)/user.o
sfsroot := $(user_dir)/build/sfsroot-$(arch)
sfsimg := $(user_dir)/build/user-$(arch).img
export ARCH = $(arch) export ARCH = $(arch)
export SFSIMG = $(sfsimg) export SFSIMG = $(user_dir)/build/user-$(arch).img
### qemu options ### ### qemu options ###
ifeq ($(arch), x86_64) ifeq ($(arch), x86_64)
@ -105,7 +103,7 @@ cc := $(prefix)gcc
as := $(prefix)as as := $(prefix)as
gdb := $(prefix)gdb 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 all: kernel
@ -116,12 +114,12 @@ clean:
doc: doc:
@cargo rustdoc -- --document-private-items @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 @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 & @qemu-system-$(arch) $(qemu_opts) -s -S &
@sleep 1 @sleep 1
@$(gdb) $(kernel) -x ../tools/gdbinit @$(gdb) $(kernel) -x ../tools/gdbinit
@ -166,7 +164,7 @@ ifeq ($(arch), x86_64)
kernel: kernel:
@bootimage build $(build_args) @bootimage build $(build_args)
else else
kernel: $(sfsimg) kernel: sfsimg
ifeq ($(arch), riscv32) ifeq ($(arch), riscv32)
@-patch -p0 -N -b \ @-patch -p0 -N -b \
$(shell rustc --print sysroot)/lib/rustlib/src/rust/src/libcore/sync/atomic.rs \ $(shell rustc --print sysroot)/lib/rustlib/src/rust/src/libcore/sync/atomic.rs \
@ -178,7 +176,7 @@ endif
### user programs ### ### user programs ###
$(sfsimg): $(sfsroot) sfsimg:
@cd $(user_dir) && make sfsimg @cd $(user_dir) && make sfsimg
# make user.o from binary files # make user.o from binary files

@ -35,16 +35,20 @@ build-c:
build: build-rust build-c build: build-rust build-c
$(user_rust_bins): build-rust
$(user_c_bins): build-c
mksfs: mksfs:
ifeq ($(shell which $(mksfs)),) ifeq ($(shell which $(mksfs)),)
@cargo install --git https://github.com/wangrunji0408/SimpleFileSystem-Rust --features="std" @cargo install --git https://github.com/wangrunji0408/SimpleFileSystem-Rust --features="std"
endif endif
$(sfsroot): build $(sfsroot): $(user_bins)
@mkdir -p $(sfsroot)/ @mkdir -p $@
@cp $(user_bins) $(sfsroot)/ @cp $^ $@/
$(sfsimg): mksfs $(sfsroot) $(sfsimg): $(user_bins) $(sfsroot) | mksfs
@echo Creating SFS image at $@ @echo Creating SFS image at $@
@$(mksfs) zip $(sfsroot) $@ @$(mksfs) zip $(sfsroot) $@

Loading…
Cancel
Save