[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Call with computed variable names
From: |
Ken Smith |
Subject: |
Re: Call with computed variable names |
Date: |
Thu, 16 Sep 2004 11:29:17 -0400 |
User-agent: |
Mutt/1.5.6i |
On Thu, Sep 16, 2004 at 11:08:03AM +0100, David Kilroy wrote:
> I've distilled a problem that I'm seeing to a minimal test case, see below.
>
> Essentially, when using the call function, the computed variable name does
> not appear to be evaluated correctly.
>
> Is this expected?
Yes. What is happening is that during the first evaluation of template,
all the $() are expanded. What you want is for the expansion of your
computed variable name to happen after the template has been evaluated
once so you need to use $$().
$(1)_VAR2=$$($(1)_VAR1)_def
After TEMPLATE is evaluated, this becomes what you expect.
FOO_VAR2=$(FOO_VAR1)_def
The reason for this is the explained in the third paragraph of section
8.8 of the GNUmake manual. If this doesn't clarify the issue, email me
offline and I'll try to explain in more detail.
>
> Thanks,
>
> Dave.
>
> PS. I'm running on cygwin (DLL 1.5.10) on winXP
>
>
> dkilroy
> $ cat Makefile
>
>
> define TEMPLATE
> $(1)_VAR1=abc
>
> $(1)_VAR2=$($(1)_VAR1)_def
> endef
>
> $(eval $(call TEMPLATE,FOO))
>
> all:
> @echo Expect FOO_VAR1 to be abc
> @echo FOO_VAR1 is $(FOO_VAR1)
> @echo Expect FOO_VAR2 to be abc_def
> @echo FOO_VAR2 is $(FOO_VAR2)
>
> dkilroy
> $ make -v
> GNU Make 3.80
> Copyright (C) 2002 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.
> There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
>
> dkilroy
> $ make
> Expect FOO_VAR1 to be abc
> FOO_VAR1 is abc
> Expect FOO_VAR2 to be abc_def
> FOO_VAR2 is _def
>
> dkilroy
> $
>
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-make