Re: Temporary variables in make .for loops

From: Tijl Coosemans <>
Date: Fri, 11 Nov 2022 13:56:35 UTC
On Fri, 11 Nov 2022 15:41:51 +0300 Gleb Popov <> wrote:
> Hello fellow porters.
> My variable modifiers are growing and become too incomprehensible, so
> here is the question I wanted to ask long ago:
> How do I make and use a temporary variable in the .for loop?
> This is what I have in Mk/Uses/
> .  for package in ${_use_cabal}
> _PKG_GROUP=        ${package:C/[\.-]//g}
> MASTER_SITES+=${package:C/[\.-]//g}
> .  endfor
> I'd like to write ${_PKG_GROUP} instead of repeating that regexp
> incantation, but due to specifics of .for operation it doesn't work.
> Using := with _PKG_GROUP also doesn't fix the problem.
> Now I need to add another regexp substitution to every expression
> inside this loop and it'll become even less readable than before.
> Is there a clean solution to this problem?

You could use a nested .for loop:

.  for package in ${_use_cabal}
.    for pkg_group pkg_norev rev in \
	${package:C/[.-]//g} ${packa...} ${packa...}

You can drop the backslash by the way.