36 lines
813 B
Makefile
36 lines
813 B
Makefile
CC = i686-elf-gcc
|
|
AS = nasm
|
|
|
|
BUILDDIR := build
|
|
INCLUDEDIR := include
|
|
|
|
KSRC := $(wildcard kernel/*.asm kernel/*.c)
|
|
KOBJ := $(addprefix $(BUILDDIR)/, \
|
|
$(notdir \
|
|
$(patsubst %.asm,%.o, $(patsubst %.c,%.o, $(KSRC)))))
|
|
KIMG := kernel.bin
|
|
|
|
CFLAGS := -ffreestanding -Wall -Wextra -Werror -I $(INCLUDEDIR)
|
|
LDFLAGS := -ffreestanding -nostdlib -lgcc -T kernel/kernel.ld
|
|
QEMUFLAGS := -kernel $(BUILDDIR)/$(KIMG) \
|
|
-serial stdio
|
|
|
|
$(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 $(QEMUFLAGS)
|
|
|
|
clean:
|
|
rm build/* boot/*.bin
|