1.word函数
作用:取字符串text中第n个单词(从1开始),如果n比text中的单词数要大,那么返回空字符串。
$(word <n>,<text> )
例子:$(word 3, foo bar abc)的返回值为abc
2.words函数
作用:统计text中字符串中的单词个数。
$(words <text> )
例子:$(words foo bar abc)的返回值为3
3.firstword函数
作用:返回text中字符串中的第一个单词。
$(firstword <text> )
例子:$(firstword foo bar abc)的返回值为foo
4.lastword函数
作用:返回text中字符串中的最后一个单词。
$(lastword <text> )
例子:$(lastword foo bar abc)的返回值为abc
注意: GNU Make 3.80中没有lastword内置函数,可用以下两种方法实现lastword函数
1.$(word $(words <text>) <text>)
2.lastword = $(if $(firstword $1),$(word $(words $1),$1)) #定义一个函数
$(call lastword,...)#调用该函数