variables - Makefile 'match' 特殊变量的名称是什么?

标签 variables makefile pattern-matching

包含 % 匹配项的特殊 Makefile 变量的名称是什么,要在规则主体中使用?

举个例子,我想这样使用它:

%.o: %.c
             @echo Matched $MATCH
             $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

我把 $MATCH 放在那里是因为我不记得那个特殊模式匹配变量的实际名称。

换句话说,如果用户说make foo.c,我想输出Matched foo

没找到here ,但我它存在是因为我以前用过它......

最佳答案

来自GNU Make software manual ,您引用的特殊变量是 $*,隐式词干匹配:

The stem with which an implicit rule matches (see How Patterns Match). If the target is dir/a.foo.b and the target pattern is a.%.b then the stem is dir/foo. The stem is useful for constructing names of related files.

关于variables - Makefile 'match' 特殊变量的名称是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4011350/

相关文章:

Windows 在运行时删除 make 可执行文件。为什么?

scala - 为什么用模式匹配收集不能缩小特定类别?

java - 按名称调用变量,编译时不知道

android - 使用全局变量

javascript - 如何将变量存储在服务器上

android - Mac 非法指令 : 4

javascript - 错误: Invalid left-hand side in assignment

visual-studio - 在 Visual Studio 中使用 Makefile 的好技术?

Javascript 字符串匹配模式帮助

mysql - 部分字符串匹配mysql