help-make
[Top][All Lists]
Advanced

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

Re: pattern matching and computed variable names


From: P C
Subject: Re: pattern matching and computed variable names
Date: Sun, 28 Feb 2010 11:47:50 -0800 (PST)

Fantastic! I could simplify significantly my makefile.
Thanks!



----- Original Message ----
From: Philip Guenther <address@hidden>
To: P C <address@hidden>
Cc: address@hidden
Sent: Sun, February 28, 2010 1:50:54 AM
Subject: Re: pattern matching and computed variable names

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
>    @echo $^
>
> 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:

.SECONDEXPANSION:
myvar:%:$$($$@).f90
        @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]