rk/Makefile

53 lines
1.1 KiB
Makefile
Raw Permalink 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-26 15:54:00 -04:00
LDFLAGS = -T src/kernel.ld -ffreestanding -O3 -nostdlib -lgcc
2024-05-20 05:59:07 -04:00
BUILDDIR = build
2024-05-26 15:54:00 -04:00
KERNELSRC := $(shell find ./src -name '*.c' -o -name '*.asm')
2024-05-20 05:59:07 -04:00
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) \
-m 512M \
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)
2024-05-26 02:33:18 -04:00
$(BUILDDIR)/%.o: */%.c
2024-05-20 05:59:07 -04:00
$(CC) $(CFLAGS) -c $^ -o $@
2024-05-26 02:33:18 -04:00
$(BUILDDIR)/%.o: */%.asm
2024-05-20 05:59:07 -04:00
nasm -felf32 $^ -o $@
qemu: kernel
qemu-system-i386 $(QEMUFLAGS)
test: kernel
rm image.img
nasm -fbin test.asm -o image.img
2024-05-20 05:59:07 -04:00
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