All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kyle Russell <bkylerussell@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Kyle Russell <bkylerussell@gmail.com>
Subject: [PATCH] Makefile: add version.h dependency on all objects
Date: Wed, 27 Jan 2021 11:58:56 -0500	[thread overview]
Message-ID: <20210127165856.2090337-1-bkylerussell@gmail.com> (raw)

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


             reply	other threads:[~2021-01-27 17:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 16:58 Kyle Russell [this message]
2021-01-27 20:47 ` [PATCH] Makefile: add version.h dependency on all objects Luc Van Oostenryck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210127165856.2090337-1-bkylerussell@gmail.com \
    --to=bkylerussell@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.