X-Git-Url: http://git.dujemihanovic.xyz/posts?a=blobdiff_plain;f=Makefile;h=ce6fccc146f48fb206005586f2beb4a3c5c5e970;hb=9ef60208fec0c672248023d467f57eecd6e7214f;hp=9d95b1ef97134bcebc837fe4ab4cfab1e6fff45a;hpb=73dce672626ceb415b49ff059092c48a2f7c3de3;p=nameless-os.git diff --git a/Makefile b/Makefile index 9d95b1e..ce6fccc 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,34 @@ -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 kernel/kernel.elf + +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} -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 + +kernel/kernel.elf: kernel/kernel.bin + $(LD) -o $@ -T kernel/linker.ld ${KERNEL_OBJ} --oformat=elf32-i386 + +clean: + rm boot/x86/boot kernel/kernel.bin ${KERNEL_OBJ} boot.img -.PHONY = clean run help +.PHONY: all clean