【问题标题】:What does it means @CPPFLAGS@ in Makefile.in?Makefile.in 中的@CPPFLAGS@ 是什么意思?
【发布时间】:2020-05-17 07:06:09
【问题描述】:

我有一个 Makefile.in 文件,它通过配置生成一个 Makefile.am。之后使用 automake Makefile.am 创建 Makefile

现在我想在生成的 Makefile 中添加一个定义。问题是,在生成的 Makefile 中,我在变量 CPPFLAGS 中找到了一个标志列表,但在 Makefile.in 中 CPPFLAGS 的定义中,我发现只有一行以以下方式写入:

CPPFLAGS = @CPPFLAGS@

@CPPFLAGS@ 是什么意思?以及如何在生成的 Makefile 中设置新标志?

【问题讨论】:

  • nit:你的顺序错了。 automake 从 Makefile.am 生成 Makefile.in。然后configureMakefile.in生成Makefile

标签: c++ linux makefile configure automake


【解决方案1】:

字符串@CPPFLAGS@ 被配置脚本扩展为执行configure 时CPPFLAGS 的值。也就是说,如果你运行configure CPPFLAGS=foo,那么@CPPFLAGS@会被扩展成字符串foo

Automake 早在 configure 被调用之前就已经运行了。 automake 所做的只是在构建该文件时将字符串 @CPPFLAGS@ 添加到 Makefile.in。

作为项目维护者,您不应编辑这些值。这是用户能够在配置时向构建添加标志的机制。

如果你想添加标志,你应该在 Makefile.am 中分配给AM_CPPFLAGS。但很可能你并不想这样做。这很难说,这取决于您认为要添加哪些标志。

【讨论】:

    【解决方案2】:

    CPPFLAGS 代表 C 预处理器标志。

    您可以将其设置为环境变量或通过命令行:

    CPPFLAGS="-g -Wall -O0" automake
    

    CPPFLAGS="-g -Wall -O0" make
    

    来自 gnu Make 手册:

    CPPFLAGS

    Extra flags to give to the C preprocessor and programs that use it (the C and Fortran compilers).
    

    【讨论】:

    • 我的问题有点不同。我知道你在说什么,但是如果在 Makefile.in 中只有这一行,那么插入到生成的 Makefile 中的值在哪里? "@CPPFLAGS@" 是什么意思
    猜你喜欢
    • 1970-01-01
    • 2011-08-12
    • 2017-06-11
    • 2018-03-05
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 2010-09-29
    • 2011-04-18
    相关资源
    最近更新 更多