From aedfdf1f1445cf9fa63fb53c42878240a9ff65ae Mon Sep 17 00:00:00 2001
From: =?utf8?q?Duje=20Mihanovi=C4=87?= <duje.mihanovic@skole.hr>
Date: Sun, 17 Oct 2021 13:19:52 +0200
Subject: [PATCH] Simplify Makefile

---
 Makefile | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index c8f15f3..848c795 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,8 @@ CC = i686-elf-gcc
 
 GIT_REV = $(shell git rev-parse --short HEAD)
 
+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
@@ -16,25 +18,21 @@ boot/x86/boot: boot/x86/boot.s boot/x86/a20.s boot/x86/protected.s boot/x86/prin
 	$(AS) -f bin boot/x86/boot.s -o $@
 
 kernel/kernel.bin: ${KERNEL_OBJ}
-	$(LD) -o $@ -T kernel/linker.ld ${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
-	$(CC) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -c kernel/arch/x86/tty/tty.c
 
 kernel/drivers/irq/i8259a.o: kernel/drivers/irq/i8259a.c
-	$(CC) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -c kernel/drivers/irq/i8259a.c
 
 kernel/arch/x86/irq/idt.o: kernel/arch/x86/irq/idt.c
-	$(CC) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -c kernel/arch/x86/irq/idt.c
 
 kernel/arch/x86/irq/sample_handler.o: kernel/arch/x86/irq/sample_handler.c
-	$(CC) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -mgeneral-regs-only -c 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) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -DGIT_COMMIT=\"$(GIT_REV)\" -c kernel/kernel.c
 
 kernel/kernel.elf: kernel/kernel.bin
 	$(LD) -o $@ -T kernel/linker.ld ${KERNEL_OBJ} --oformat=elf32-i386
-- 
2.39.5