Variable assignment of Makefile

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.