Skip to content

Commit

Permalink
build: add dependency tracking for header files
Browse files Browse the repository at this point in the history
  • Loading branch information
rnpnr committed Jul 31, 2023
1 parent 583ee82 commit 4cd1abb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
*.gcov
*.html
*.o
*.d
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -74,6 +75,8 @@ DOCKER?=docker

all: $(ELF)

-include $(DEP)

.c.o:
${CC} ${CFLAGS} ${CFLAGS_VIS} ${CFLAGS_EXTRA} -o $@ -c $<

Expand All @@ -83,9 +86,9 @@ config.h:
config.mk:
@touch $@

$(OBJ): config.mk config.h
$(OBJ): config.mk

vis: config.h config.mk *.h ${OBJ}
vis: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS} ${LDFLAGS_VIS} ${LDFLAGS_EXTRA}

vis-menu: vis-menu.c
Expand Down Expand Up @@ -154,7 +157,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
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4cd1abb

Please sign in to comment.