什么是$<和$ @代表Makefile吗? [英] What do $< and $@ represent in a Makefile?
本文介绍了什么是$<和$ @代表Makefile吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以在Makefile
中解释$<
和$@
的含义吗?
Can anybody please explain the meaning of $<
and $@
in a Makefile
?
推荐答案
$<
求值为make规则中的第一个前提",而$@
求值为make规则中的目标".
$<
evaluates to the first "prerequisite" in the make rule, and $@
evaluates to the "target" in the make rule.
这是一个例子:
file.o : file.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
在这种情况下,$<
将替换为file.c
,而$@
将替换为file.o
.
In this case, $<
will be replaced with file.c
and $@
will be file.o
.
这些在诸如此类的通用规则中更有用:
These are more useful in generic rules like this:
%.o : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
有关更多信息,请参见本手册.
See this manual for more info.
这篇关于什么是$<和$ @代表Makefile吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文