我是一名新手编写makefile。最近,我看到了makefile中的模式规则。例如:
%.o: %.cc
# command to compile comes here
在网上进行了严格的搜索后,我找到了上面语句的含义,但我遇到了下面的另一个语句。
%: %.o
# Command to link lies here
我不理解这条规则。有人能解释一下第二个模式规则吗?
我是一名新手编写makefile。最近,我看到了makefile中的模式规则。例如:
%.o: %.cc
# command to compile comes here
在网上进行了严格的搜索后,我找到了上面语句的含义,但我遇到了下面的另一个语句。
%: %.o
# Command to link lies here
.o
的文件创建一个没有扩展名的文件。因此,这是一个将foo.o
链接到foo
,将bar.o
链接到bar
等等的规则。