]> git.dujemihanovic.xyz Git - nameless-os.git/blobdiff - Makefile
Better gitignore and tidier string
[nameless-os.git] / Makefile
index 9d95b1ef97134bcebc837fe4ab4cfab1e6fff45a..a4c88b392be52822dea6e890cacc9b200b7acdcd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,31 @@
-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 kernel/kernel.bin
+       cat boot kernel/kernel.bin > $@
+       truncate -s1440K $@
+
+boot: boot.s
+       $(AS) -f bin 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 kernel/kernel.bin ${KERNEL_OBJ} boot.img
 
-.PHONY = clean run help
+.PHONY: all clean