[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Variable expansion in recipes
From: |
Brian Vandenberg |
Subject: |
Re: Variable expansion in recipes |
Date: |
Tue, 30 May 2017 14:34:24 -0600 |
There's two ways I'm parsing what you're asking:
a) use ${SOMEVAR} without recursive expansion
b) expand ${SOMEVAR} ahead of time, presumably so it doesn't expand it
multiple times
For (a) you'd use $(value SOMEVAR).
For (b) you can do it but may not be straightforward. Which you choose
depends on why you want to do it:
1) Use $(eval) because expansion of ${SOMEVAR} is expensive; or because it
has side effects; or because you want to dynamically create recipes (meta
programming):
$(eval RECIPE = some stuff using ${SOMEVAR})
2) Pre-expand an operation & save into another variable either because it's
expensive or because the result could change depending on
environment/context:
old:
RECIPE = some stuff using $(shell pkg-config --cflags glib)
or
RECIPE = some stuff using `pkg-config --cflags glib`
new:
SOMEVAR := $(shell pkg-config --cflags glib)
RECIPE = some stuff using ${SOMEVAR}
-brian
On Tue, May 30, 2017 at 6:40 AM, Sébastien Hinderer <
address@hidden> wrote:
> Dear all,
>
> Is there a way to have make substitute a variable by its value in
> a recipe when the recipe is read, rather than when the recipe is used?
>
> Thanks,
>
> Sébastien.
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-make
>