Can anybody give a clear explanation of how variable assignment really works in Makefiles.
What is the difference between :
VARIABLE = value
VARIABLE ?= value
VARIABLE := value
VARIABLE += value
I have read the section in GNU Make's manual, but it still doesn't make sense to me.
VARIABLE = value
Normal setting of a variable, but any other variables mentioned with the value
field are recursively expanded with their value at the point at which the variable is used, not the one it had when it was declared
VARIABLE := value
Setting of a variable with simple expansion of the values inside - values within it are expanded at declaration time.
VARIABLE ?= value
Setting of a variable only if it doesn't have a value. value
is always evaluated when VARIABLE
is accessed. It is equivalent to
ifeq ($(origin FOO), undefined)
FOO = bar
endif
See the documentation for more details.
VARIABLE += value
Appending the supplied value to the existing value (or setting to that value if the variable didn't exist)