BSD Make 和 GNU Make 兼容的 makefile
我有一个 BSDmakefile 和 GNUmakefile,除了依赖管理之外,它们几乎完全相同。
GNUmakefile:
ifneq ($(MAKECMDGOALS), "clean")
-include $(dependencies)
endif
BSDmakefile:
.for i in $(dependencies)
.sinclude "${i}"
.endfor
有没有办法让我可以检测我是否在 gmake 或 bsdmake 下运行,然后基于此执行适当的包含语句?我记得看到有人利用两个 makefile 处理器中的一个怪癖,以便他们可以达到类似的效果。
或者,如果有比这更好的方法,我想知道! (切换到 SCons 或 CMake 是不合适的!)
谢谢!
I have a BSDmakefile and GNUmakefile that are pretty much identical except for dependency management.
The GNUmakefile:
ifneq ($(MAKECMDGOALS), "clean")
-include $(dependencies)
endif
The BSDmakefile:
.for i in $(dependencies)
.sinclude "${i}"
.endfor
Is there a way to make it so that I can detect if I am running under gmake or bsdmake and then execute the appropriate include statements based off of that? I remember seeing someone take advantage of a quirk in both makefile processors so that they could achieve a similar effect.
Alternatively, if there is a better approach than this, I would like to know! (switching to SCons or CMake is not appropriate!)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 GNU 特定的内容放入
GNUmakefile
中,将 BSD 特定的内容放入BSDmakefile
中,将常用的内容放入名为Makefile.common
的文件中> 或类似的。然后在另外两个文件的开头包含Makefile.common
。缺点是,现在您有 3 个 makefile,而不是 2 个。优点是,您只能编辑 1 个。You could put your GNU-specific stuff in
GNUmakefile
, your BSD-specific stuff inBSDmakefile
, and your common stuff in a file namedMakefile.common
or similar. Then includeMakefile.common
at the very beginning of each of the other two. Downside is, now you have 3 makefiles instead of 2. Upside, you'll only be editing 1.