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"