[Top][All Lists]

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

Re: pattern matching and computed variable names

From: Philip Guenther
Subject: Re: pattern matching and computed variable names
Date: Sat, 27 Feb 2010 16:50:54 -0800

On Sat, Feb 27, 2010 at 7:01 AM, P C <address@hidden> wrote:
> I tried to use pattern % to compute a variable name, but the following 
> doesn't work:
> .f90:
> myvar = foo
> myvar:%:$(%).f90
>   address@hidden $^
> make myvar gives:
> .f90
> instead of the foo.f90. Is this expected? Is there a work around it? Thanks!

Yes, that's the expected behavior.  Variable expansion in the target
and prerequisite list of a rule is immediate and not deferred, so that
expands $% while reading the Makefile, where it expands to the empty
string.  You need to use secondary expansion to get the result you
want, using something like:

        @echo $^

Read section 3.10, "Secondary Expansion", of the info pages for details.

Philip Guenther

reply via email to

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