【问题标题】:How to force an error in BSD make如何在 BSD make 中强制出错
【发布时间】:2011-09-15 14:57:28
【问题描述】:

有没有办法在不使用目标的情况下强制 BSD makefile 出错?我正在寻找类似的东西

.if ...some condition...
    error bad configuration
.endif

这个问题类似于“How to force an error in a gnumake file”,但适用于 BSD makefile。

【问题讨论】:

    标签: c makefile gnu-make bsdmake


    【解决方案1】:

    是:使用.error(以及变量赋值语法VARIABLE != some command 将shell 命令的输出分配给变量)。

    SOMEVAR != foo --bar
    .if (${SOMEVAR} != "some string")
    .error bad configuration
    .endif
    

    (如果手头没有,可以在线阅读here 的手册页,其中包含语法的完整详细信息。)

    【讨论】:

    • 谢谢。您是否知道适用于不支持 .error 指令的古老版本的 bsd make 的解决方案?我使用的 Solaris 版本会默默地忽略该指令。
    • 不,我不知道——对不起。 (我知道有一个名为 bmake 的 BSD make 版本声称非常便携,如果有帮助的话?)
    • 我可以确认 bmake 过去与 FreeBSD 上的 make 非常兼容(现在它们相同,所以更容易),我在 Solaris 上使用了我的 bsdowl make 宏。 — bitbucket.org/michipili/bsdowl
    猜你喜欢
    • 2021-12-04
    • 2015-08-17
    • 2018-09-30
    • 1970-01-01
    • 2010-12-24
    • 2023-03-09
    • 1970-01-01
    • 2016-05-15
    • 2014-07-26
    相关资源
    最近更新 更多