Makefile中也可使用函数进行一些操作,函数的返回值可以当做变量来使用。
一、函数调用语法
函数调用也是用“$”标识,格式
$(<
function>,<arguments>)或者
${<
function>,<arguments>}
其中的function标识函数名,arguments标识函数所需要的参数,$()的结果是函数的返回值。
二、一些字符处理函数
1、换字符
$(subst
<from>,
<to>,
<text>)
标识将text中的from都换成to,返回换完后的text
2、换某种模式的字符串
$(patsubst
<pattern>,
<replacement>,
<text>)
将text中符合模式pattern的字符串换位replacement。
3、过滤符合某种模式的字符串
$(filter <pattern>,<
text>)
过滤出text中符合pattern模式的字符串并返回。
更多的函数参见《GNU Make 中文手册》
转载请注明原文地址: https://ju.6miu.com/read-700290.html