Makefile_Jerry(二)

来源:互联网 发布:制谱软件x 编辑:程序博客网 时间:2024/06/11 17:20

常用函数

Makefile 常用函数语法:

1、字符串处理函数
$(subst < before > ,< later >,< text >)
字符串替换函数,将text字符串中的before字符串换成later字符串,并返回处理后的字符串。
$(patsubst < pattern >,< replacement >,< text >)
查找< text >中的单词(单词以“空格”、“Tab”或“回车”“换行”分隔)是否符合模式< pattern >,如果匹配的话,则以< replacement >替换。这里,< pattern >可以包括通配符“%”,表示任意长度的字串。如果< replacement >中也包含“%”,那么,< replacement >中的这个“%”将是< pattern >中的那个“%”所代表的字串。(可以用“/”来转义,以“/%”来表示真实含义的“%”字符)

$(strip < string >)

去空格函数,去除字符串之间多余的空格以及字符串首尾的空格。

$(findstring < word>, < text >)

字符串查找函数,在字符串text中查找word字符串,找到返回word字符串,否则返回空字串。

$(filter < pattern…>,< text >)

$(filter-out < pattern…>,< text>)
过滤函数与反过滤函数,返回符合条件模式(或者不符合条件模式)的字符串。

$(sort < List >)

排序函数,按照升序给字符串List排序,并返回排序后的字符串,在返回的字符串中相同的字符串会被去掉。

$(word < n >,< text >)

取单词函数,取出text中的第n个单词并返回,当n比text中的单词数大时,返回空字符串。

$(wordlist < m >,< n >,< text >)

取单词串函数,m超过单词数量时,返回空字符串。

$(words < text >)

统计text中的单词数量,并返回。
要取最后一个单词可以这样:$( word $(words < text >),< text >)

$(firstword < text >)

取首单词函数

2、文件名操作函数
$(dir < names…> )
取目录函数,从文件名序列中取目录,返回反斜杠”/ “之前的目录,如果没有”/ “那么返回”./ ”
$(notdir < names…>)
取出非目录部分
$(suffix < names…>)
取后缀函数
$(basename < names…>)
取前缀函数
$(addsuffix < suffix >,< names…>)
加后缀函数
$(addprefix < prefix >,< names…>)
加前缀函数
$(join < list1 >,< list2 >)
连接函数,将list1和list2中的对应单词连接起来并返回。
原创粉丝点击