【问题标题】:How do I remove -Werror from autotools-generated makefiles?如何从自动工具生成的 makefile 中删除 -Werror?
【发布时间】:2016-08-28 18:46:52
【问题描述】:

我正在编译一个使用自动工具构建过程的大型库。有很多makefile。他们每个人都得到CFLAGS = .... -Werror

当我尝试编译时,有一些小警告会杀死我的设置。

尽管有警告,我还是想尝试构建,因此我需要从所有 makefile 中删除 -Werror。有没有办法防止 autotools 在所有这些 makefile 中输入-Werror

【问题讨论】:

  • 检查 configure.ac - 它可能包含类似 AM_INIT_AUTOMAKE([-Werror]) 的内容。不要在生成时编辑 Makefile/s。

标签: makefile autotools automake suppress-warnings autogen


【解决方案1】:

我在 configure.ac 中四处寻找,发现:

AC_ARG_ENABLE([werror],
  AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
  [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])

所以我像这样运行配置:

./configure --disable-werror

它就像一个魅力。我的 makefile 中不再有 -Werror 标志。感谢您的评论直到!

【讨论】:

    【解决方案2】:

    我的 sed 方式,在 Makefile 创建之后

    find . -name Makefile -exec sed -i s'/-Werror//g' {} \;
    

    在 Mac 中,将 sed 替换为 gsed

    【讨论】:

      【解决方案3】:

      对于基于 autotools 的项目,您可能需要通过:

      ./autogen.sh --disable-Werror
      

      观察Werror中的大写W

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-11-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-19
        • 2013-01-12
        • 1970-01-01
        • 2010-09-05
        相关资源
        最近更新 更多