hazel/Makefile
2024-06-25 22:21:33 -04:00

32 lines
723 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 .
qemu: kernel
qemu-system-i386 -kernel $(BUILDDIR)/$(KIMG)
clean:
rm build/* boot/*.bin