如何组合 AC_SUBST 和 AC_DEFINE? [英] How do I combine AC_SUBST and AC_DEFINE?

查看:38
本文介绍了如何组合 AC_SUBST 和 AC_DEFINE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 configure.ac 文件,其中包含如下几行:

I've a configure.ac file containing lines like:

AC_DEFINE(CONF_XDISP, ":8", "X screen number")

这些常量在 C 源代码中用于设置编译默认值.我还有一个配置文件 conf/bumblebee.conf,需要在其中设置这些默认值.我被告知 AC_SUBST 可用于将 @CONF_XDISP@ 替换为 ":8" 使得以下行:

These constants are used in the C source for setting compile defaults. I also have a configuration file conf/bumblebee.conf in which these defaults need to be set. I'm told that AC_SUBST can be used to get @CONF_XDISP@ substituted for ":8" such that the below line:

VGL_DISPLAY=@CONF_XDISP@

变成:

VGL_DISPLAY=":8"

为每个 AC_DEFINE 制作一个 AC_SUBST 行在我看来并不是最好的方法,因为它包含很多重复的行.如何组合这些选项,以便我可以使用诸如 AC_DEFINE_SUBST 之类的东西?也欢迎其他改进这一点的想法和建议.

Making an AC_SUBST line for each AC_DEFINE does not look the best way to me as it includes a lot duplication of lines. How can I combine these options, such that I can use something like AC_DEFINE_SUBST? Other ideas and suggestions to improve this are welcome too.

推荐答案

感谢 thinton,我可以编写下面的代码:

Thanks to thinton, I could cook up the below code:

# AC_DEFINE_SUBST(NAME, VALUE, DESCRIPTION)
# -----------------------------------------
AC_DEFUN([AC_DEFINE_SUBST], [
AC_DEFINE([$1], [$2], [$3])
AC_SUBST([$1], ['$2'])
])

对于AC_DEFINE_SUBST(CONF_XDISP, ":8", "X screen number"),这会生成一个configure文件,其中包含:

For AC_DEFINE_SUBST(CONF_XDISP, ":8", "X screen number"), this generates a configure file containing:

$as_echo "#define CONF_XDISP ":8 $PWD"" >>confdefs.h

CONF_XDISP='":8"'

相关文档:

这篇关于如何组合 AC_SUBST 和 AC_DEFINE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆