Add header dependencies to Makefiles

This commit is contained in:
mintsuki 2020-09-21 12:46:42 +02:00
parent f245d0e280
commit c869ab6f85
3 changed files with 15 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/**/*.o
/**/*.d
/**/*.a
/**/*.bin
/**/*.bin.gz

View File

@ -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 $@

View File

@ -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 $@