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

Re: [PATCH 2/8] Documentation/Makefile: conditionally include ../GIT-VERSION-FILE

From
Jeff King <peff@peff.net>
Date
Nov 6, 2020, 20:56 UTC
Message-ID
<20201106205618.GA197338@coredump.intra.peff.net>
In-Reply-To
<a654c95f-2367-5805-d4f8-56c466a141d4@ramsayjones.plus.com>
On Fri, Nov 06, 2020 at 07:38:06PM +0000, Ramsay Jones wrote:
Show 18 quoted lines
> I hadn't done so yet, but I had planned to modify the GIT-VERSION-GEN script
> (with -v parameter, say) to just output the version to stdout, because it
> would save a sed invocation. It currently looks something like this:
> 
>   diff --git a/Makefile b/Makefile
>   index 372139f1f2..f166fbe067 100644
>   --- a/Makefile
>   +++ b/Makefile
>   @@ -493,7 +493,11 @@ all::
>  
>    GIT-VERSION-FILE: FORCE
>           @$(SHELL_PATH) ./GIT-VERSION-GEN
>   --include GIT-VERSION-FILE
>   +
>   +ifeq ($(wildcard GIT-VERSION-FILE),)
>   +$(shell ./GIT-VERSION-GEN)
>   +endif
>   +GIT_VERSION = $(eval GIT_VERSION := $$(shell cat GIT-VERSION-FILE | sed -e 's/^GIT_VERSION = //'))$(GIT_VERSION)

Yeah, not too surprising. If we grow a lot of these fill-in-the-value stubs, it might be worth abstracting it out into a function (using $(call) should be OK, as even Apple's ancient version of GNU make has it).

I do think the one that evals an "include" might end up being more readable and flexible, though. I'm not sure if the include needs to be more aggressive about using ":=" though (in a simple test it didn't seem to be, and since we'll be filling in a concrete value that's OK to evaluate multiple times, I think it would be OK).

> Ignore the 'ifeq' for now (I had several versions, including getting rid
> of the GIT-VERSION-FILE rule, but that caused problems without changing
> the Documentation/Makefile, and several others ... (including in contrib)).

Yeah, I didn't look at all at what complications we might get from other Makefiles. Though if everything is literally running `GIT-VERSION-GEN` directly then I think they could all use the same code.

> So, I haven't worked everything out yet, but I had planned to look at
> this next.

Sounds good. I mostly wanted to plant the seed in your head. Finding that it was already growing is better still. :)

-Peff
Previous: Ramsay JonesNext: Junio C Hamano
Message 6 of 7 in “Documentation/Makefile: conditionally include ../GIT-VERSION-FILE”
  1. 2/8 Documentation/Makefile: conditionally include ../GIT-VERSION-FILERamsay Jones, Nov 5, 2020
  2. Junio C HamanoNov 5, 2020
  3. Ramsay JonesNov 6, 2020
  4. Jeff KingNov 6, 2020
  5. Ramsay JonesNov 6, 2020
  6. Jeff KingNov 6, 2020
  7. Junio C HamanoNov 6, 2020

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.