5

I have a Makefile. Somewhere in the makefile there is a variable defined:

FOO=hello

Later on I need to append some text to FOO's content. I tried it like this:

FOO=$(FOO)_world

I suggested that echo $(FOO) would output hello_world. Instead I get an error:

*** Recursive variable 'FOO' references itself (eventually).  Stop.

Using the += operator is no option, because this would add a space in between.

9

You need the := in place of the recursive =:

FOO := hello
FOO := $(FOO)_world
$(info FOO=$(FOO))

hello_world

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.