hazel/Makefile
2024-06-25 21:43:07 -04:00

33 lines
748 B
Makefile

CC = i686-elf-gcc
AS = nasm
BUILDDIR := build
CFLAGS := -ffreestanding -Wall -Wextra -Werror
LDFLAGS := -ffreestanding -nostdlib -lgcc -T kernel/kernel.ld
KSRC := $(wildcard kernel/*.asm kernel/*.c)
KOBJ := $(addprefix $(BUILDDIR)/, \
$(notdir \
$(patsubst %.asm,%.o, $(patsubst %.c,%.o, $(KSRC)))))
KIMG := kernel.bin
$(BUILDDIR)/$(KIMG): $(KOBJ)
$(CC) $^ -o $@ $(LDFLAGS)
$(BUILDDIR)/%.o: */%.asm
$(AS) -felf32 $^ -o $@
$(BUILDDIR)/%.o: */%.c
$(CC) $(CFLAGS) -c $^ -o $@
kernel: $(BUILDDIR)/$(KIMG)
$(BUILDDIR)/Hazel.iso: kernel
cp $(BUILDDIR)/kernel.bin boot/kernel.bin
grub-mkrescue -o $(BUILDDIR)/Hazel.iso .
iso: $(BUILDDIR)/Hazel.iso
qemu: iso
qemu-system-i386 -cdrom $(BUILDDIR)/Hazel.iso
clean:
rm build/* boot/*.bin