[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Variable expansion in recipes
From: |
Sébastien Hinderer |
Subject: |
Re: Variable expansion in recipes |
Date: |
Fri, 2 Jun 2017 15:59:22 +0200 |
Dear Brian,
Many thanks for your response.
Brian Vandenberg (2017/05/30 14:34 -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
I meant (b), sorry for having been unclear.
> 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:
Yeah that's it. Using a variable whose value is modified between
different parts of the Makefile.
> 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}
So what I ended up doing was to save the content of the variable in a
per-target variable which could then be used in the recipe and that
worked.
Thanks again for your help!
Sébastien.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Variable expansion in recipes,
Sébastien Hinderer <=