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.

2 Answers 2


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

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



I would say the makefile addsuffix function is what you are looking for, thus in your case for example:

FOO := hello
FOO := $(addsuffix _world,$(FOO))

However @user218374 was right too and his solution works as well, in this case, but I am pretty sure you might be happy to have a look at these built-in expansion functions relating also to lists of file names!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .