条件表达式的语法为:
<conditional-directive>
<text-if-true>
endif
以及:
<conditional-directive>
<text-if-true>
else
<text-if-false>
endif
其中<conditional-directive>表示条件关键字,如“ifeq”。这个关键字有四个。
第一个是我们前面所见过的“ifeq” 。比较参数“arg1”和“arg2”的值是否相同。
ifeq (<arg1>, <arg2>)
ifeq '<arg1>' '<arg2>'
ifeq "<arg1>" "<arg2>"
ifeq "<arg1>" '<arg2>'
ifeq '<arg1>' "<arg2>"
第二个条件关键字是“ifneq”。其比较参数“arg1”和“arg2”的值是否相同,如果不同,则为真。
ifneq (<arg1>, <arg2>)
ifneq '<arg1>' '<arg2>'
ifneq "<arg1>" "<arg2>"
ifneq "<arg1>" '<arg2>'
ifneq '<arg1>' "<arg2>"
第三个条件关键字是“ifdef”。语法是:
ifdef <variable-name>
如果变量<variable-name>的值非空,那到表达式为真。否则,表达式为假。
第四个条件关键字是“ifndef”。其语法是:
ifndef <variable-name>
这个我就不多说了,和“ifdef”是相反的意思。