X-Git-Url: http://git.dujemihanovic.xyz/posts?a=blobdiff_plain;f=Makefile;h=848c7959b14d9a1d439b3980c83cf7c6dedc0ce4;hb=0b02cbac466992423caa450f9659b18d251a4158;hp=7001c99b6359d03cd4b26c934e903e2b0079e473;hpb=c9f2bccb44c5437f1cae0862b2c84d3af47eade8;p=nameless-os.git diff --git a/Makefile b/Makefile index 7001c99..848c795 100644 --- a/Makefile +++ b/Makefile @@ -2,25 +2,42 @@ AS = yasm LD = i686-elf-ld CC = i686-elf-gcc -all: boot.img +GIT_REV = $(shell git rev-parse --short HEAD) -boot.img: boot kernel/kernel.bin - cat boot kernel/kernel.bin > $@ +CFLAGS = -std=gnu89 -g -Iinclude/arch/x86 -ffreestanding -DGIT_COMMIT=\"$(GIT_REV)\" + +KERNEL_OBJ = kernel/entry.o kernel/arch/x86/tty/tty.o kernel/drivers/irq/i8259a.o kernel/arch/x86/irq/idt.o kernel/arch/x86/irq/sample_handler.o kernel/kernel.o + +all: boot.img kernel/kernel.elf + +boot.img: boot/x86/boot kernel/kernel.bin + cat boot/x86/boot kernel/kernel.bin > $@ truncate -s1440K $@ -boot: boot.s - $(AS) -f bin boot.s -o $@ +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/entry.o kernel/kernel.o - $(LD) -o $@ -Ttext 0x1000 kernel/entry.o kernel/kernel.o --oformat=binary +kernel/kernel.bin: ${KERNEL_OBJ} + $(LD) -o $@ -T kernel/linker.ld ${KERNEL_OBJ} kernel/entry.o: kernel/entry.s $(AS) -f elf kernel/entry.s -o $@ +kernel/arch/x86/tty/tty.o: kernel/arch/x86/tty/tty.c + +kernel/drivers/irq/i8259a.o: kernel/drivers/irq/i8259a.c + +kernel/arch/x86/irq/idt.o: kernel/arch/x86/irq/idt.c + +kernel/arch/x86/irq/sample_handler.o: kernel/arch/x86/irq/sample_handler.c + $(CC) $(CFLAGS) -mgeneral-regs-only -c kernel/arch/x86/irq/sample_handler.c -o $@ + kernel/kernel.o: kernel/kernel.c - $(CC) -o $@ -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 kernel/kernel.bin kernel/entry.o kernel/kernel.o boot.img + rm boot/x86/boot kernel/kernel.bin kernel/kernel.elf ${KERNEL_OBJ} boot.img .PHONY: all clean