BSD Make和GNU Make兼容的makefile

编程入门 行业动态 更新时间:2024-10-12 01:24:35
本文介绍了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中,并将常用的内容放在一个名为或类似.然后在其他两个开头的开头都包含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) 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 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

本文发布于:2023-11-24 17:06:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626095.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:BSD   GNU   makefile

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!