-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (44 loc) · 1.19 KB
/
Makefile
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
.DEFAULT_GOAL := image
# Kernel targets
.PHONY: kernel_check
kernel_check:
@cd kernel; cargo clippy
.PHONY: kernel_build
kernel_build:
@cd kernel; cargo build --release
.PHONY: kernel_clean
kernel_clean:
@cd kernel; cargo clean
# Top level targets
.PHONY: check
check: kernel_check
.PHONY: build
build: kernel_build
.PHONY: clean
clean: kernel_clean
@rm disk.img
disk.img:
@echo Creating disk.img...
@dd if=/dev/zero of=disk.img count=8 bs=1M
@printf "n\n\n\n\n\nt\nb\na\nw\n" | fdisk disk.img
@sudo losetup -P /dev/loop0 disk.img
@sudo mkfs.vfat /dev/loop0p1
@sudo limine bios-install /dev/loop0
@sudo losetup -d /dev/loop0
.PHONY: image
image: build disk.img
@echo Copying files to disk.img...
@sudo losetup -P /dev/loop0 disk.img
@sudo mount /dev/loop0p1 /mnt
@sudo rm -rf /mnt/*
@sudo mkdir /mnt/boot
@sudo cp /usr/local/share/limine/limine-bios.sys /mnt/boot
@sudo cp limine.cfg /mnt/boot
@sudo cp kernel/target/target/release/kernel /mnt/boot
@echo Contents of /boot:
@ls /mnt/boot
@sudo umount /mnt
@sudo losetup -d /dev/loop0
.PHONY: run
run: image
@qemu-system-x86_64 -accel kvm -drive format=raw,file=disk.img -cpu Broadwell,pdpe1gb -m 1G -serial mon:stdio -d int -D qemu.log