BSD Make 和 GNU Make 兼容的 makefile

发布于 2024-09-26 01:13:48 字数 439 浏览 1 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

埋葬我深情 2024-10-03 01:13:48

您可以将 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 in BSDmakefile, and your common stuff in a file named Makefile.common or similar. Then include Makefile.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文