Skip to content

Commit

Permalink
fix support for incremental rebuilds as set out by 436044
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeremybobbin committed Jun 11, 2024
1 parent a7aac10 commit 2925724
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/config.h
/config.mk
/dependency
/obj
/vis
/vis-menu
/vis-single
Expand All @@ -13,3 +12,4 @@
*.gcov
*.html
*.d
*.o
18 changes: 6 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2925724

Please sign in to comment.