hazel/Makefile

47 lines
1.0 KiB
Makefile

CC = /home/rami/crossdev/bin/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) -s -m 512M -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
make -C user
cp $(BUILDDIR)/$(KIMG) boot/$(KIMG)
rm -f $(BUILDDIR)/$(ISO)
grub-mkrescue -o $(BUILDDIR)/$(ISO) .
iso: $(BUILDDIR)/$(ISO)
all: iso
qemu: iso
qemu-system-i386 $(QEMUFLAGS)
clean:
make clean -C user
rm -f build/* boot/*.bin boot/initrd