包含 %
匹配项的特殊 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 isa.%.b
then the stem isdir/foo
. The stem is useful for constructing names of related files.
关于variables - Makefile 'match' 特殊变量的名称是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4011350/