What's the difference between := and = in Makefile?

prosseek picture prosseek · Feb 2, 2011 · Viewed 41.9k times · Source

For variable assignment in Make, I see := and = operator. What's the difference between them?

Answer

Greg Hewgill picture Greg Hewgill · Feb 2, 2011

This is described in the GNU Make documentation, in the section titled 6.2 The Two Flavors of Variables .

In short, variables defined with := are expanded once, but variables defined with = are expanded whenever they are used.