mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-24 17:06:18 +04:00
uppercase arguments in Makefile
This commit is contained in:
parent
ab06b2cd55
commit
f66c8d29cd
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -58,4 +58,4 @@ jobs:
|
||||
- name: Download prebuilt user image
|
||||
run: cd user && make sfsimg arch=${{ matrix.arch }} prebuilt=1 && cd ..
|
||||
- name: Build kernel
|
||||
run: cd kernel && make build arch=${{ matrix.arch }} && cd ..
|
||||
run: cd kernel && make build ARCH=${{ matrix.arch }} && cd ..
|
||||
|
@ -20,7 +20,6 @@ Supported architectures and boards:
|
||||
### Environment
|
||||
|
||||
* [Rust](https://www.rust-lang.org) toolchain
|
||||
* Cargo tools: [cargo-binutils](https://github.com/rust-embedded/cargo-binutils)
|
||||
* [QEMU](https://www.qemu.org) >= 4.1.0
|
||||
* [musl-based GCC toolchains](https://musl.cc/) (only for building [user programs](https://github.com/rcore-os/rcore-user))
|
||||
|
||||
@ -41,11 +40,13 @@ $ docker run -it -v $PWD:$PWD -w $PWD wangrunji0408/rcore
|
||||
```bash
|
||||
$ git clone https://github.com/rcore-os/rCore.git --recursive
|
||||
$ cd rCore/user
|
||||
$ make sfsimg prebuilt=1 arch={riscv32,riscv64,x86_64,aarch64,mipsel}
|
||||
$ make sfsimg prebuilt=1 arch=x86_64
|
||||
$ cd ../kernel
|
||||
$ make run arch={riscv32,riscv64,x86_64,aarch64,mipsel}
|
||||
$ make run ARCH=x86_64 LOG=info
|
||||
```
|
||||
|
||||
See [Makefile](kernel/Makefile) for more usages.
|
||||
|
||||
## Maintainers
|
||||
|
||||
| Module | Maintainer |
|
||||
|
@ -20,6 +20,7 @@ authors = [
|
||||
|
||||
[features]
|
||||
default = []
|
||||
board_qemu = []
|
||||
board_u540 = ["link_user"]
|
||||
board_k210 = ["link_user"]
|
||||
board_rocket_chip = ["link_user"]
|
||||
|
199
kernel/Makefile
199
kernel/Makefile
@ -11,37 +11,37 @@
|
||||
# make clean Clean
|
||||
#
|
||||
# Options:
|
||||
# arch = x86_64 | riscv32 | riscv64 | aarch64 | mipsel
|
||||
# d = int | in_asm | ... QEMU debug info
|
||||
# mode = debug | release
|
||||
# ARCH = x86_64 | riscv32 | riscv64 | aarch64 | mipsel
|
||||
# D = int | in_asm | ... QEMU debug info
|
||||
# MODE = debug | release
|
||||
# LOG = off | error | warn | info | debug | trace
|
||||
# USER_IMG = <sfsimg> image path of user programs
|
||||
# smp = 1 | 2 | ... SMP core number
|
||||
# graphic = on | off | console Enable/disable qemu graphical output, or print console to graphic output
|
||||
# board = none Running on QEMU
|
||||
# | pc Only available on x86_64, run on real pc
|
||||
# | u540 Only available on riscv64, run on HiFive U540, use Sv39
|
||||
# | k210 Only available on riscv64, run on K210, use Sv39
|
||||
# | rocket_chip Only available on riscv64, run on Rocket Chip, use Sv39
|
||||
# | raspi3 Only available on aarch64, run on Raspberry Pi 3 Model B/B+
|
||||
# net = on | off Only available on x86_64, enable NIC
|
||||
# pci_passthru = 0000:00:00.1 Only available on x86_64, passthrough the specified PCI device
|
||||
# init = /bin/ls Only available on riscv64, run specified program instead of user shell
|
||||
# extra_nic = on | off Only available on x86_64, add an additional e1000 nic
|
||||
# . extra_features = profile | ... Add additional features
|
||||
# USER_IMG = <sfsimg> Image path of user programs
|
||||
# SMP = 1 | 2 | ... SMP core number
|
||||
# GRAPHIC = on | off | console Enable/disable qemu graphical output, or print console to graphic output
|
||||
# BOARD = qemu Run on QEMU
|
||||
# | pc [ x86_64 only] Run on real pc
|
||||
# | u540 [riscv64 only] Run on HiFive U540, use Sv39
|
||||
# | k210 [riscv64 only] Run on K210, use Sv39
|
||||
# | rocket_chip [riscv64 only] Run on Rocket Chip, use Sv39
|
||||
# | raspi3 [aarch64 only] Run on Raspberry Pi 3 Model B/B+
|
||||
# NET = on | off [ x86_64 only] Enable NIC
|
||||
# PCI_PASSTHRU = 0000:00:00.1 [ x86_64 only] Passthrough the specified PCI device
|
||||
# INIT = /bin/ls [riscv64 only] Run specified program instead of user shell
|
||||
# EXTRA_NIC = on | off [ x86_64 only] Add an additional e1000 nic
|
||||
# FEATURES = profile | ... Add additional features
|
||||
|
||||
arch ?= riscv64
|
||||
mode ?= release
|
||||
ARCH ?= riscv64
|
||||
MODE ?= release
|
||||
LOG ?=
|
||||
graphic ?= off
|
||||
smp ?= 4
|
||||
pci_passthru ?=
|
||||
init ?=
|
||||
extra_nic ?= off
|
||||
GRAPHIC ?= off
|
||||
SMP ?= 4
|
||||
PCI_PASSTHRU ?=
|
||||
INIT ?=
|
||||
EXTRA_NIC ?= off
|
||||
|
||||
qemu := qemu-system-$(arch)
|
||||
target := $(arch)
|
||||
build_path := target/$(target)/$(mode)
|
||||
qemu := qemu-system-$(ARCH)
|
||||
target := $(ARCH)
|
||||
build_path := target/$(target)/$(MODE)
|
||||
kernel := $(build_path)/rcore
|
||||
kernel_img := $(build_path)/kernel.img
|
||||
ESP := $(build_path)/esp
|
||||
@ -51,55 +51,49 @@ user_dir := ../user
|
||||
|
||||
### export environments ###
|
||||
|
||||
export USER_IMG = $(user_dir)/build/$(arch).img
|
||||
export USER_QCOW2 = $(user_dir)/build/$(arch).qcow2
|
||||
export USER_IMG = $(user_dir)/build/$(ARCH).img
|
||||
export USER_QCOW2 = $(user_dir)/build/$(ARCH).qcow2
|
||||
|
||||
ifeq ($(arch), aarch64)
|
||||
board ?= raspi3
|
||||
else ifeq ($(arch), mipsel)
|
||||
board ?= malta
|
||||
ifeq ($(ARCH), aarch64)
|
||||
BOARD ?= raspi3
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
BOARD ?= malta
|
||||
else
|
||||
board ?= none
|
||||
BOARD ?= qemu
|
||||
endif
|
||||
|
||||
# currently only mipsel architecture and rocket-chip need DTB linked to the kernel
|
||||
ifeq ($(arch), mipsel)
|
||||
dtb := src/arch/$(arch)/board/$(board)/device.dtb
|
||||
ifeq ($(ARCH), mipsel)
|
||||
DTB := src/arch/$(ARCH)/board/$(BOARD)/device.dtb
|
||||
endif
|
||||
ifeq ($(board), rocket_chip)
|
||||
dtb := src/arch/riscv/board/$(board)/device.dtb
|
||||
ifeq ($(BOARD), rocket_chip)
|
||||
DTB := src/arch/riscv/board/$(BOARD)/device.dtb
|
||||
endif
|
||||
|
||||
# mipssim does not support SMP
|
||||
ifeq ($(board), mipssim)
|
||||
smp := 1
|
||||
ifeq ($(BOARD), mipssim)
|
||||
SMP := 1
|
||||
endif
|
||||
|
||||
export ARCH = $(arch)
|
||||
export BOARD = $(board)
|
||||
export SMP = $(smp)
|
||||
export DTB = $(dtb)
|
||||
|
||||
|
||||
### qemu options ###
|
||||
qemu_opts := \
|
||||
-smp cores=$(smp)
|
||||
-smp cores=$(SMP)
|
||||
qemu_net_opts :=
|
||||
|
||||
ifeq ($(arch), x86_64)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
qemu_opts += \
|
||||
-bios $(OVMF) \
|
||||
-drive format=raw,file=fat:rw:$(ESP) \
|
||||
-serial mon:stdio \
|
||||
-m 4G \
|
||||
-device isa-debug-exit
|
||||
ifeq ($(board), none)
|
||||
ifeq ($(BOARD), qemu)
|
||||
qemu_opts += \
|
||||
-drive format=qcow2,file=$(USER_QCOW2),media=disk,cache=writeback,id=sfsimg,if=none \
|
||||
-device ahci,id=ahci0 \
|
||||
-device ide-drive,drive=sfsimg,bus=ahci0.0
|
||||
endif
|
||||
ifeq ($(pci_passthru), )
|
||||
ifeq ($(PCI_PASSTHRU), )
|
||||
qemu_net_opts += \
|
||||
-netdev type=tap,id=net0,script=no,downscript=no \
|
||||
-device e1000e,netdev=net0
|
||||
@ -107,17 +101,17 @@ else
|
||||
qemu_opts += \
|
||||
-machine accel=kvm
|
||||
qemu_net_opts += \
|
||||
-device vfio-pci,host=$(pci_passthru)
|
||||
-device vfio-pci,host=$(PCI_PASSTHRU)
|
||||
qemu_ui_opts += \
|
||||
-vga std
|
||||
endif
|
||||
ifeq ($(extra_nic), on)
|
||||
ifeq ($(EXTRA_NIC), on)
|
||||
qemu_net_opts += \
|
||||
-netdev type=tap,id=net1,script=no,downscript=no \
|
||||
-device e1000e,netdev=net1
|
||||
endif
|
||||
|
||||
else ifeq ($(arch), riscv32)
|
||||
else ifeq ($(ARCH), riscv32)
|
||||
qemu_opts += \
|
||||
-machine virt \
|
||||
-serial mon:stdio \
|
||||
@ -131,8 +125,8 @@ qemu_net_opts += \
|
||||
-netdev type=tap,id=net0,script=no,downscript=no \
|
||||
-device virtio-net-device,netdev=net0
|
||||
|
||||
else ifeq ($(arch), riscv64)
|
||||
ifeq ($(board), u540)
|
||||
else ifeq ($(ARCH), riscv64)
|
||||
ifeq ($(BOARD), u540)
|
||||
qemu_opts += \
|
||||
-machine virt \
|
||||
-serial mon:stdio \
|
||||
@ -153,79 +147,78 @@ qemu_net_opts += \
|
||||
-netdev type=tap,id=net0,script=no,downscript=no \
|
||||
-device virtio-net-device,netdev=net0
|
||||
|
||||
else ifeq ($(arch), aarch64)
|
||||
else ifeq ($(ARCH), aarch64)
|
||||
qemu_opts += \
|
||||
-machine $(board) \
|
||||
-machine $(BOARD) \
|
||||
-smp 4 \
|
||||
-serial null -serial mon:stdio \
|
||||
-kernel $(kernel_img) \
|
||||
-drive file=$(USER_QCOW2),format=qcow2,id=sfs
|
||||
|
||||
else ifeq ($(arch), mipsel)
|
||||
ifeq ($(board), malta)
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
ifeq ($(BOARD), malta)
|
||||
qemu_opts += \
|
||||
-machine $(board) -device VGA \
|
||||
-machine $(BOARD) -device VGA \
|
||||
-serial null -serial null -serial mon:stdio \
|
||||
-kernel $(kernel_img)
|
||||
endif
|
||||
ifeq ($(board), mipssim)
|
||||
ifeq ($(BOARD), mipssim)
|
||||
qemu_opts += \
|
||||
-machine $(board) \
|
||||
-machine $(BOARD) \
|
||||
-serial mon:stdio \
|
||||
-kernel $(kernel_img)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef d
|
||||
qemu_opts += -d $(d)
|
||||
ifdef D
|
||||
qemu_opts += -d $(D)
|
||||
endif
|
||||
|
||||
ifeq ($(graphic), off)
|
||||
ifeq ($(GRAPHIC), off)
|
||||
qemu_opts += -nographic
|
||||
endif
|
||||
|
||||
ifeq ($(net), on)
|
||||
ifeq ($(NET), on)
|
||||
qemu_opts += $(qemu_net_opts)
|
||||
qemu := sudo $(qemu)
|
||||
endif
|
||||
|
||||
### build args ###
|
||||
ifeq ($(graphic), off)
|
||||
features += nographic
|
||||
ifeq ($(GRAPHIC), off)
|
||||
FEATURES += nographic
|
||||
endif
|
||||
|
||||
ifeq ($(graphic), console)
|
||||
features += consolegraphic
|
||||
ifeq ($(GRAPHIC), console)
|
||||
FEATURES += consolegraphic
|
||||
endif
|
||||
|
||||
ifneq ($(init), )
|
||||
features += run_cmdline
|
||||
ifneq ($(INIT), )
|
||||
FEATURES += run_cmdline
|
||||
endif
|
||||
|
||||
ifneq ($(board), none)
|
||||
features += board_$(board)
|
||||
endif
|
||||
FEATURES += board_$(BOARD)
|
||||
|
||||
features += $(extra_features)
|
||||
build_args := \
|
||||
-Z build-std=core,alloc \
|
||||
--target targets/$(target).json \
|
||||
--features "$(FEATURES)"
|
||||
|
||||
build_args := -Z build-std=core,alloc --target targets/$(target).json --features "$(features)"
|
||||
|
||||
ifeq ($(mode), release)
|
||||
ifeq ($(MODE), release)
|
||||
build_args += --release
|
||||
endif
|
||||
|
||||
### prefix ###
|
||||
ifeq ($(arch), x86_64)
|
||||
ifeq ($(uname), Darwin)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
ifeq ($(shell uname), Darwin)
|
||||
prefix := x86_64-linux-musl-
|
||||
endif
|
||||
else ifeq ($(arch), riscv32)
|
||||
else ifeq ($(ARCH), riscv32)
|
||||
prefix := riscv64-linux-musl-
|
||||
else ifeq ($(arch), riscv64)
|
||||
else ifeq ($(ARCH), riscv64)
|
||||
prefix := riscv64-linux-musl-
|
||||
else ifeq ($(arch), mipsel)
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
prefix ?= mipsel-linux-musln32-
|
||||
else ifeq ($(arch), aarch64)
|
||||
else ifeq ($(ARCH), aarch64)
|
||||
prefix ?= aarch64-linux-musl-
|
||||
endif
|
||||
|
||||
@ -256,7 +249,7 @@ justrun:
|
||||
|
||||
justtest:
|
||||
# unavailable now
|
||||
@#$(qemu) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(init) -serial file:../tests/stdout -monitor null
|
||||
@#$(qemu) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(INIT) -serial file:../tests/stdout -monitor null
|
||||
|
||||
debug: $(kernel) $(kernel_img)
|
||||
@$(qemu) $(qemu_opts) -s -S &
|
||||
@ -284,31 +277,31 @@ sym:
|
||||
### bootloader and kernel image ###
|
||||
|
||||
bootloader: $(kernel)
|
||||
ifeq ($(arch), x86_64)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
@cd ../rboot && make build
|
||||
endif
|
||||
|
||||
$(kernel_img): kernel bootloader
|
||||
ifeq ($(arch), x86_64)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
@mkdir -p $(ESP)/EFI/rCore $(ESP)/EFI/Boot
|
||||
@cp ../rboot/target/x86_64-unknown-uefi/release/rboot.efi $(ESP)/EFI/Boot/BootX64.efi
|
||||
@cp ../rboot/rboot.conf $(ESP)/EFI/Boot/rboot.conf
|
||||
@cp $(kernel) $(ESP)/EFI/rCore/kernel.elf
|
||||
else ifeq ($(arch), $(filter $(arch), riscv32 riscv64))
|
||||
else ifeq ($(ARCH), $(filter $(ARCH), riscv32 riscv64))
|
||||
@$(objcopy) $(kernel) --strip-all -O binary $@
|
||||
else ifeq ($(arch), aarch64)
|
||||
else ifeq ($(ARCH), aarch64)
|
||||
@$(objcopy) $(kernel) --strip-all -O binary $@
|
||||
else ifeq ($(arch), mipsel)
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
# qemu-system-mipsel accepts ELF file only, so objcopy is not needed
|
||||
@$(strip) $(kernel) -o $@
|
||||
endif
|
||||
|
||||
kernel: $(dtb)
|
||||
@echo Building $(arch) kernel
|
||||
ifeq ($(arch), $(filter $(arch), riscv32 riscv64))
|
||||
ifeq ($(board), k210)
|
||||
kernel: $(DTB)
|
||||
@echo Building $(ARCH) kernel
|
||||
ifeq ($(ARCH), $(filter $(ARCH), riscv32 riscv64))
|
||||
ifeq ($(BOARD), k210)
|
||||
@cp src/arch/riscv/board/k210/linker.ld src/arch/riscv/boot/linker64.ld
|
||||
else ifeq ($(board), rocket_chip)
|
||||
else ifeq ($(BOARD), rocket_chip)
|
||||
@cp src/arch/riscv/board/rocket_chip/linker.ld src/arch/riscv/boot/linker64.ld
|
||||
else
|
||||
@cp src/arch/riscv/board/u540/linker.ld src/arch/riscv/boot/linker64.ld
|
||||
@ -316,11 +309,11 @@ endif
|
||||
@-patch -p0 -N -b \
|
||||
$(sysroot)/lib/rustlib/src/rust/src/libcore/sync/atomic.rs \
|
||||
src/arch/riscv/atomic.patch
|
||||
else ifeq ($(arch), mipsel)
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
@for file in context entry trap ; do \
|
||||
$(hostcc) -Dboard_$(board) -E src/arch/$(arch)/boot/$${file}.S -o src/arch/$(arch)/boot/$${file}.gen.s ; \
|
||||
$(hostcc) -Dboard_$(BOARD) -E src/arch/$(ARCH)/boot/$${file}.S -o src/arch/$(ARCH)/boot/$${file}.gen.s ; \
|
||||
done
|
||||
$(hostcc) -Dboard_$(board) -E src/arch/$(arch)/boot/linker.ld.S -o src/arch/$(arch)/boot/linker.ld
|
||||
$(hostcc) -Dboard_$(BOARD) -E src/arch/$(ARCH)/boot/linker.ld.S -o src/arch/$(ARCH)/boot/linker.ld
|
||||
endif
|
||||
@cargo build $(build_args)
|
||||
|
||||
@ -331,7 +324,7 @@ sfsimg:
|
||||
|
||||
|
||||
### install ###
|
||||
ifeq ($(board), raspi3)
|
||||
ifeq ($(BOARD), raspi3)
|
||||
sd_card ?=
|
||||
|
||||
ifeq ($(shell uname), Darwin)
|
||||
@ -349,7 +342,7 @@ endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(board), u540)
|
||||
ifeq ($(BOARD), u540)
|
||||
.PHONY:
|
||||
install: $(kernel_img)
|
||||
@$(objcopy) -S -O binary ../tools/opensbi/fu540.elf $(build_path)/bin
|
||||
@ -357,7 +350,7 @@ install: $(kernel_img)
|
||||
@../tools/u540/mkimg.sh $(build_path)/bin $(build_path)/u540.img
|
||||
endif
|
||||
|
||||
ifeq ($(board), k210)
|
||||
ifeq ($(BOARD), k210)
|
||||
.PHONY:
|
||||
install: $(kernel_img)
|
||||
@$(objcopy) -S -O binary ../tools/opensbi/k210.elf $(build_path)/k210.img
|
||||
@ -367,4 +360,4 @@ endif
|
||||
|
||||
.PHONY:
|
||||
addr2line:
|
||||
@python3.7 ../tools/addr2line.py $(prefix)addr2line $(arch) $(mode)
|
||||
@python3.7 ../tools/addr2line.py $(prefix)addr2line $(ARCH) $(MODE)
|
||||
|
@ -10,7 +10,6 @@ fn main() {
|
||||
println!("cargo:rerun-if-env-changed=USER_IMG");
|
||||
|
||||
let arch: String = std::env::var("ARCH").unwrap();
|
||||
let _board: String = std::env::var("BOARD").unwrap();
|
||||
if let Ok(user_img) = std::env::var("USER_IMG") {
|
||||
println!("cargo:rerun-if-changed={}", user_img);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user