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