[PATCH] Makefile: add version.h dependency on all objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux