hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 62521395037dde5d9b983a0f3f05f989167c45e3 (plain)
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
# Revel — build the kernel, assemble a Limine ISO, boot it in QEMU.
#
#   make            build the ISO (default)
#   make run        build and boot it headless (serial on stdout)
#   make kernel     just compile the kernel ELF
#   make clean      remove build output (kernel, ISO, caches)
#   make distclean  also remove Limine's built host tool

ZIG  ?= zig
QEMU ?= qemu-system-x86_64

KERNEL := zig-out/bin/revel
ISO    := revel.iso

.PHONY: all kernel iso run clean distclean

all: iso

kernel:
	$(ZIG) build

limine/limine:
	$(MAKE) -C limine

iso: kernel limine/limine
	rm -rf iso_root
	mkdir -p iso_root/boot/limine iso_root/EFI/BOOT
	cp $(KERNEL)                       iso_root/boot/revel
	cp boot/limine.conf                iso_root/boot/limine/
	cp limine/limine-bios.sys    \
	   limine/limine-bios-cd.bin \
	   limine/limine-uefi-cd.bin       iso_root/boot/limine/
	cp limine/BOOTX64.EFI \
	   limine/BOOTIA32.EFI             iso_root/EFI/BOOT/
	xorriso -as mkisofs -R -r -J                                 \
		-b boot/limine/limine-bios-cd.bin                        \
		-no-emul-boot -boot-load-size 4 -boot-info-table         \
		-hfsplus -apm-block-size 2048                            \
		--efi-boot boot/limine/limine-uefi-cd.bin                \
		-efi-boot-part --efi-boot-image --protective-msdos-label \
		iso_root -o $(ISO)
	./limine/limine bios-install $(ISO)

# for now this is just going to be a headless run
# all I need this for is to check for kernel panics
# and limine related failures.
run: iso
	$(QEMU) -M q35 -m 256M -cdrom $(ISO) -boot d   \
	        -display none -serial stdio -no-reboot \
			-no-shutdown

clean:
	rm -rf iso_root zig-out .zig-cache $(ISO)

distclean: clean
	rm -f limine/limine