[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using named variables in canned recipes
From: |
Paul Smith |
Subject: |
Re: Using named variables in canned recipes |
Date: |
Sun, 12 Mar 2017 11:10:10 -0400 |
On Sun, 2017-03-12 at 18:15 +1100, Tony Theodore wrote:
> It seems the variable `prog` is in scope from the calling loop and
> can be referenced in the template:
>
> define PROGRAM_template =
> $(prog): $$($(prog)_OBJS) $$($(prog)_LIBS:%=-l%)
> ALL_OBJS += $$($(prog)_OBJS)
> endef
>
> I was wondering if this is defined behaviour and can be relied upon
> to work in future versions of make?
Yes, absolutely. The point of the foreach function is that the loop
variable is visible in the scope of the loop body... otherwise foreach
is almost useless.