update Makefile

master
WangRunji 6 years ago
parent b3a80ba571
commit a74b893bd2

@ -12,73 +12,71 @@
# d = int | in_asm | ... QEMU debug info # d = int | in_asm | ... QEMU debug info
# mode = debug | release # mode = debug | release
# LOG = off | error | warn | info | debug | trace # LOG = off | error | warn | info | debug | trace
# smp SMP core number # smp = 1 | 2 | ... SMP core number
# board = fpga Only available on riscv32, build without bbl, run on board # board = fpga Only available on riscv32, build without bbl, run on board
# | raspi3 Only available on aarch64, run on Raspberry Pi 3 Model B/B+ # | raspi3 Only available on aarch64, run on Raspberry Pi 3 Model B/B+
# nommu Only available on riscv32, build for M-Mode, without MMU
arch ?= riscv32 arch ?= riscv32
board ?= raspi3 board ?= raspi3
mode ?= debug mode ?= debug
LOG ?= debug LOG ?= debug
smp ?= 4 smp ?= 4
nommu ?=
target := $(arch)-blog_os target := $(arch)-blog_os
kernel := target/$(target)/$(mode)/ucore kernel := target/$(target)/$(mode)/ucore
bin := target/$(target)/$(mode)/kernel.bin bin := target/$(target)/$(mode)/kernel.bin
bootimage := target/$(target)/bootimage.bin bootimage := target/$(target)/bootimage.bin
user_bin_path := ../user/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
SFSIMG := ../user/img/ucore-i386-pic.img
### qemu options ### ### qemu options ###
ifeq ($(arch), x86_64)
qemu_opts := \ qemu_opts := \
-drive format=raw,file=$(bootimage) \
-drive format=raw,file=$(SFSIMG),media=disk,cache=writeback \
-smp cores=$(smp) \ -smp cores=$(smp) \
-serial mon:stdio \
-device isa-debug-exit \
-nographic -nographic
ifeq ($(arch), x86_64)
qemu_opts += \
-drive format=raw,file=$(bootimage) \
-drive format=raw,file="../user/img/ucore-i386-pic.img",media=disk,cache=writeback \
-serial mon:stdio \
-device isa-debug-exit
else ifeq ($(arch), riscv32) else ifeq ($(arch), riscv32)
qemu_opts := \ qemu_opts += \
-machine virt \ -machine virt \
-kernel $(bin) \ -kernel $(bin)
-nographic \
-smp cores=$(smp)
ifdef nommu ifdef nommu
qemu_opts := $(qemu_opts) -cpu rv32imacu-nommu qemu_opts += -cpu rv32imacu-nommu
endif endif
else ifeq ($(arch), aarch64) else ifeq ($(arch), aarch64)
qemu_opts := \ qemu_opts += \
-machine $(board) \ -machine $(board) \
-serial null -serial mon:stdio \ -serial null -serial mon:stdio \
-nographic \ -kernel $(bin)
-kernel $(bin) \
-smp cores=$(smp)
endif endif
ifdef d ifdef d
qemu_opts := $(qemu_opts) -d $(d) qemu_opts += -d $(d)
endif endif
### build args ### ### build args ###
ifeq ($(arch), riscv32) ifeq ($(arch), riscv32)
ifeq ($(board), fpga) ifeq ($(board), fpga)
features := $(features) no_bbl features += no_bbl
endif endif
endif endif
ifdef nommu ifdef nommu
features := $(features) no_mmu features += no_mmu
bbl_m_mode := --enable-boot-machine
endif endif
features := $(features) board_$(board) features += board_$(board)
build_args := --target $(target).json --features "$(features)" build_args := --target $(target).json --features "$(features)"
ifeq ($(mode), release) ifeq ($(mode), release)
build_args := $(build_args) --release build_args += --release
endif endif
@ -146,6 +144,7 @@ else
mkdir -p build && \ mkdir -p build && \
cd build && \ cd build && \
../configure \ ../configure \
$(bbl_m_mode) \
--with-arch=rv32imac \ --with-arch=rv32imac \
--disable-fp-emulation \ --disable-fp-emulation \
--host=riscv64-unknown-elf \ --host=riscv64-unknown-elf \
@ -167,12 +166,6 @@ else
@CC=$(cc) cargo xbuild $(build_args) @CC=$(cc) cargo xbuild $(build_args)
endif endif
# make user.o from binary files
$(user_obj): $(user_bins)
@cd $(user_bin_path) && \
$(ld) -o $(abspath $@) $(patsubst %, -b binary %, $(notdir $(user_bins)))
### install ### ### install ###
ifeq ($(board), raspi3) ifeq ($(board), raspi3)

Loading…
Cancel
Save