hazel/Makefile

45 lines
1008 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
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)/, \
$(notdir \
$(patsubst %.c,%.o, $(LSRC))))
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-06-28 16:01:28 -04:00
QEMUFLAGS := -cdrom $(BUILDDIR)/$(ISO) \
2024-07-02 18:44:36 -04:00
-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-06-30 21:27:33 -04:00
rm -f $(BUILDDIR)/$(ISO)
2024-06-28 16:01:28 -04:00
cp $(BUILDDIR)/$(KIMG) boot/$(KIMG)
grub-mkrescue -o $(BUILDDIR)/$(ISO) .
iso: $(BUILDDIR)/$(ISO)
2024-06-25 15:28:44 -04:00
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-06-30 21:27:33 -04:00
rm -f build/* boot/*.bin