Add Forty-Two support

This commit is contained in:
gbaconni
2021-11-05 10:36:43 +01:00
parent dd6536d230
commit 01f404a1f2
2 changed files with 78 additions and 39 deletions

116
Makefile
View File

@@ -6,7 +6,7 @@
# By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/11/02 17:47:57 by gbaconni #+# #+# #
# Updated: 2021/11/05 08:39:30 by gbaconni ### lausanne.ch #
# Updated: 2021/11/05 10:00:08 by gbaconni ### ########.fr #
# #
# **************************************************************************** #
@@ -17,6 +17,7 @@ RAM = 2048
SSD = 31539
KERNEL = $(shell uname -s)
FT = $(shell if test -L ~/goinfre; then echo "yes"; else "no"; fi)
all: sync
@@ -24,44 +25,70 @@ virtualbox:
@test -d ~/goinfre/VirtualBox\ VMs || mkdir -p ~/goinfre/VirtualBox\ VMs
@ln -snf ~/goinfre/VirtualBox\ VMs ~/VirtualBox\ VMs
uefi:
ifeq ($(KERNEL),Linux)
@test -f efi-virtio.rom || cp /usr/lib/ipxe/qemu/efi-virtio.rom efi-virtio.rom
@test -f edk2-aarch64-code.fd || cp /usr/share/AAVMF/AAVMF_CODE.fd edk2-aarch64-code.fd
@test -f edk2-arm-vars.fd || cp /usr/share/AAVMF/AAVMF_VARS.fd edk2-arm-vars.fd
@test -f edk2-x86_64-code.fd || cp /usr/share/OVMF/OVMF_CODE_4M.fd edk2-x86_64-code.fd
@test -f edk2-i386-vars.fd || cp /usr/share/OVMF/OVMF_VARS_4M.fd edk2-i386-vars.fd
endif
ifeq ($(KERNEL),Darwin)
@test -f efi-virtio.rom || cp /opt/homebrew/Cellar/qemu/*/share/qemu/efi-virtio.rom efi-virtio.rom
@test -f edk2-aarch64-code.fd || cp /opt/homebrew/Cellar/qemu/*/share/qemu/edk2-aarch64-code.fd edk2-aarch64-code.fd
@test -f edk2-arm-vars.fd || cp /opt/homebrew/Cellar/qemu/*/share/qemu/edk2-arm-vars.fd edk2-arm-vars.fd
@test -f edk2-x86_64-code.fd || cp /opt/homebrew/Cellar/qemu/*/share/qemu/edk2-x86_64-code.fd edk2-x86_64-code.fd
@test -f edk2-i386-vars.fd || cp /opt/homebrew/Cellar/qemu/*/share/qemu/edk2-i386-vars.fd edk2-i386-vars.fd
data:
ifeq ($(FT),yes)
@test -d ~/goinfre/born2beroot || install -d ~/goinfre/born2beroot
@test -L data || ln -snf ~/goinfre/born2beroot data
else
@test -d data || install -d data
endif
qemu: uefi
uefi: data
ifeq ($(KERNEL),Linux)
@test -f data/efi-virtio.rom || cp /usr/lib/ipxe/qemu/efi-virtio.rom data/efi-virtio.rom
@test -f data/edk2-aarch64-code.fd || cp /usr/share/AAVMF/AAVMF_CODE.fd data/edk2-aarch64-code.fd
@test -f data/edk2-arm-vars.fd || cp /usr/share/AAVMF/AAVMF_VARS.fd data/edk2-arm-vars.fd
@test -f data/edk2-x86_64-code.fd || cp /usr/share/OVMF/OVMF_CODE_4M.fd data/edk2-x86_64-code.fd
@test -f data/edk2-i386-vars.fd || cp /usr/share/OVMF/OVMF_VARS_4M.fd data/edk2-i386-vars.fd
endif
ifeq ($(KERNEL),Darwin)
ifeq ($(FT),yes)
@test -f data/efi-virtio.rom || cp ~/.brew/Cellar/qemu/*/share/qemu/efi-virtio.rom data/efi-virtio.rom
@test -f data/edk2-aarch64-code.fd || cp ~/.brew/Cellar/qemu/*/share/qemu/edk2-aarch64-code.fd data/edk2-aarch64-code.fd
@test -f data/edk2-arm-vars.fd || cp ~/.brew/Cellar/qemu/*/share/qemu/edk2-arm-vars.fd data/edk2-arm-vars.fd
@test -f data/edk2-x86_64-code.fd || cp ~/.brew/Cellar/qemu/*/share/qemu/edk2-x86_64-code.fd data/edk2-x86_64-code.fd
@test -f data/edk2-i386-vars.fd || cp ~/.brew/Cellar/qemu/*/share/qemu/edk2-i386-vars.fd data/edk2-i386-vars.fd
else
@test -f data/efi-virtio.rom || cp /opt/homebrew/Cellar/qemu/*/share/qemu/efi-virtio.rom data/efi-virtio.rom
@test -f data/edk2-aarch64-code.fd || cp /opt/homebrew/Cellar/qemu/*/share/qemu/edk2-aarch64-code.fd data/edk2-aarch64-code.fd
@test -f data/edk2-arm-vars.fd || cp /opt/homebrew/Cellar/qemu/*/share/qemu/edk2-arm-vars.fd data/edk2-arm-vars.fd
@test -f data/edk2-x86_64-code.fd || cp /opt/homebrew/Cellar/qemu/*/share/qemu/edk2-x86_64-code.fd data/edk2-x86_64-code.fd
@test -f data/edk2-i386-vars.fd || cp /opt/homebrew/Cellar/qemu/*/share/qemu/edk2-i386-vars.fd data/edk2-i386-vars.fd
endif
endif
qemu:
ifeq ($(KERNEL),Linux)
@which qemu-system-x86_64 >/dev/null 2>&1 || sudo apt-get install -qq -y qemu-utils qemu-system-x86 qemu-system-arm qemu-efi-aarch64 ovmf ipxe-qemu
endif
ifeq ($(KERNEL),Darwin)
ifeq ($(FT),yes)
@which brew >/dev/null 2>&1 || curl -fsSL https://rawgit.com/kube/42homebrew/master/install.sh | zsh
@test -L ~/.brew/bin/qemu-system-x86_64 || (eval "$$(/opt/homebrew/bin/brew shellenv)" && brew install qemu)
else
@which brew >/dev/null 2>&1 || bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@test -L /opt/homebrew/bin/qemu-system-x86_64 || (eval "$$(/opt/homebrew/bin/brew shellenv)" && brew install qemu)
endif
endif
debian:
@test -f debian-$(DVER)-amd64-netinst.iso || curl -sLO https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-$(DVER)-amd64-netinst.iso
@test -f debian-$(DVER)-arm64-netinst.iso || curl -sLO https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-$(DVER)-arm64-netinst.iso
curl:
ifeq ($(KERNEL),Linux)
@which curl >/dev/null 2>&1 || sudo apt-get install -qq -y curl
endif
auto:
@grep -q 42url debian-$(DVER)-amd64-netinst.iso || sed -i'.orig' -e 's|auto=true priority=critical vga=788|auto url=https://42url.com/6eMNuv2Y|g' debian-$(DVER)-amd64-netinst.iso
@grep -q 42url debian-$(DVER)-arm64-netinst.iso || sed -i'.orig' -e 's|auto=true priority=critical --- quiet|auto url=https://42url.com/6eMNuv2Y |g' debian-$(DVER)-arm64-netinst.iso
@rm -f debian-$(DVER)-amd64-netinst.iso.orig debian-$(DVER)-arm64-netinst.iso.orig
debian: data curl
@test -f data/debian-$(DVER)-amd64-netinst.iso || curl -sLo data/debian-$(DVER)-amd64-netinst.iso https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-$(DVER)-amd64-netinst.iso
@test -f data/debian-$(DVER)-arm64-netinst.iso || curl -sLo data/debian-$(DVER)-arm64-netinst.iso https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-$(DVER)-arm64-netinst.iso
sda:
@test -f sda.raw || qemu-img create -f raw -o size=$(SSD)M sda.raw
auto: data
@grep -q 42url data/debian-$(DVER)-amd64-netinst.iso || sed -i'.orig' -e 's|auto=true priority=critical vga=788|auto url=https://42url.com/6eMNuv2Y|g' data/debian-$(DVER)-amd64-netinst.iso
@grep -q 42url data/debian-$(DVER)-arm64-netinst.iso || sed -i'.orig' -e 's|auto=true priority=critical --- quiet|auto url=https://42url.com/6eMNuv2Y |g' data/debian-$(DVER)-arm64-netinst.iso
@rm -f data/debian-$(DVER)-amd64-netinst.iso.orig data/debian-$(DVER)-arm64-netinst.iso.orig
amd64: qemu sda debian
sda: data
@test -f data/sda.raw || qemu-img create -f raw -o size=$(SSD)M data/sda.raw
amd64: qemu uefi sda debian
@qemu-system-x86_64 \
-name debian \
-cpu qemu64-v1 \
@@ -79,10 +106,10 @@ amd64: qemu sda debian
-device virtio-scsi-pci,num_queues=4,id=scsi0 \
-device scsi-hd,drive=drive0,bus=scsi0.0,channel=0,scsi-id=0,lun=0,bootindex=0 \
-device scsi-cd,drive=cdrom0,bus=scsi0.0,channel=0,scsi-id=1,lun=0,bootindex=1 \
-drive id=pflash0,unit=0,file=${PWD}/edk2-x86_64-code.fd,if=pflash,format=raw,readonly=on \
-drive id=pflash1,unit=1,file=${PWD}/edk2-i386-vars.fd,if=pflash,format=raw \
-drive id=drive0,index=0,file=${PWD}/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \
-drive id=cdrom0,index=1,file=${PWD}/debian-$(DVER)-amd64-netinst.iso,if=none,media=cdrom,readonly=on \
-drive id=pflash0,unit=0,file=${PWD}/data/edk2-x86_64-code.fd,if=pflash,format=raw,readonly=on \
-drive id=pflash1,unit=1,file=${PWD}/data/edk2-i386-vars.fd,if=pflash,format=raw \
-drive id=drive0,index=0,file=${PWD}/data/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \
-drive id=cdrom0,index=1,file=${PWD}/data/debian-$(DVER)-amd64-netinst.iso,if=none,media=cdrom,readonly=on \
-nic user,model=virtio \
-monitor stdio \
-rtc base=localtime,clock=host
@@ -104,14 +131,14 @@ debug: qemu
-device virtio-gpu \
-device virtio-scsi-pci,num_queues=4,id=scsi0 \
-device scsi-hd,drive=drive0,bus=scsi0.0,channel=0,scsi-id=0,lun=0,bootindex=0 \
-drive id=drive0,index=0,file=${PWD}/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \
-drive id=drive0,index=0,file=${PWD}/data/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \
-nic user,model=virtio \
-monitor stdio \
-rtc base=localtime,clock=host
test: auto amd64 debug
arm64: qemu sda debian
arm64: qemu uefi sda debian
@qemu-system-aarch64 \
-name debian \
-accel hvf \
@@ -130,20 +157,31 @@ arm64: qemu sda debian
-device virtio-scsi-pci,num_queues=4,id=scsi0 \
-device scsi-hd,drive=drive0,bus=scsi0.0,channel=0,scsi-id=0,lun=0,bootindex=0 \
-device scsi-cd,drive=cdrom0,bus=scsi0.0,channel=0,scsi-id=1,lun=0,bootindex=1 \
-drive id=pflash0,unit=0,file=${PWD}/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on \
-drive id=pflash1,unit=1,file=${PWD}/edk2-arm-vars.fd,if=pflash,format=raw \
-drive id=drive0,index=0,file=${PWD}/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \
-drive id=cdrom0,index=1,file=${PWD}/debian-$(DVER)-arm64-netinst.iso,if=none,media=cdrom,readonly=on \
-drive id=pflash0,unit=0,file=${PWD}/data/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on \
-drive id=pflash1,unit=1,file=${PWD}/data/edk2-arm-vars.fd,if=pflash,format=raw \
-drive id=drive0,index=0,file=${PWD}/data/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \
-drive id=cdrom0,index=1,file=${PWD}/data/debian-$(DVER)-arm64-netinst.iso,if=none,media=cdrom,readonly=on \
-nic user,model=virtio \
-monitor stdio \
-rtc base=localtime,clock=host
clean:
@rm -f sda.raw
@rm -f data/sda.raw
fclean: clean
@rm -f debian-$(DVER)-amd64-netinst.iso
@rm -f debian-$(DVER)-arm64-netinst.iso
@rm -f data/debian-$(DVER)-amd64-netinst.iso
@rm -f data/debian-$(DVER)-arm64-netinst.iso
@rm -f data/efi-virtio.rom
@rm -f data/edk2-aarch64-code.fd
@rm -f data/edk2-arm-vars.fd
@rm -f data/edk2-x86_64-code.fd
@rm -f data/edk2-i386-vars.fd
ifeq ($(FT),yes)
@rm -f data
@rm -fr ~/goinfre/born2beroot
else
@rm -fr data
endif
re: clean test