-AS = yasm # choose yasm or nasm here
-ASFLAGS = -f bin # compile a raw binary
+AS = yasm
+LD = i686-elf-ld
+CC = i686-elf-gcc
-boot: boot.s print.s
- $(AS) $(ASFLAGS) -o $@ boot.s
+KERNEL_OBJ = kernel/entry.o kernel/arch/x86/tty/tty.o kernel/kernel.o
-clean:
- -rm boot
+all: boot.img
+
+boot.img: boot/x86/boot kernel/kernel.bin
+ cat boot/x86/boot kernel/kernel.bin > $@
+ truncate -s1440K $@
+
+boot/x86/boot: boot/x86/boot.s boot/x86/a20.s boot/x86/protected.s boot/x86/print.s
+ $(AS) -f bin boot/x86/boot.s -o $@
+
+kernel/kernel.bin: ${KERNEL_OBJ}
+ $(LD) -o $@ -T kernel/linker.ld ${KERNEL_OBJ} --oformat=binary
-run:
- qemu-system-i386 boot
+kernel/entry.o: kernel/entry.s
+ $(AS) -f elf kernel/entry.s -o $@
-help:
- @echo "Run 'make' to compile."
- @echo "Run 'make clean' to delete compiled objects."
- @echo "Run 'make run' to run the compiled object. Must have qemu-system-i386 (but x86_64 should work too)."
+kernel/arch/x86/tty/tty.o: kernel/arch/x86/tty/tty.c
+ $(CC) -g -o $@ -ffreestanding -c kernel/arch/x86/tty/tty.c
+
+kernel/kernel.o: kernel/kernel.c
+ $(CC) -g -o $@ -Iinclude/arch/x86 -ffreestanding -c kernel/kernel.c
+
+clean:
+ rm boot/x86/boot kernel/kernel.bin ${KERNEL_OBJ} boot.img
-.PHONY = clean run help
+.PHONY: all clean