automake:修改隐式 make 规则以包含额外的标志
如何添加适用于所有 makefile 的额外标志变量(如 CPPFLAGS)?目前,我们正在使用 CPPFLAGS,但它应该保留为用户变量,我想保留它。我不想使用 AM_CPPFLAGS,因为我想为特定的 Makefile.amS 保留它。我想要的是像 GLOBAL_CPPFLAGS 这样的东西,我可以在configure.ac中设置它并将其应用于所有内容。如果有一种方法可以显式忽略该标志,那就太好了。
我认为我需要做的是编写自己的 make 规则,但是如何使其在所有子文件夹中可用而不将其复制到每个 Makefile.am 中?
How can I add extra flag variables (like CPPFLAGS) that will apply to all makefiles? Currently, we're using CPPFLAGS, but that is supposed to be reserved as a user variable and I would like to reserve it. I'd prefer not to use AM_CPPFLAGS because I would like to reserve that for specific Makefile.amS. What I want is something like GLOBAL_CPPFLAGS that I could set in configure.ac and have it applied to everything. It would also be nice if there were a way to explicitly ignore the flag.
I think what I need to do is to write my own make rule, but how would I make that available in all subfolders without copying it into every Makefile.am?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不使用 CPPFLAGS 是正确的。这是一个用户变量。我要做的是这样的:
在源目录的根目录中,创建一个名为
common.am
的文件,并在其中定义您需要的任何内容:我知道您说过您不想使用
AM_CPPFLAGS
,但请听我说完。在您的各个子目录中,include $(top_srcdir)/common .am
并根据需要扩展或覆盖AM_CPPFLAGS
:如果要覆盖,请使用
=
而不是+=
>:You're correct in not using
CPPFLAGS
. That's a user variable. What I'd do is something like this:In the root of your source dir, create a file called
common.am
and define whatever you need in there:I know you said you didn't want to use
AM_CPPFLAGS
, but hear me out. In your individual subdirectories,include $(top_srcdir)/common.am
and extend or overrideAM_CPPFLAGS
as needed:If you want to override, use
=
instead of+=
:我想你回答了你自己的问题:你必须将新规则复制到每个 makefile 中。
I think you answered your own question: you will have to copy the new rule into every makefile.
CPPFLAGS 是您可能应该使用的机制。只需在 configure.ac 中的某个位置连接您想要的标志:
GLOBAL_CPPFLAGS="-DSOMETHING"
...
CPPFLAGS="$CPPFLAGS $GLOBAL_CPPFLAGS"
就可以设置了。
CPPFLAGS is the mechanism you probably should be using. Just concatenate the flags you want somewhere in configure.ac:
GLOBAL_CPPFLAGS="-DSOMETHING"
...
CPPFLAGS="$CPPFLAGS $GLOBAL_CPPFLAGS"
and you should be set.