-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
104 lines (82 loc) · 2.87 KB
/
GNUmakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
.PHONY: all
all: optimist.iso
.PHONY: all-hdd
all-hdd: barebones.hdd
.PHONY: run
run: optimist.iso
# qemu-system-x86_64.exe -M q35 -m 2G -cdrom optimist.iso -boot d
qemu-system-x86_64.exe -M q35 -m 4G -cdrom optimist.iso -boot d
.PHONY: runl
runl: optimist.iso
# qemu-system-x86_64.exe -M q35 -m 2G -cdrom optimist.iso -boot d
qemu-system-x86_64 -M q35 -m 4G -cdrom optimist.iso -boot d
.PHONY: runm
runm: optimist.iso
# qemu-system-x86_64.exe -M q35 -m 2G -cdrom optimist.iso -boot d
qemu-system-x86_64.exe -M q35 -m 4G -cdrom optimist.iso -boot d -smp cores=2
.PHONY: debug
debug: optimist.iso
qemu-system-x86_64.exe -M q35 -m 4G -cdrom optimist.iso -boot d -s -S
.PHONY: debugi
debugi: optimist.iso
qemu-system-x86_64.exe -M q35 -m 4G -cdrom optimist.iso -boot d -d int -s -S
.PHONY: run-uefi
run-uefi: ovmf-x64 optimist.iso
qemu-system-x86_64 -M q35 -m 2G -bios ovmf-x64/OVMF.fd -cdrom optimist.iso -boot d
.PHONY: run-hdd
run-hdd: barebones.hdd
qemu-system-x86_64 -M q35 -m 2G -hda barebones.hdd
.PHONY: run-hdd-uefi
run-hdd-uefi: ovmf-x64 barebones.hdd
qemu-system-x86_64 -M q35 -m 2G -bios ovmf-x64/OVMF.fd -hda barebones.hdd
ovmf-x64:
mkdir -p ovmf-x64
cd ovmf-x64 && curl -o OVMF-X64.zip https://efi.akeo.ie/OVMF/OVMF-X64.zip && 7z x OVMF-X64.zip
limine:
git clone https://github.com/limine-bootloader/limine.git --branch=v4.x-branch-binary --depth=1
make -C limine
.PHONY: kernel
kernel:
$(MAKE) -C kernel
optimist.iso: limine kernel
rm -rf iso_root
mkdir -p iso_root
mkdir -p iso_root/media
cp kernel/kernel.elf \
limine.cfg limine/limine.sys limine/limine-cd.bin limine/limine-cd-efi.bin \
kernel/external/* \
iso_root/
cp media/* iso_root/media/
xorriso -as mkisofs -b limine-cd.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table \
--efi-boot limine-cd-efi.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
iso_root -o optimist.iso
limine/limine-deploy optimist.iso
rm -rf iso_root
barebones.hdd: limine kernel
rm -f barebones.hdd
dd if=/dev/zero bs=1M count=0 seek=64 of=barebones.hdd
parted -s barebones.hdd mklabel gpt
parted -s barebones.hdd mkpart ESP fat32 2048s 100%
parted -s barebones.hdd set 1 esp on
limine/limine-deploy barebones.hdd
sudo losetup -Pf --show barebones.hdd >loopback_dev
sudo mkfs.fat -F 32 `cat loopback_dev`p1
mkdir -p img_mount
sudo mount `cat loopback_dev`p1 img_mount
sudo mkdir -p img_mount/EFI/BOOT
sudo cp -v kernel/kernel.elf limine.cfg limine/limine.sys img_mount/
sudo cp -v limine/BOOTX64.EFI img_mount/EFI/BOOT/
sync
sudo umount img_mount
sudo losetup -d `cat loopback_dev`
rm -rf loopback_dev img_mount
.PHONY: clean
clean:
rm -rf iso_root optimist.iso barebones.hdd */*.d
$(MAKE) -C kernel clean
.PHONY: distclean
distclean: clean
rm -rf limine ovmf-x64
$(MAKE) -C kernel distclean