2024-08-01 14:22:25 -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
|
|
|
|
|
2024-06-25 15:28:44 -04:00
|
|
|
KSRC := $(wildcard kernel/*.asm kernel/*.c)
|
|
|
|
KOBJ := $(addprefix $(BUILDDIR)/, \
|
2024-07-01 19:28:45 -04:00
|
|
|
$(notdir \
|
|
|
|
$(patsubst %.asm,%.o, $(patsubst %.c,%.o, $(KSRC)))))
|
2024-06-25 15:28:44 -04:00
|
|
|
KIMG := kernel.bin
|
|
|
|
|
2024-07-01 19:28:45 -04:00
|
|
|
LSRC := $(wildcard lib/*.c)
|
|
|
|
LOBJ := $(addprefix $(BUILDDIR)/, \
|
2024-07-28 10:11:15 -04:00
|
|
|
$(notdir \
|
|
|
|
$(patsubst %.c,%.o, $(LSRC))))
|
2024-07-01 19:28:45 -04:00
|
|
|
|
2024-06-28 16:01:28 -04:00
|
|
|
ISO := Hazel.iso
|
|
|
|
|
2024-07-01 19:28:45 -04:00
|
|
|
CFLAGS := -ffreestanding -Wall -Wextra -Werror -I $(INCLUDEDIR) -I lib
|
2024-06-27 18:36:32 -04:00
|
|
|
LDFLAGS := -ffreestanding -nostdlib -lgcc -T kernel/kernel.ld
|
2024-08-01 14:22:25 -04:00
|
|
|
QEMUFLAGS := -cdrom $(BUILDDIR)/$(ISO) -s -m 512M -serial stdio
|
2024-06-27 18:36:32 -04:00
|
|
|
|
2024-07-01 19:28:45 -04:00
|
|
|
$(BUILDDIR)/$(KIMG): $(KOBJ) $(LOBJ)
|
2024-06-25 15:28:44 -04:00
|
|
|
$(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)
|
|
|
|
|
2024-06-28 16:01:28 -04:00
|
|
|
$(BUILDDIR)/$(ISO): kernel
|
2024-07-28 10:11:15 -04:00
|
|
|
make -C user
|
2024-06-28 16:01:28 -04:00
|
|
|
cp $(BUILDDIR)/$(KIMG) boot/$(KIMG)
|
2024-07-28 10:11:15 -04:00
|
|
|
rm -f $(BUILDDIR)/$(ISO)
|
2024-06-28 16:01:28 -04:00
|
|
|
grub-mkrescue -o $(BUILDDIR)/$(ISO) .
|
|
|
|
iso: $(BUILDDIR)/$(ISO)
|
2024-06-25 15:28:44 -04:00
|
|
|
|
2024-07-28 10:11:15 -04:00
|
|
|
all: iso
|
|
|
|
|
2024-06-28 16:01:28 -04:00
|
|
|
qemu: iso
|
2024-06-27 18:36:32 -04:00
|
|
|
qemu-system-i386 $(QEMUFLAGS)
|
2024-06-25 15:28:44 -04:00
|
|
|
clean:
|
2024-07-28 10:11:15 -04:00
|
|
|
make clean -C user
|
2024-07-03 15:42:01 -04:00
|
|
|
rm -f build/* boot/*.bin boot/initrd
|