要安装目录文件,我想获取 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/