From 292572443a042bdd246b3d9a12dc78de0850611a Mon Sep 17 00:00:00 2001 From: Jeremy Bobbin Date: Mon, 10 Jun 2024 19:14:01 -0700 Subject: [PATCH] fix support for incremental rebuilds as set out by 436044 the POSIX Makefile macro ".c.o"(reintroduced into this patch), for example, compiles text.c -> text.o, if text.o is either older, or it doesn't exist. this was removed in patches 4ca7119 & 09ba77a, after which, if you modify any C file, vis would not be re-compiled. the goal of 4ca7119 was to stop the base directory from being polluted with .o & .d files. This patch polluates the base directory. the only simple alternative to .c.o, which doesn't pollute, is the following: obj/%.o: %.c ${CC} ${CFLAGS} ${CFLAGS_VIS} -c $< -o $@ this is not POSIX, however. --- .gitignore | 2 +- Makefile | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 9b114f294..b62256bbf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ /config.h /config.mk /dependency -/obj /vis /vis-menu /vis-single @@ -13,3 +12,4 @@ *.gcov *.html *.d +*.o diff --git a/Makefile b/Makefile index a2f1df35f..27101a2fe 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ SRC = array.c \ vis-text-objects.c \ vis.c \ $(REGEX_SRC) -OBJ = $(SRC:%.c=obj/%.o) +OBJ = $(SRC:%.c=%.o) ELF = vis vis-menu vis-digraph EXECUTABLES = $(ELF) vis-clipboard vis-complete vis-open @@ -82,16 +82,11 @@ config.h: config.mk: @touch $@ -obj/.tstamp: - mkdir obj - touch obj/.tstamp +.c.o: + ${CC} ${CFLAGS} ${CFLAGS_VIS} ${CFLAGS_EXTRA} -o $@ -c $< -obj/main.o: config.h - -$(OBJ): config.mk obj/.tstamp - ${CC} ${CFLAGS} ${CFLAGS_VIS} ${CFLAGS_EXTRA} -o $@ -c $(@:obj/%.o=%.c) - --include obj/*.d +-include *.d +${OBJ}: config.mk config.h vis: ${OBJ} ${CC} -o $@ ${OBJ} ${LDFLAGS} ${LDFLAGS_VIS} ${LDFLAGS_EXTRA} @@ -157,8 +152,7 @@ testclean: clean: @echo cleaning - @rm -rf obj - @rm -f $(ELF) vis-single vis-single-payload.inc vis-*.tar.gz *.gcov *.gcda *.gcno *.d + @rm -f $(ELF) $(OBJ) vis-single vis-single-payload.inc vis-*.tar.gz *.gcov *.gcda *.gcno *.d distclean: clean testclean @echo cleaning build configuration