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