Reformat makefile

master
Harry Cheng 5 years ago
parent 185fb6e891
commit 8fa7a8c2ad

@ -98,133 +98,134 @@ export DTB = $(dtb)
qemu_opts := \ qemu_opts := \
-smp cores=$(smp) -smp cores=$(smp)
qemu_net_opts := qemu_net_opts :=
qemu_ui_opts := qemu_ui_opts :=
ifeq ($(arch), x86_64) ifeq ($(arch), x86_64)
qemu_opts += \ qemu_opts += \
-drive format=raw,file=$(bootimage) \ -drive format=raw,file=$(bootimage) \
-serial mon:stdio \ -serial mon:stdio \
-m 4G \ -m 4G \
-device isa-debug-exit -device isa-debug-exit
ifeq ($(board), none) ifeq ($(board), none)
qemu_opts += \ qemu_opts += \
-drive format=qcow2,file=$(SFSIMG),media=disk,cache=writeback,id=sfsimg,if=none \ -drive format=qcow2,file=$(SFSIMG),media=disk,cache=writeback,id=sfsimg,if=none \
-device ahci,id=ahci0 \ -device ahci,id=ahci0 \
-device ide-drive,drive=sfsimg,bus=ahci0.0 -device ide-drive,drive=sfsimg,bus=ahci0.0
endif endif
ifeq ($(pci_passthru), )
qemu_net_opts += \ ifeq ($(pci_passthru), )
-netdev type=tap,id=net0,script=no,downscript=no \ qemu_net_opts += \
-device e1000e,netdev=net0 -netdev type=tap,id=net0,script=no,downscript=no \
else -device e1000e,netdev=net0
qemu_opts += \ else
-machine accel=kvm qemu_opts += \
qemu_net_opts += \ -machine accel=kvm
-device vfio-pci,host=$(pci_passthru) qemu_net_opts += \
qemu_ui_opts += \ -device vfio-pci,host=$(pci_passthru)
-vga std qemu_ui_opts += \
endif -vga std
ifeq ($(extra_nic), on) endif
qemu_net_opts += \
-netdev type=tap,id=net1,script=no,downscript=no \ ifeq ($(extra_nic), on)
-device e1000e,netdev=net1 qemu_net_opts += \
endif -netdev type=tap,id=net1,script=no,downscript=no \
-device e1000e,netdev=net1
endif
else ifeq ($(arch), riscv32) else ifeq ($(arch), riscv32)
qemu_opts += \ qemu_opts += \
-machine virt \ -machine virt \
-serial mon:stdio \ -serial mon:stdio \
-kernel ../tools/opensbi/virt_rv32.elf \ -kernel ../tools/opensbi/virt_rv32.elf \
-device loader,addr=0x80400000,file=$(kernel_img) \ -device loader,addr=0x80400000,file=$(kernel_img) \
-drive file=$(SFSIMG),format=qcow2,id=sfs \ -drive file=$(SFSIMG),format=qcow2,id=sfs \
-device virtio-blk-device,drive=sfs -device virtio-blk-device,drive=sfs
qemu_net_opts += \ qemu_net_opts += \
-netdev type=tap,id=net0,script=no,downscript=no \ -netdev type=tap,id=net0,script=no,downscript=no \
-device virtio-net-device,netdev=net0 -device virtio-net-device,netdev=net0
qemu_ui_opts += \ qemu_ui_opts += \
-device virtio-gpu-device \ -device virtio-gpu-device \
-device virtio-mouse-device -device virtio-mouse-device
else ifeq ($(arch), riscv64) else ifeq ($(arch), riscv64)
ifeq ($(board), u540) ifeq ($(board), u540)
qemu_opts += \ qemu_opts += \
-machine virt \ -machine virt \
-serial mon:stdio \ -serial mon:stdio \
-kernel ../tools/opensbi/fu540.elf \ -kernel ../tools/opensbi/fu540.elf \
-device loader,addr=0x80200000,file=$(kernel_img) -device loader,addr=0x80200000,file=$(kernel_img)
else else
qemu_opts += \ qemu_opts += \
-machine virt \ -machine virt \
-serial mon:stdio \ -serial mon:stdio \
-kernel ../tools/opensbi/virt_rv64.elf \ -kernel ../tools/opensbi/virt_rv64.elf \
-device loader,addr=0x80200000,file=$(kernel_img) \ -device loader,addr=0x80200000,file=$(kernel_img) \
-drive file=$(SFSIMG),format=qcow2,id=sfs \ -drive file=$(SFSIMG),format=qcow2,id=sfs \
-device virtio-blk-device,drive=sfs -device virtio-blk-device,drive=sfs
endif endif
qemu_net_opts += \
-netdev type=tap,id=net0,script=no,downscript=no \ qemu_net_opts += \
-device virtio-net-device,netdev=net0 -netdev type=tap,id=net0,script=no,downscript=no \
qemu_ui_opts += \ -device virtio-net-device,netdev=net0
-device virtio-gpu-device \ qemu_ui_opts += \
-device virtio-mouse-device -device virtio-gpu-device \
-device virtio-mouse-device
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 \
-kernel $(kernel_img) -kernel $(kernel_img)
ifneq ($(u_boot), ) ifneq ($(u_boot), )
qemu_opts += \ qemu_opts += \
-sd $(bootloader) -sd $(bootloader)
endif endif
else ifeq ($(arch), mipsel) else ifeq ($(arch), mipsel)
ifeq ($(board), malta) ifeq ($(board), malta)
qemu_opts += \ qemu_opts += \
-machine $(board) -device VGA \ -machine $(board) -device VGA \
-serial null -serial null -serial mon:stdio \ -serial null -serial null -serial mon:stdio \
-kernel $(kernel_img) -kernel $(kernel_img)
endif endif
ifeq ($(board), mipssim) ifeq ($(board), mipssim)
qemu_opts += \ qemu_opts += \
-machine $(board) \ -machine $(board) \
-serial mon:stdio \ -serial mon:stdio \
-kernel $(kernel_img) -kernel $(kernel_img)
endif endif
endif endif
ifdef d ifdef d
qemu_opts += -d $(d) qemu_opts += -d $(d)
endif endif
ifeq ($(graphic), off) ifeq ($(graphic), off)
qemu_opts += -nographic qemu_opts += -nographic
endif endif
### build args ### ### build args ###
ifeq ($(graphic), off) ifeq ($(graphic), off)
features += nographic features += nographic
endif endif
ifeq ($(graphic), console) ifeq ($(graphic), console)
features += consolegraphic features += consolegraphic
endif endif
ifneq ($(init), ) ifneq ($(init), )
features += run_cmdline features += run_cmdline
endif endif
ifeq ($(board), raspi3) ifeq ($(board), raspi3)
# qemu only has generic timer # qemu only has generic timer
# TODO: configure system/generic timer automatically # TODO: configure system/generic timer automatically
raspi3_timer ?= generic raspi3_timer ?= generic
ifeq ($(raspi3_timer), generic) ifeq ($(raspi3_timer), generic)
features += raspi3_use_generic_timer features += raspi3_use_generic_timer
endif endif
endif endif
ifneq ($(board), none) ifneq ($(board), none)
features += board_$(board) features += board_$(board)
endif endif
features += $(extra_features) features += $(extra_features)
@ -232,25 +233,25 @@ features += $(extra_features)
build_args := --target targets/$(target).json --features "$(features)" build_args := --target targets/$(target).json --features "$(features)"
ifeq ($(mode), release) ifeq ($(mode), release)
build_args += --release build_args += --release
endif endif
### prefix ### ### prefix ###
ifeq ($(arch), x86_64) ifeq ($(arch), x86_64)
ifeq ($(uname), Darwin) ifeq ($(uname), Darwin)
prefix := x86_64-elf- prefix := x86_64-elf-
endif endif
else ifeq ($(arch), riscv32) else ifeq ($(arch), riscv32)
prefix := riscv64-unknown-elf- prefix := riscv64-unknown-elf-
else ifeq ($(arch), riscv64) else ifeq ($(arch), riscv64)
prefix := riscv64-unknown-elf- prefix := riscv64-unknown-elf-
else ifeq ($(arch), mipsel) else ifeq ($(arch), mipsel)
prefix ?= mipsel-linux-musln32- prefix ?= mipsel-linux-musln32-
else ifeq ($(arch), aarch64) else ifeq ($(arch), aarch64)
prefix ?= aarch64-none-elf- prefix ?= aarch64-none-elf-
ifeq (,$(shell which $(prefix)ld)) ifeq (,$(shell which $(prefix)ld))
prefix := aarch64-elf- prefix := aarch64-elf-
endif endif
endif endif
gdb := $(prefix)gdb gdb := $(prefix)gdb
@ -374,9 +375,9 @@ ifeq ($(board), raspi3)
sd_card ?= sd_card ?=
ifeq ($(shell uname), Darwin) ifeq ($(shell uname), Darwin)
sd_card := /Volumes/boot sd_card := /Volumes/boot
else ifeq ($(shell uname), Linux) else ifeq ($(shell uname), Linux)
sd_card := /media/$(shell whoami)/boot sd_card := /media/$(shell whoami)/boot
endif endif
ifdef sd_card ifdef sd_card

Loading…
Cancel
Save