Linux SPARSE checker discussions
 help / color / mirror / Atom feed
* [PATCH] Makefile: add version.h dependency on all objects
@ 2021-01-27 16:58 Kyle Russell
  2021-01-27 20:47 ` Luc Van Oostenryck
  0 siblings, 1 reply; 2+ messages in thread
From: Kyle Russell @ 2021-01-27 16:58 UTC (permalink / raw)
  To: linux-sparse; +Cc: Kyle Russell

This guarantees the generated version.h will exist before attempting
to compile any c files that include it.

Several source files include the generated version.h, but not all
declare a proper make dependency.

$ grep -r 'version\.h' *.c
compile-i386.c:#include "version.h"
lib.c:#include "version.h"
options.c:#include "version.h"

This allows a sufficiently parallelized make invocation to encounter
ENOENT.

  CC      compile-i386.o
compile-i386.c:60:21: fatal error: version.h: No such file or directory
compilation terminated.
Makefile:253: recipe for target 'compile-i386.o' failed
make: *** [compile-i386.o] Error 1

Signed-off-by: Kyle Russell <bkylerussell@gmail.com>
---
 Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 31366446..dbad0f7a 100644
--- a/Makefile
+++ b/Makefile
@@ -249,7 +249,7 @@ libsparse.a: $(LIB_OBJS)
 
 
 cflags   += $($(*)-cflags) $(CPPFLAGS) $(CFLAGS)
-%.o: %.c
+%.o: %.c version.h
 	@echo "  CC      $@"
 	$(Q)$(CC) $(cflags) -c -o $@ $<
 
@@ -260,7 +260,6 @@ cflags   += $($(*)-cflags) $(CPPFLAGS) $(CFLAGS)
 selfcheck: $(OBJS:.o=.sc)
 
 SPARSE_VERSION:=$(shell git describe --dirty 2>/dev/null || echo '$(VERSION)')
-lib.o: version.h
 version.h: FORCE
 	@echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > version.h.tmp
 	@if cmp -s version.h version.h.tmp; then \
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-27 20:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-27 16:58 [PATCH] Makefile: add version.h dependency on all objects Kyle Russell
2021-01-27 20:47 ` Luc Van Oostenryck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox