33 lines
766 B
Makefile
33 lines
766 B
Makefile
|
CC = x86_64-elf-gcc
|
||
|
AS = nasm
|
||
|
|
||
|
BUILDDIR := build
|
||
|
CFLAGS := -ffreestanding -Wall -Wextra -Werror -mno-red-zone
|
||
|
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) -felf64 $^ -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-x86_64 -cdrom $(BUILDDIR)/Hazel.iso
|
||
|
|
||
|
clean:
|
||
|
rm build/* boot/*.bin
|