rk/Makefile
2024-05-21 21:13:07 -05:00

49 lines
1.0 KiB
Makefile

CC = i686-elf-gcc
INCLUDE = -I./include -I./lib
CFLAGS = -Wall -Wextra -Werror -ffreestanding $(INCLUDE)
LDFLAGS = -T kernel.ld -ffreestanding -O3 -nostdlib -lgcc
BUILDDIR = build
KERNELSRC := $(shell find . -name '*.c' -o -name '*.asm')
KERNELOBJ := $(addprefix $(BUILDDIR)/, \
$(notdir \
$(patsubst %.c,%.o,\
$(patsubst %.asm,%.o,$(KERNELSRC)))))
KERNELIMG := $(BUILDDIR)/kernel.bin
QEMUFLAGS = -d int -s \
-kernel $(KERNELIMG) \
-machine q35 \
-device piix3-ide,id=ide -drive id=disk,file=image.img,format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 \
.PHONY: all kernel qemu clean docs
all: qemu
qemu: kernel
kernel: $(KERNELIMG)
$(KERNELIMG): $(KERNELOBJ)
$(CC) $^ -o $@ $(LDFLAGS)
$(BUILDDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $^ -o $@
$(BUILDDIR)/%.o: %.asm
nasm -felf32 $^ -o $@
qemu: kernel
qemu-system-i386 $(QEMUFLAGS)
iso: kernel
cp $(BUILDDIR)/kernel.bin iso/boot/kernel.bin
grub-mkrescue -o $(BUILDDIR)/andewOS.iso iso/
bochs: iso
bochs -q
clean:
rm -rf build/*.o build/*.bin iso/boot/*.bin
docs:
doxygen