2014-02-09 83 views
2

要安裝目錄文件,我想獲得的目錄格拉德(一UI設計師),像這樣:查詢pkg配置變量

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

但在我Makefile.am內部變量。是否有一個(便攜式)的方式來做到這一點?

回答

4

configure.ac獲取此值。我認爲pkg-config最新版本是0.28。讓我們假設0.25以上就足夠了:$(GLADEUI_CATDIR)


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這個值