From 03ea9975ebe19774d6a4b83438f11d43c5367396 Mon Sep 17 00:00:00 2001 From: David Gailleton Date: Tue, 11 Nov 2025 14:16:20 +0100 Subject: [PATCH] depedency files add to Makefile --- Makefile | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5592593..8099728 100644 --- a/Makefile +++ b/Makefile @@ -59,18 +59,33 @@ OBJ = $(SRC:.c=.o) BONUS_OBJ = $(BONUS_SRC:.c=.o) +DEP = $(SRC:.c=.d) + +BONUS_DEP = $(BONUS_SRC:.c=.d) + +ALL_SRC = $(SRC) $(BONUS_SRC) + +ALL_OBJ = $(OBJ) $(BONUS_OBJ) + +ALL_DEP = $(DEP) $(BONUS_DEP) + %.o: %.c $(CC) -o $@ -c $< $(CFLAGS) -I$(HEADER) +%.d: %.c + @set -e; rm -f $@; \ + $(CC) -M $(CFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ -$(NAME): $(OBJ) $(HEADER) +$(NAME): $(OBJ) $(DEP) $(AR) $(ARFLAGS) $(NAME) $(OBJ) ranlib $(NAME) all: $(NAME) -bonus: $(OBJ) $(BONUS_OBJ) $(HEADER) +bonus: $(ALL_OBJ) $(ALL_DEP) $(AR) $(ARFLAGS) $(NAME) $(OBJ) $(BONUS_OBJ) ranlib $(NAME) @@ -82,4 +97,6 @@ fclean: clean re: fclean all +-include $(ALL_DEP) + .PHONY: all clean fclean re bonus