Fantastic! I could simplify significantly my makefile. Thanks!
----- Original Message ---- From: Philip Guenther <[email protected]> To: P C <[email protected]> Cc: [email protected] 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 <[email protected]> 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 _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
