From 561ec9a7c440f8f15f28c714c3907a443923910c Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Sun, 30 Jul 2023 21:26:01 -0600 Subject: [PATCH] build: add dependency tracking for header files --- .gitignore | 1 + Makefile | 13 +++++++++---- configure | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 7aa3fae06..950e4d84a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ *.gcov *.html *.o +*.d diff --git a/Makefile b/Makefile index 585b826c0..0fd5fa905 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ SRC = array.c \ vis-text-objects.c \ $(REGEX_SRC) OBJ = $(SRC:.c=.o) +DEP = $(OBJ:.o=.d) ELF = vis vis-menu vis-digraph EXECUTABLES = $(ELF) vis-clipboard vis-complete vis-open @@ -46,7 +47,7 @@ CONFIG_TRE ?= 0 CONFIG_ACL ?= 0 CONFIG_SELINUX ?= 0 -CFLAGS_STD ?= -std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DNDEBUG +CFLAGS_STD ?= -std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DNDEBUG -MMD CFLAGS_STD += -DVERSION=\"${VERSION}\" LDFLAGS_STD ?= -lc @@ -83,9 +84,13 @@ config.h: config.mk: @touch $@ -$(OBJ): config.mk config.h +main.o: config.h -vis: config.h config.mk *.h ${OBJ} +$(OBJ): config.mk + +-include $(DEP) + +vis: ${OBJ} ${CC} -o $@ ${OBJ} ${LDFLAGS} ${LDFLAGS_VIS} ${LDFLAGS_EXTRA} vis-menu: vis-menu.c @@ -154,7 +159,7 @@ testclean: clean: @echo cleaning - @rm -f $(ELF) $(OBJ) vis-single vis-single-payload.inc vis-*.tar.gz *.gcov *.gcda *.gcno + @rm -f $(ELF) $(OBJ) $(DEP) vis-single vis-single-payload.inc vis-*.tar.gz *.gcov *.gcda *.gcno distclean: clean testclean @echo cleaning build configuration diff --git a/configure b/configure index d71ab78b1..5d7c821bf 100755 --- a/configure +++ b/configure @@ -220,7 +220,7 @@ tryflag CFLAGS_TRY -Werror=unused-command-line-argument tryldflag LDFLAGS_TRY -Werror=unknown-warning-option tryldflag LDFLAGS_TRY -Werror=unused-command-line-argument -CFLAGS_STD="-std=c99 -D_POSIX_C_SOURCE=200809L -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG" +CFLAGS_STD="-std=c99 -D_POSIX_C_SOURCE=200809L -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG -MMD" LDFLAGS_STD="-lc" OS=$(uname)