44 lines
990 B
Makefile
44 lines
990 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
|
|
|
|
LSRC := $(wildcard lib/*.c)
|
|
LOBJ := $(addprefix $(BUILDDIR)/, \
|
|
$(notdir \
|
|
$(patsubst %.c,%.o, $(LSRC))))
|
|
|
|
ISO := Hazel.iso
|
|
|
|
CFLAGS := -ffreestanding -Wall -Wextra -Werror -I $(INCLUDEDIR) -I lib
|
|
LDFLAGS := -ffreestanding -nostdlib -lgcc -T kernel/kernel.ld
|
|
QEMUFLAGS := -cdrom $(BUILDDIR)/$(ISO) \
|
|
-serial stdio
|
|
|
|
$(BUILDDIR)/$(KIMG): $(KOBJ) $(LOBJ)
|
|
$(CC) $^ -o $@ $(LDFLAGS)
|
|
$(BUILDDIR)/%.o: */%.asm
|
|
$(AS) -felf32 $^ -o $@
|
|
$(BUILDDIR)/%.o: */%.c
|
|
$(CC) $(CFLAGS) -c $^ -o $@
|
|
|
|
kernel: $(BUILDDIR)/$(KIMG)
|
|
|
|
$(BUILDDIR)/$(ISO): kernel
|
|
rm -f $(BUILDDIR)/$(ISO)
|
|
cp $(BUILDDIR)/$(KIMG) boot/$(KIMG)
|
|
grub-mkrescue -o $(BUILDDIR)/$(ISO) .
|
|
iso: $(BUILDDIR)/$(ISO)
|
|
|
|
qemu: iso
|
|
qemu-system-i386 $(QEMUFLAGS)
|
|
clean:
|
|
rm -f build/* boot/*.bin
|