BSD Make和GNU Make兼容的makefile [英] BSD Make and GNU Make compatible makefile
问题描述
我有一个BSDmakefile和GNUmakefile,除了依赖管理外,它们几乎完全相同.
GNUmakefile:
ifneq ($(MAKECMDGOALS), "clean")
-include $(dependencies)
endif
BSDmakefile:
.for i in $(dependencies)
.sinclude "${i}"
.endfor
是否有一种方法可以使我检测到我是在gmake还是bsdmake下运行,然后基于此执行适当的include语句?我记得我看到有人在两个Makefile处理器中都利用了一个怪癖,以便他们可以达到类似的效果.
或者,如果有比这更好的方法,我想知道! (不适合切换到SCons或CMake!)
谢谢!
您可以将特定于GNU的内容放在 I have a BSDmakefile and GNUmakefile that are pretty much identical except for dependency management. The GNUmakefile: The BSDmakefile: 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! You could put your GNU-specific stuff in 这篇关于BSD Make和GNU Make兼容的makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!GNUmakefile
中,将特定于BSD的内容放在BSDmakefile
中,并将常用的内容放在一个名为Makefile.common
.不利的一面是,现在您拥有3个makefile而不是2个.向上的方面,您将仅编辑1.ifneq ($(MAKECMDGOALS), "clean")
-include $(dependencies)
endif
.for i in $(dependencies)
.sinclude "${i}"
.endfor
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.