22 lines
782 B
Makefile

.PHONY: kernel
kernel:
./i686-elf-gcc/bin/i686-elf-gcc -c -o boot.o -ffreestanding boot.S
ldc2 -march=x86 -mcpu=i686 --betterC -c -of=kernel_main.o kernel_main.d
./i686-elf-gcc/bin/i686-elf-gcc -o kernel.elf -ffreestanding -nostdlib -T link.ld boot.o kernel_main.o
.PHONY: image
image: kernel
rm -rf image
mkdir -p image/iso/boot/grub
echo 'set default="0"' >image/iso/boot/grub/grub.cfg
echo 'set timeout=1' >>image/iso/boot/grub/grub.cfg
echo 'menuentry "MyKernel" {' >>image/iso/boot/grub/grub.cfg
echo ' insmod multiboot' >>image/iso/boot/grub/grub.cfg
echo ' multiboot /kernel.elf' >>image/iso/boot/grub/grub.cfg
echo '}' >>image/iso/boot/grub/grub.cfg
cp kernel.elf image/iso
grub-mkrescue -o image.img image/iso
run: image
qemu-system-x86_64 -hda image.img