Ifeq,ifneq,else,endif "

Source: Internet
Author: User

Author: shaoyizhe2006

Original URL: http://blog.csdn.net/shaoyizhe2006/article/details/8012929


Three keywords are used in conditional statements: "Ifeq", "Else", and "endif". which

1. "Ifeq" represents the beginning of a conditional statement and specifies a comparison condition (equality). The following are two parameters that are enclosed in parentheses, using commas "," and separated by a space with the keyword "ifeq". The variable reference in the parameter is expanded when the variable value is compared. After "Ifeq", it is ignored when the condition satisfies the requirement that make needs to be executed and the condition is not satisfied.

2. "Else" is the operative part when the condition is not satisfied. This section is not required for all conditional statements.

3. "EndIf" means the end of a conditional statement, and any conditional expression must end with "endif".

This keyword is used to determine whether the parameters are equal, in the following format:

' Ifeq (ARG1, ARG2) '

' ifeq ' ARG1 ' ARG2 '

' ifeq ' ARG1 , ' ARG2 '

' ifeq ' ARG1 ' ARG2 '

' ifeq ' ARG1 ' ARG2 ' replace the expand ' ARG1 ' and ' ARG1 ' to compare their values

Usually we use it to determine whether the value of a variable is null (not any character). Parameter values may be obtained by referencing a variable or function, which may result in the inclusion of NULL characters (spaces, etc.) in the parameter values during the expansion process. Generally in this case we use make's "strip" function to process the value of its variable, removing the null characters. The format is:

ifeq ($ (Strip $ (foo)),)

Text-if-empty

endif

That is, there are several leading and trailing spaces in "$ (foo)", and "Text-if-empty" is also used as part of the makefile need to perform.

Keyword "IFNEQ" Implementation of conditional judgment statement and "Ifeq" opposite

Keyword "ifdef"

The keyword "ifdef" is used to determine whether a variable has been defined. The format is:

' ifdef variable-name '

If the value of the variable "vaeiable_name" is not empty (the value of a variable not defined in makefile is null), then the expression is true

Example 1:

bar =

foo = $ (bar)

ifdef foo

Frobozz = yes

Else

Frobozz = no

endif

Example 2:

foo =

ifdef foo

Frobozz = yes

Else

Frobozz = no

endif

The result in Example 1 is: "Frobozz = yes" and the result of Example 2 is "Frobozz = no".

The key word "ifndef" implements the same functionality as "ifdef"

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.