通过autotools查询pkg-config变量

时间:2014-02-09 20:18:48

标签: autotools autoconf automake glade pkg-config

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

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

但是在Makefile.am中的变量中。有(便携式)方法吗?

1 个答案:

答案 0 :(得分:5)

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)中访问此值