autotools - 通过autotools查询pkg-config变量

标签 autotools autoconf automake glade pkg-config

要安装目录文件,我想获取 Glade(UI 设计师)的目录,如下所示:

$ pkg-config --variable=catalogdir gladeui-2.0
/usr/share/glade/catalogs

但在我的 Makefile.am 内的变量中。有没有一种(可移植)方法可以做到这一点?

最佳答案

configure.ac中获取该值。我认为pkg-config的最新版本是0.28。我们假设 0.25 或以上就足够了:

<小时/>

configure.ac

...

PKG_PROG_PKG_CONFIG([0.25]) # check and set $PKG_CONFIG

PKG_CHECK_MODULES([GLADEUI],[gladeui-2.0],
  [ac_gladeui_catdir=`$PKG_CONFIG --variable=catalogdir gladeui-2.0`],
  [ac_gladeui_catdir=;])

# there's nothing special about the choice of variable names:
# GLADEUI or ac_gladeui_catdir - use whatever naming scheme you please.

if test "x$ac_gladeui_catdir" = x ; then
  AC_MSG_ERROR([couldn't find Glade or catalog directory])
fi

# or if you prefer the AS_IF macro:
# AS_IF([test "x$ac_gladeui_catdir" = x],
#   [AC_MSG_ERROR([couldn't find Glade or catalog directory])])

AC_SUBST(GLADEUI_CATDIR, $ac_gladeui_catdir)
<小时/>

您现在可以使用以下方式在 Makefile.am 中访问此值:$(GLADEUI_CATDIR)

关于autotools - 通过autotools查询pkg-config变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21664473/

相关文章:

build - X-I。 : command not found, 构建某种软件失败,怎么回事?

autotools - 分发自动工具图元文件

pthreads - autoconf 与 -pthread

c++ - autoconf 中的库版本字符串

c - main 的多重定义

c++ - gcc -R 参数有什么作用?

makefile - 如何在子目录中编写makefile.am?

c++ - Eclipse 中的源代码外构建

compilation - 如何使用相同的参数重新运行./configure?

testing - 在 hudson 中设置测试构建作业,检测 make 何时无法编译