git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH resend] Makefile: Use computed header dependencies if the compiler supports it

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 14, 2011, 19:00 UTC
Message-ID
<20110814190050.GA16819@elie.gateway.2wire.net>
In-Reply-To
<1313347512-7815-1-git-send-email-frekui@gmail.com>
Hi,
Fredrik Kuivinen wrote:
> Previously you had to manually define COMPUTE_HEADER_DEPENDENCIES to
> enable this feature. It seemed a bit sad that such a useful feature
> had to be enabled manually.
Yes!  Thanks for this.
I have a few thoughts about the implementation:
> --- a/Makefile
> +++ b/Makefile
[...]
Show 13 quoted lines
> @@ -1236,6 +1232,15 @@ endif
>  ifdef CHECK_HEADER_DEPENDENCIES
>  COMPUTE_HEADER_DEPENDENCIES =
>  USE_COMPUTED_HEADER_DEPENDENCIES =
> +else
> +dep_check = $(shell sh -c \
> +	': > ++empty.c; \
> +	$(CC) -c -MF /dev/null -MMD -MP ++empty.c -o /dev/null 2>&1; \
> +	echo $$?; \
> +	$(RM) ++empty.c')
> +ifeq ($(dep_check),0)
> +COMPUTE_HEADER_DEPENDENCIES=YesPlease
> +endif

This causes "make foo" to run gcc and create a temporary file unconditionally, regardless of what foo is. In an ideal world:

 - the autodetection would only happen when building targets that
   care about it
 - the detection would happen once (creating some file to store the
   result) and not be repeated with each invocation of "make"
 - (maybe) there would be a way to override the detection with
   either a "yes" or "no" result, for those who really care to
   save a little time.

I was about to say that the GIT_VERSION variable has some of these properties, but now that I check, from the point of view of the Makefile it doesn't. ./GIT-VERSION-GEN is just very fast. :)

I wonder if we can make do with a faster check, like
	$(CC) -c -MF /dev/null -MMD -MP git.c --help >/dev/null 2>&1
What do you think?
Previous: Fredrik KuivinenNext: Fredrik Kuivinen
Message 2 of 6 in “Makefile: Use computed header dependencies if the compiler supports it”
  1. Makefile: Use computed header dependencies if the compiler supports itFredrik Kuivinen, Aug 14, 2011
  2. Jonathan NiederAug 14, 2011
  3. Fredrik KuivinenAug 14, 2011
  4. Jonathan NiederAug 14, 2011
  5. Fredrik KuivinenAug 18, 2011
  6. Jonathan NiederAug 18, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.