uboot学习之二----主Makefile学习之三----静默编译

第45-54行:

45 # Deal with colliding definitions from tcsh etc.
46 VENDOR=
47
48 #########################################################################
49 # Allow for silent builds
50 ifeq (,$(findstring s,$(MAKEFLAGS))) //判断findstring函数是否为空

51 XECHO = echo //如果有就echo
52 else
53 XECHO = : //如果没有就为空,即不打印
54 endif
55


这一段 主要是关于静默编译的内容


uboot允许静默编译,开启静默编译主要是通过判断ifeq (,$(findstring s,$(MAKEFLAGS))) 。

使用方法:在编译时,使用make -s -会作为MAKEFLAGS传给Makefile.

关于makefile知识点:

条件判断:主makefile50行 :ifeq (,$(findstring s,$(MAKEFLAGS)))

《跟我一起学Makefile》第42页:

条件表达式的语法为:

<conditional-directive>

<text-if-true>

endif

以及

<conditional-directiv>

<text-if-ture>

else

<text-if-false>

endif

其中<conditional-directiv>表示条件关键字,如“ifeq”。

第一个关键字ifeq:

ifeq(<arg1>, <arg2>)

ifeq 'arg1' 'arg2'
ifeq “arg1” 'arg2'

ifeq 'arg1' ”arg2”

ifeq ”arg1” “arg2”

比较参数“arg1” 和“arg2”的值是否相同。相同为真。

第二个关键字ifneq:

ifneq (<arg1>, <arg2>)

ifneq 'arg1' 'arg2'

ifneq “arg1” 'arg2'

ifneq 'arg1' ”arg2”

ifneq ”arg1” “arg2”

比较参数“arg1” 和“arg2”的值是否相同。不同为真。

第三个关键字ifdef:

ifdef <variable-name>

如果变量的值非空,那么表达式为真,否则为假。

findstring函数

函数调用语法:

$(<funciton> <arguments>)

或者

${<function> <arguments>}

$(findstring <find>, <in>)

功能:在字串<in>中查找<find>字串。

返回:如果找到,那么返回<find>,否则返回空字符串。

所以这里ifeq (,$(findstring s,$(MAKEFLAGS)))

这里的意思就是如果findstring函数的返回值为空。如果为空,那么ifeq函数的两个参数相等,条件判断为真。执行<text-if-true>.

原文地址:https://www.cnblogs.com/yr-linux/p/5361885.html