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


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


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.


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

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


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.