Simple understanding of Makefile 4

Conditional judgment

The syntax of the conditional expression is:

<conditional-directive>
<text-if-true>
endif
以及:
<conditional-directive>
<text-if-true>
else
<text-if-false>
endif

Which <conditional-directive>represents conditional keywords, such as "ifeq". There are four keywords, as follows:

1.“ifeq”

ifeq (<arg1>, <arg2> ) 
ifeq '<arg1>' '<arg2>' 
ifeq "<arg1>" "<arg2>" 
ifeq "<arg1>" '<arg2>' 
ifeq '<arg1>' "<arg2>" 

Compare whether the values ​​of the parameters "arg1" and "arg2" are the same, and if they are the same, it is true.

2. The second condition keyword is "ifneq". The syntax is:

ifneq (<arg1>, <arg2> ) 
ifneq '<arg1>' '<arg2>' 
ifneq "<arg1>" "<arg2>" 
ifneq "<arg1>" '<arg2>' 
ifneq '<arg1>' "<arg2>" 

It compares whether the values ​​of the parameters "arg1" and "arg2" are the same, and if they are different, it is true.

3. The third condition keyword is "ifdef". The syntax is:
ifdef <variable-name>
If <variable-name>the value of the variable is not empty, the expression is true. Otherwise, the expression is false.

4. The fourth condition keyword is "ifndef". The syntax is:
ifndef <variable-name>
If the <variable-name>value is empty, the expression is true.

Guess you like

Origin blog.csdn.net/weixin_46259642/article/details/113568250