-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
47 lines (39 loc) · 1.27 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
arch ?= x86_64
target ?= $(arch)-snowflake
boot2snow := build/boot2snow/bootx64.efi
kernel := build/kernel/kernel.bin
img := build/snowflake-$(arch).img
CARGO = cargo
NASM = nasm
LD = $(arch)-elf-ld
AS = $(arch)-elf-as
OBJCOPY = $(arch)-elf-objcopy
STRIP = $(arch)-elf-strip
.PHONY: all clean run run-debug img
all: $(img)
clean:
@rm -r build #target
run: $(img)
@qemu-system-x86_64 -m 1024 -serial mon:stdio -net none -vga std -bios ovmf.fd $(img)
run-debug: $(img)
@qemu-system-x86_64 -s -S -m 1024 -serial mon:stdio -net none -vga std -bios ovmf.fd $(img)
img: $(img)
$(img):
@make -C boot2snow
@make -C kernel
@dd if=/dev/zero of=$(img).tmp bs=512 count=98304
@mkfs.vfat $(img).tmp
@mmd -i $(img).tmp ::/boot2snow
@mmd -i $(img).tmp ::/efi
@mmd -i $(img).tmp ::/efi/boot
@mcopy -i $(img).tmp $(kernel) ::/boot2snow
@mcopy -i $(img).tmp res/only_logo.bmp ::/boot2snow
@mcopy -i $(img).tmp res/full_logo.bmp ::/boot2snow
@mcopy -i $(img).tmp res/boot2snow.conf ::/boot2snow
@mcopy -i $(img).tmp $(boot2snow) ::/efi/boot
@dd if=/dev/zero of=$@ bs=512 count=100352
@parted $@ -s -a minimal mklabel gpt
@parted $@ -s -a minimal mkpart EFI FAT32 2048s 93716s
@parted $@ -s -a minimal toggle 1 boot
@dd if=$@.tmp of=$@ bs=512 count=98304 seek=2048 conv=notrunc
@rm -rf $@.tmp