help-make
[Top][All Lists]
Advanced

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

RE: Call with computed variable names


From: David Kilroy
Subject: RE: Call with computed variable names
Date: Thu, 16 Sep 2004 17:00:32 +0100

Ken Smith wrote:
> On Thu, Sep 16, 2004 at 11:08:03AM +0100, David Kilroy wrote:
>> 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.
 
Thank you Ken.

I did eventually find that section of the manual. However that didn't
entirely cure my problem.

My new problem, still related to computed variables, eval, call and friends
is shown below. In this case the dependencies of a target do not appear to
be expanded correctly.

I've tried various combinations of adding extra $, and using the value
function to no avail. Any help appreciated.

Thanks,

Dave.

dkilroy
$ cat Makefile

FOO_SRCS=foo.c

define TEMPLATE
$(1)_OBJS=$$($(1)_SRCS:.c=.o)
$(1)_TGT = foo

$$($(1)_TGT) : $(1)_FLAG=bar
$$($(1)_TGT) : $(value $(1)_OBJS)
endef

$(eval $(call TEMPLATE,FOO))

all: foo

foo :
        @echo Sources are $(FOO_SRCS)
        @echo Objects are $(FOO_OBJS)
        @echo Flags are $(FOO_FLAG)
        @echo foo.o depends on $^

dkilroy
$ make
Sources are foo.c
Objects are foo.o
Flags are bar
foo.o depends on

dkilroy
$




reply via email to

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