:: commit c869ab6f8559f09a69086027ec7610f37f7763a4

mintsuki <mintsuki@protonmail.com> — 2020-09-21 10:46

parents: f245d0e280

Add header dependencies to Makefiles

diff --git a/.gitignore b/.gitignore
index 4a6d47c3..7fcab45d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 /**/*.o
+/**/*.d
 /**/*.a
 /**/*.bin
 /**/*.bin.gz
diff --git a/decompressor/Makefile b/decompressor/Makefile
index 1f78f0d3..2186687d 100644
--- a/decompressor/Makefile
+++ b/decompressor/Makefile
@@ -10,14 +10,15 @@ INTERNAL_CFLAGS =  \
 	-fno-stack-protector \
 	-fno-pic \
 	-fomit-frame-pointer \
+	-Wno-address-of-packed-member \
 	-masm=intel \
 	-mno-80387 \
 	-mno-mmx \
 	-mno-3dnow \
 	-mno-sse \
 	-mno-sse2 \
-	-I. \
-	-Wno-address-of-packed-member
+	-MMD \
+	-I.
 
 LDFLAGS = -flto -Os
 
@@ -34,6 +35,7 @@ INTERNAL_LDFLAGS = \
 C_FILES := $(shell find ./ -type f -name '*.c' | sort)
 ASM_FILES := $(shell find ./ -type f -name '*.asm' | sort)
 OBJ := $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o)
+HEADER_DEPS := $(C_FILES:.c=.d)
 
 all: decompressor.bin
 
@@ -41,6 +43,8 @@ decompressor.bin: $(OBJ)
 	$(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o decompressor.elf
 	$(OBJCOPY) -O binary decompressor.elf decompressor.bin
 
+-include $(HEADER_DEPS)
+
 %.o: %.c
 	$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
 
diff --git a/stage2/Makefile b/stage2/Makefile
index 1e998921..97728305 100644
--- a/stage2/Makefile
+++ b/stage2/Makefile
@@ -11,15 +11,16 @@ INTERNAL_CFLAGS =  \
 	-fno-stack-protector \
 	-fno-pic \
 	-fomit-frame-pointer \
+	-Wno-address-of-packed-member \
 	-masm=intel \
 	-mno-80387 \
 	-mno-mmx \
 	-mno-3dnow \
 	-mno-sse \
 	-mno-sse2 \
+	-MMD \
 	-I. \
-	-I.. \
-	-Wno-address-of-packed-member
+	-I..
 
 LDFLAGS = -flto -Os
 
@@ -36,13 +37,16 @@ INTERNAL_LDFLAGS = \
 C_FILES := $(shell find ./ -type f -name '*.c' | sort)
 ASM_FILES := $(shell find ./ -type f -name '*.asm' | sort)
 OBJ := $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o)
+HEADER_DEPS := $(C_FILES:.c=.d)
 
-all: limine.bin
+all: stage2.bin
 
-limine.bin: $(OBJ)
+stage2.bin: $(OBJ)
 	$(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o stage2.elf
 	$(OBJCOPY) -O binary stage2.elf stage2.bin
 
+-include $(HEADER_DEPS)
+
 %.o: %.c
 	$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
 
tab: 248 wrap: offon