help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: if function combined with filter or findstring with eval


From: Philip Guenther
Subject: Re: if function combined with filter or findstring with eval
Date: Thu, 20 Oct 2016 14:39:27 -0700

On Thu, Oct 20, 2016 at 2:22 PM, Scott Kruger <address@hidden> wrote:
> I am trying to construct a simple list of variables
> whose values match certain patterns.  It seems
> straightforward, but I can't get the righ t
>
> The makefile is:
> ----------
> RUNTESTS=runex1 runex2 runex3
> RUNTESTS_ARGS=$(foreach runtest, $(RUNTESTS), $(runtest)_ARGS)
>
> ifdef argsearch
>   FOO:=$(foreach rarg, $(RUNTESTS_ARGS), $(if $(findstring
> $(argsearch),$(eval $(value rarg))), $(rarg)))

You use := here so this will be evaluated *IMMEDIATELY*, before the
rest of the Makefile is parsed and therefore before the runex*_ARGS
variables are set.  Either put those assignments before this
assignment, or use '=' instead of ':='.

Next, you don't want $(eval).  That's for creating rules or doing
assignments while in the middle of an expansion.  You don't need that,
you just need to get the value of the variable whose name is $(rarg).
You just need two levels of $(), though using $(value $(rarg)) is
probably best.

So:

FOO=$(foreach rarg,$(RUNTESTS_ARGS),$(if $(findstring
$(argsearch),$(value $(rarg))),$(rarg)))


With that:
$ gmake argsearch=foo
>runex1_ARGS runex2_ARGS
$


Philip Guenther



reply via email to

[Prev in Thread] Current Thread [Next in Thread]