There are 4 ways to assign variables in makefile:
= , := , += , ?=
= : Direct Assignment
Variable = value
: = : Position-dependent assignment
If the right value is a value, then it is not the same as =, if the right value is a variable, then the value of the left variable is equal to the value of the current position of the right variable, what does it mean?
A = ABCB = $ (a) a = Jklall: @echo $ (b). Phony:all
Executing this makefile, the value of output B is jkl, and in the sentence B = $ (a) , the value of variable A is deferred, which is determined by the last assignment statement a = JKL of variable A. If B is assigned a value of: =, the situation is different:
A = ABCB: = $ (a) a = Jklall: @echo $ (b). Phony:all
At this point, the value of output B is ABC, which means to get the value of the current position variable a assigned to B.
? = : Asks if the left variable is defined, that is, whether an assignment is used, or not, otherwise ignored. Note whether it is defined, not whether it is a null value, and also note that null values are not equal to spaces, tab keys, and so on.
Here is the space, how to spaces grid? or Tab
Spacevalue= Space/tab#
Note that the # specifier is required, at which point the value of Spacevalue is the assignment = after the beginning of the #, there is a trap for the comment, assuming that a variable dir is defined, assigning it a path
Dir =/home/thomas #xx的路径
This is due to variable assignment, the left and right side of the assignment number of spaces, tab will be ignored, is from the first non-space, non-tab to the last non-space, non-tab end, unless you encounter an annotation, otherwise to the end of the comment.
+ = : Append Assignment
the final value of a variable is determined by one of the above assignment operations, based on the rules .
Variable assignment of Makefile