-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
34 lines (26 loc) · 1.11 KB
/
Makefile
File metadata and controls
34 lines (26 loc) · 1.11 KB
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
ENTRY_POINT = loader_main
img: BOOTX64.EFI kernel.bin Makefile
cp $< fs/EFI/BOOT/$<
dd if=/dev/zero of=fat.img bs=1k count=1440
mformat -i fat.img -f 1440 ::
mcopy -i fat.img kernel.bin ::/
mmd -i fat.img ::/EFI
mmd -i fat.img ::/EFI/BOOT
mcopy -i fat.img $< ::/EFI/BOOT
BOOTX64.EFI: loader.c lib.c
x86_64-w64-mingw32-gcc -Wall -Wextra -nostdlib -nostdinc -ffreestanding -mno-red-zone -Wl,--subsystem,10 -m64 -shared -Wl,-Bsymbolic -mabi=ms -mgeneral-regs-only -fpic -fno-stack-protector -e $(ENTRY_POINT) -o $@ $+
kernel.bin: kernel.o Makefile
ld.lld -e kernel_main -z norelro --image-base 0x100000 --static -o $@ $<
%.o: %.c Makefile
gcc -Wall -Wextra -nostdlib -nostdinc -ffreestanding -mno-red-zone -Wl,--subsystem,10 -m64 -shared -Wl,-Bsymbolic -mabi=ms -mgeneral-regs-only -fpic -fno-stack-protector -c -o $*.o $*.c
run: img
qemu-system-x86_64 -m 4G -bios OVMF.fd -hda fat.img -monitor stdio
clean:
rm -f BOOTX64.EFI
rm -f fs/EFI/BOOT/BOOTX64.EFI
rm -f fat.img
rm -f kernel.bin
rm -f *.o
kernellist: kernel.c
gcc -Wall -Wextra -nostdinc -nostdlib -fno-builtin -S -o kernel.s kernel.c
as -al kernel.s