通过自动工具查询pkg-config变量 [英] Query pkg-config variable through autotools

查看:291
本文介绍了通过自动工具查询pkg-config变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要安装目录文件,我想像这样获取Glade(UI设计器)的目录:

To install a catalog file, I'd like to get the directory for Glade (an UI designer) like so:

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

但在我的Makefile.am中的变量中.有(便携式)方式可以做到这一点吗?

but in a variable inside my Makefile.am. Is there a (portable) way to do this?

推荐答案

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

Get this value in configure.ac. I think the latest version of pkg-config is 0.28. Let's assume that 0.25 or above is good enough:

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)


您现在可以使用$(GLADEUI_CATDIR)

这篇关于通过自动工具查询pkg-config变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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