我有一个BSDmakefile和GNUmakefile,除了依赖管理外,它们几乎完全相同.
GNUmakefile:
ifneq ($(MAKECMDGOALS), "clean") -include $(dependencies) endifBSDmakefile:
.for i in $(dependencies) .sinclude "${i}" .endfor是否有一种方法可以使我检测到我是在gmake还是bsdmake下运行,然后基于此执行适当的include语句?我记得我看到有人在两个Makefile处理器中都利用了一个怪癖,以便他们可以达到类似的效果.
或者,如果有比这更好的方法,我想知道! (不适合切换到SCons或CMake!)
谢谢!
解决方案您可以将特定于GNU的内容放在GNUmakefile中,将特定于BSD的内容放在BSDmakefile中,并将常用的内容放在一个名为或类似.然后在其他两个开头的开头都包含Makefilemon.不利的一面是,现在您拥有3个makefile而不是2个.向上的方面,您将仅编辑1.
I have a BSDmakefile and GNUmakefile that are pretty much identical except for dependency management.
The GNUmakefile:
ifneq ($(MAKECMDGOALS), "clean") -include $(dependencies) endifThe BSDmakefile:
.for i in $(dependencies) .sinclude "${i}" .endforIs 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!
解决方案You could put your GNU-specific stuff in GNUmakefile, your BSD-specific stuff in BSDmakefile, and your common stuff in a file named Makefilemon or similar. Then include Makefilemon 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.
更多推荐
BSD Make和GNU Make兼容的makefile
发布评论