Query pkg-config variable through autotools

☆樱花仙子☆ 提交于 2019-12-23 16:18:46

问题


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

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


回答1:


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)

You can now access this value in the Makefile.am using: $(GLADEUI_CATDIR)



来源:https://stackoverflow.com/questions/21664473/query-pkg-config-variable-through-autotools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!