hazel/Makefile

34 lines
763 B
Makefile
Raw Normal View History

2024-06-25 21:43:07 -04:00
CC = i686-elf-gcc
2024-06-25 15:28:44 -04:00
AS = nasm
BUILDDIR := build
2024-06-25 22:47:21 -04:00
INCLUDEDIR := include
CFLAGS := -ffreestanding -Wall -Wextra -Werror -I $(INCLUDEDIR)
2024-06-25 15:28:44 -04:00
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
2024-06-25 21:43:07 -04:00
$(AS) -felf32 $^ -o $@
2024-06-25 15:28:44 -04:00
$(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 .
2024-06-25 22:21:33 -04:00
qemu: kernel
qemu-system-i386 -kernel $(BUILDDIR)/$(KIMG)
2024-06-25 15:28:44 -04:00
clean:
rm build/* boot/*.bin