In a Makefile, I'm trying to assign the result of a shell command to a variable:
but
is echoing 2 different values, eg:
What is the syntax for mktemp to be computed on variable assignment?
Thank you.
| ||
Was this post useful to you?
|
10
|
It depends on the flavour of make. With GNU Make, you can use
:= instead of = as in
Edit As pointed out by Novelocrat, the
= assignment differs from := assignment in that values assigned using = will be evaluated during substitution (and thus, each time, the variable is used), whereas := assigned variables will have their values evaluated only once (during assignment), and hence, the values are fixed after that. See the documentation of GNU Make for a more detailed explanation.
In order for the value to be truelly constant after assignment, though, the it should not contain any parts, which might be special to the shell (which make calls in order to actually run the update rules, etc.) In particular, backticks are best avoided. Instead, use GNU
make 's built-in shell function and similar to achieve your goals. | |||
feedback
|
Computing Makefile variable on assignment - Stack Overflow
'via Blog this'
=
are evaluated at each substitution. Variables assigned with:=
are evaluated at assignment, as you desire. – Novelocrat Sep 16 '09 at 22:37