rk/Makefile

48 lines
1.0 KiB
Makefile
Raw Normal View History

2024-05-20 05:59:07 -04:00
CC = i686-elf-gcc
2024-05-21 22:13:07 -04:00
INCLUDE = -I./include -I./lib
2024-05-20 05:59:07 -04:00
CFLAGS = -Wall -Wextra -Werror -ffreestanding $(INCLUDE)
2024-05-21 22:07:04 -04:00
LDFLAGS = -T kernel.ld -ffreestanding -O3 -nostdlib -lgcc
2024-05-20 05:59:07 -04:00
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 \
2024-05-20 17:39:20 -04:00
-kernel $(KERNELIMG) \
2024-05-21 22:07:04 -04:00
-device piix3-ide,id=ide -drive id=disk,file=image.img,format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 \
2024-05-20 05:59:07 -04:00
.PHONY: all kernel qemu clean docs
all: qemu
qemu: kernel
kernel: $(KERNELIMG)
2024-05-21 22:13:07 -04:00
$(KERNELIMG): $(KERNELOBJ)
2024-05-20 05:59:07 -04:00
$(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/
2024-05-21 22:07:04 -04:00
bochs: iso
bochs -q
2024-05-20 05:59:07 -04:00
clean:
rm -rf build/*.o build/*.bin iso/boot/*.bin
docs:
doxygen