Monday, September 2, 2019

Makefile 四種等號用法


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
(that means it fetches/parses the value only when you use the variable)

Immediate Set

VARIABLE := value
Setting of a variable with simple expansion of the values inside - values within it are expanded at declaration time.
(that means it fetches the value immediately, and store the content to the variable)

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)

No comments:

Post a Comment