Questions
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
http://www.gnu.org/software/make/manual/make.html#Reading-Makefiles
http://www.gnu.org/software/make/manual/make.html#Reading-Makefiles
Answers
Lazy Set
VARIABLE = value
Normal setting of a variable - values within it are recursively expanded when the variable is used, not when it s declared
Immediate Set
VARIABLE := value
Setting of a variable with simple expansion of the values inside - values within it are expanded at declaration time.
Set If Absent
VARIABLE ?= value
Setting of a variable only if it doesn t have a value
Append
VARIABLE += value
Appending the supplied value to the existing value (or setting to that value if the variable didn t exist)
Source
License : cc by-sa 3.0
http://stackoverflow.com/questions/448910/makefile-variable-assignment
Related