Makefile 生成具有相同名称但通过两种不同规则的文件
我想让 makefile 生成一个具有两种不同规则的文件。一个用于推荐 make aaa,另一个用于 make bbb。 我有两个文件: 1.c 和 2.c 规则 aaa 需要从 1.c 生成的 result.o 而 bbb 需要从 2.c 生成的 result.o
如何做到这一点?
I want to have makefile witch generate one file with two different rules. One for commend make aaa and another for make bbb.
I have two files:
1.c and 2.c
rule aaa need result.o generated from 1.c
and bbb need result.o generated from 2.c
How to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 GNU Make 文档:
也就是说,make rules的目的是生成一些目标,通常是某些操作的结果文件 - 可以是一个标记文件信令已执行的步骤或编译中的目标文件。
您想要为 2 个不同的依赖项生成
result.o
目标,这并不完全是 make 的目的。您可以做的是生成目标
1.o
和2.o
,然后在更高级别中符号链接到result.o
规则。但这意味着规则aaa
和bbb
必须依赖1.o
和2。 o
因为它们必须有单独的目标(巧合的是规则的名称)。From the GNU Make documentation:
That is, the purpose of make rules is to generate some target which usually is the result file from some operation - be it a stamp file signalling that a step has executed or an object file from a compilation.
What you want, generate a
result.o
target for 2 different dependencies is just not exactly what make is intended to do.What you can do, is generate targets
1.o
and2.o
, which than get symlinked toresult.o
in a higher-level rule. This means however, that rulesaaa
andbbb
have to depend on1.o
and2.o
as they have to have separate targets (which coincidentally are the rule's names).