Reputation: 4798
In a makefile, what's the difference between writing
define VAR =
...
...
endef
and writing
define VAR
...
...
endef
Notice that the latter is missing the =
on the define
line. Both are accepted by Gnumake, but they don't appear to exhibit the same behavior (for me, I find that using the latter does what I want it to).
When should you use which form?
Upvotes: 3
Views: 225
Reputation: 100856
There is no difference between them: both create recursive multi-line variable values.
There is ONE difference, though: the former version (with the equals sign) was introduced in GNU make 3.82 (released in 2010). If you're still using a version of GNU make before that, then this statement:
define FOO =
bar
enddef
creates a variable named FOO =
, not FOO
(which is probably why it doesn't appear to work for you).
The ability to add assignment operators here is really so you can use the other operators, such as :=
, ?=
, +=
with multi-line variables, which you didn't used to be able to do.
But the default if no operator is specified is and always has been, to create a normal recursive variable.
Upvotes: 5