rk/Makefile

53 lines
1.1 KiB
Makefile

CC = i686-elf-gcc
INCLUDE = -I./include -I./lib
CFLAGS = -Wall -Wextra -Werror -ffreestanding $(INCLUDE)
LDFLAGS = -T src/kernel.ld -ffreestanding -O3 -nostdlib -lgcc
BUILDDIR = build
KERNELSRC := $(shell find ./src -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) \
-m 512M \
-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)
test: kernel
rm image.img
nasm -fbin test.asm -o image.img
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