X-Git-Url: http://git.dujemihanovic.xyz/posts?a=blobdiff_plain;f=Makefile;h=848c7959b14d9a1d439b3980c83cf7c6dedc0ce4;hb=aedfdf1f1445cf9fa63fb53c42878240a9ff65ae;hp=9d1c34475a160d1bb3af2d6fd2ff3f28feb0169e;hpb=63853960825f007827a79f704d291c372c807096;p=nameless-os.git diff --git a/Makefile b/Makefile index 9d1c344..848c795 100644 --- a/Makefile +++ b/Makefile @@ -2,30 +2,42 @@ AS = yasm LD = i686-elf-ld CC = i686-elf-gcc -KERNEL_OBJ = kernel/entry.o kernel/arch/x86/tty/tty.o kernel/kernel.o +GIT_REV = $(shell git rev-parse --short HEAD) -all: boot.img +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/x86/boot: boot/x86/boot.s boot/x86/a20.s boot/x86/protected.s +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 + $(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 - $(CC) -g -o $@ -ffreestanding -c 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) -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 + rm boot/x86/boot kernel/kernel.bin kernel/kernel.elf ${KERNEL_OBJ} boot.img .PHONY: all clean