Makefile - 模式规则

See*_*tty 3 makefile

我是编写 makefile 的新手。最近我在 makefile 中看到了模式规则。例如:

%.o: %.cc
        # command to compile comes here
Run Code Online (Sandbox Code Playgroud)

经过在网上的严格搜索,我发现了上面的语句的作用,但是我遇到了下面的另一个语句。

%: %.o
        # Command to link lies here
Run Code Online (Sandbox Code Playgroud)

我不明白这个规则。谁能解释一下第二个模式规则?

Jac*_*lly 5

第二条规则也是一个模式规则,它说明如何从同名但.o在末尾的文件创建一个没有扩展名的文件。所以链接foofrom foo.obarfrombar.o等等是一个规则。