BSD Make和GNU Make兼容的makefile [英] BSD Make and GNU Make compatible makefile

查看:286
本文介绍了BSD Make和GNU Make兼容的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的内容放在GNUmakefile中,将特定于BSD的内容放在BSDmakefile中,并将常用的内容放在一个名为或类似.然后在其他两个开头的开头都包含Makefile.common.不利的一面是,现在您拥有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)
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!

解决方案

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.

这篇关于BSD Make和GNU Make兼容的makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆