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

Re: [PATCH 1/4] Makefile: don't re-define PERL_DEFINES

From
Jeff King <peff@peff.net>
Date
May 6, 2021, 16:55 UTC
Message-ID
<YJQfnviIeK7UdCBy@coredump.intra.peff.net>
In-Reply-To
<xmqq4kfg3c4v.fsf@gitster.g>
On Thu, May 06, 2021 at 10:05:20AM +0900, Junio C Hamano wrote:
Show 19 quoted lines
> As to the simply-expanded vs recursively-expanded variable, there is
> aneed to use former, which comes from what the original commit
> 07d90ead did outside the context of this patch, which is:
> 
>     PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))
>     GIT-PERL-DEFINES: FORCE
>             @FLAGS='$(PERL_DEFINES)'; \
>                 if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \
>                     echo >&2 "    * new perl-specific parameters"; \
>                     echo "$$FLAGS" >$@; \
>                 fi
> 
> That is, up to this point PERL_DEFINES accumulate various build-time
> settings with += (i.e. space separated tokens), and at this point
> finally it is turned into a colon separated tokens, which cannot be
> written with a recursively expanded variable.
> 
> But I tend to agree that you do not have to := clear the list in
> this patch.
OK, that matches my understanding. Thanks for laying out.

In general, I would say that the later use that you quoted above would do better to use a second variable (because then there is no question of when PERL_DEFINES is space-separated and when it is colon-separated). But that is not that big a deal, and certainly very orthogonal to Ævar's patch.

I'd also question whether the colon transformation is even necessary. The point of the file is to change when the values change. Being sloppy with delimiters means we _could_ miss a change, but in practice I doubt it is very likely (and it is not like colons cannot appear in values, either, so they are not foolproof). But again, not really important for this patch.

-Peff

P.S. I also wondered briefly if make would preserve spaces even for empty variables (since without that, we might miss delimiters and confuse one of the variables for another). I.e., we know that:

  FOO = $(one):$(two):$(three)

will have two colons even if some of the variables are empty. But does it preserve them even for "$(one) $(two) $(three)", or more importantly, when using "+=" (which _would_ be relevant to this patch)? The answer is yes, they are all fine.

You can demonstrate it with the Makefile below, running "make one=foo three=bar", "make two=foo", etc.

-- >8 -- empty := space := $(empty) $(empty)

COLONS = $(one):$(two):$(three)

SPACES_SINGLE = $(one) $(two) $(three) SPACES_SINGLE := $(subst $(space),:,$(SPACES_SINGLE))

SPACES_PLUS = SPACES_PLUS += $(one) SPACES_PLUS += $(two) SPACES_PLUS += $(three) SPACES_PLUS := $(subst $(space),:,$(SPACES_PLUS))

all:
	@echo "COLONS=$(COLONS)"
	@echo "SPACES_SINGLE=$(SPACES_SINGLE)"
	@echo "SPACES_PLUS=$(SPACES_PLUS)"
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 5 of 26 in “Makefile/perl: correctly re-generate build/* + speed up under NO_GETTEXT=Y”
  1. 0/4 Makefile/perl: correctly re-generate build/* + speed up under NO_GETTEXT=YÆvar Arnfjörð Bjarmason, May 5, 2021
  2. 1/4 Makefile: don't re-define PERL_DEFINESÆvar Arnfjörð Bjarmason, May 5, 2021
  3. Jeff KingMay 5, 2021
  4. Junio C HamanoMay 6, 2021
  5. Jeff KingMay 6, 2021
  6. Ævar Arnfjörð BjarmasonMay 6, 2021
  7. Junio C HamanoMay 6, 2021
  8. Ævar Arnfjörð BjarmasonMay 6, 2021
  9. Jeff KingMay 6, 2021
  10. Junio C HamanoMay 7, 2021
  11. 3/4 Makefile: regenerate *.pm on NO_PERL_CPAN_FALLBACKS changeÆvar Arnfjörð Bjarmason, May 5, 2021
  12. 2/4 Makefile: regenerate perl/build/* if GIT-PERL-DEFINES changesÆvar Arnfjörð Bjarmason, May 5, 2021
  13. 4/4 perl: use mock i18n functions under NO_GETTEXT=YÆvar Arnfjörð Bjarmason, May 5, 2021
  14. 0/6 Makefile/perl: correctly re-generate build/* + speed up under NO_GETTEXT=YÆvar Arnfjörð Bjarmason, May 10, 2021
  15. 1/6 Makefile: regenerate perl/build/* if GIT-PERL-DEFINES changesÆvar Arnfjörð Bjarmason, May 10, 2021
  16. 2/6 Makefile: don't re-define PERL_DEFINESÆvar Arnfjörð Bjarmason, May 10, 2021
  17. 4/6 Makefile: split up the deceleration of PERL_DEFINESÆvar Arnfjörð Bjarmason, May 10, 2021
  18. 3/6 Makefile: make PERL_DEFINES recursively expandedÆvar Arnfjörð Bjarmason, May 10, 2021
  19. 6/6 perl: use mock i18n functions under NO_GETTEXT=YÆvar Arnfjörð Bjarmason, May 10, 2021
  20. 5/6 Makefile: regenerate *.pm on NO_PERL_CPAN_FALLBACKS changeÆvar Arnfjörð Bjarmason, May 10, 2021
  21. Junio C HamanoMay 10, 2021
  22. Ævar Arnfjörð BjarmasonMay 11, 2021
  23. Junio C HamanoMay 11, 2021
  24. Makefile: make PERL_DEFINES recursively expandedÆvar Arnfjörð Bjarmason, May 12, 2021
  25. Jeff KingMay 12, 2021
  26. Junio C HamanoMay 12, 2021

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.