加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

makefile – 模式中的’%’是否匹配空字符串?

发布时间:2020-12-16 06:50:00 所属栏目:百科 来源:网络整理
导读:从 docs: A vpath pattern is a string containing a % character. The string must match the file name of a prerequisite that is being searched for, the % character matching any sequence of zero or more characters (as in pattern rules). 现在,
从 docs:

A vpath pattern is a string containing a % character. The string
must match the file name of a prerequisite that is being searched for,
the % character matching any sequence of zero or more characters (as
in pattern rules).

现在,虽然%确实匹配vpath模式(vpath%foo)中的空字符串(零长度字符串),但对于模式规则却不是这样.

因此,上述文档在它们之间进行等同是错误的,如:

…the ‘%’ character matching any sequence of zero or more characters (as
in pattern rules.

??

因为这根本不是真的,如下面的Makefile所示:

all ::

al%l :
    @echo '$@'

.

执行,我们得到:

# It is evident that 'all' doesn't match 'al%l'
$make -r
make: Nothing to be done for 'all'.

# But,'all' does match 'al%'
$make  -r -f makefile -f <(echo 'al% : ; echo $@')
echo all
all

.

事实上,这很好documented:

For example,%.c as a pattern matches any file name that ends in
.c. s.%.c as a pattern matches any file name that starts with s.,
ends in .c and is at least five characters long. (There must be at
least one character to match the %.) The substring that the %
matches is called the “stem”.

同意?

解决方法

是的,它确实.

您的示例中的问题是您正在混合和匹配单冒号和双冒号配方.明确不允许这样做,您需要为所有匹配规则执行一个或另一个.

此外,具有不同的模式不符合相同的目标,并且通常会运行最具体的匹配并忽略其他匹配(即使示例中的零宽度匹配可能存在).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读