Reputation: 350
I have a Makefile that includes another makefile, say CommonMakefile. There is a variable that I want to prefix with a value (cf. appending using +=
) keeping rest of the value intact.
V = value1 # set in CommonMakefile that is included
V = value0 $(V) # I want to prefix value0 to V
# rule defined in CommonMakefile that is included
whatsV:
echo $V # first char is a <TAB> here
How can I do that?
Expecting:
$ gmake whatsV
value0 value1
Actual:
$ gmake whatsV
Makefile:3: *** Recursive variable `V' references itself (eventually). Stop.
PS: I can-not/do-not-want to change CommonMakefile.
Upvotes: 0
Views: 860
Reputation: 99134
This won't work:
V = value0 $(V)
because here V
is a recursively expanded variable, and it can't be defined in terms of itself. But change it to a simply expanded variable:
V := value0 $(V) # <-- Note the colon
and it will work as intended.
Upvotes: 1