gpt4 book ai didi

makefile - 模式中的 '%' 是否与空字符串匹配?

转载 作者:行者123 更新时间:2023-12-01 06:22:17 24 4
gpt4 key购买 nike

来自 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".



同意?

最佳答案

是的,它确实。

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

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

关于makefile - 模式中的 '%' 是否与空字符串匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32195512/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com