summaryrefslogtreecommitdiff
path: root/Makefile
blob: 1fda09575a7c2bf90dc2c1898913e735e7ee85f0 (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
### Copyright (c) 2025 Freya Murphy <freya@freyacat.org>

.PHONY: build fmt clean qemu
.SILENT:

UNAME := $(shell uname)

QEMU = qemu-system-x86_64
QEMUOPTS = -cdrom bin/os.iso \
		   -no-reboot \
		   -serial mon:stdio \
		   -m 4G \
		   -name kern

qemu: bin/os.iso
	$(QEMU) $(QEMUOPTS)

qemu-gdb: bin/os.iso
	$(QEMU) $(QEMUOPTS) -S -gdb tcp::1337

gdb:
	gdb -q -n -x util/gdbinit

clean:
	rm -fr .zig-cache
	rm -fr bin

build:
	zig build

bin/os.iso: build
	mkdir -p bin/iso/boot/grub
	cp grub.cfg bin/iso/boot/grub
	cp bin/kernel bin/iso/boot
	grub-mkrescue -o bin/os.iso bin/iso 2>/dev/null

fmt:
	clang-format -i $(shell find -type f -name "*.[ch]")
	sed -i 's/[ \t]*$$//' $(shell find -type f -name "*.[chS]" -or -name "*.ld")