47 lines
1.1 KiB
Makefile
47 lines
1.1 KiB
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) \
|
|
-s -d int \
|
|
-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
|
|
rm -f $(BUILDDIR)/$(ISO) boot/initrd
|
|
nasm -fbin user/userinit.asm -o boot/initrd
|
|
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 boot/initrd
|