[patch] Re: cross compiling, pc files and `PKG_CONFIG_SYSROOT_DIR`

LHB Jr lhb.jr at aol.com
Thu Oct 20 00:53:25 PDT 2011


hi,

In the past, people have had problems with pkg-config and their 
directory variables during staged compilation.  I ran into this problem 
myself while compiling x.org libraries.  In fact, here is the code that 
gave me a problem, it is directly  excerpted from libXCB configure.ac 
at X.org :

# Find the xcbgen Python package
AC_MSG_CHECKING(XCBPROTO_XCBPYTHONDIR)
XCBPROTO_XCBPYTHONDIR=`$PKG_CONFIG --variable=pythondir xcb-proto`
AC_MSG_RESULT($XCBPROTO_XCBPYTHONDIR)
AC_SUBST(XCBPROTO_XCBPYTHONDIR)

In my frustration, I went through the trouble of getting the source  
 from the anon git repo and attempt to redress the issue.  As a result I 
ended up with a patch to make the above work with no changes to 
configure.ac or .pc files, only with setting PKG_CONFIG_SYSROOT_DIR.  
With this patch, the above 'Just Works'....

It  accomplishes this  by
1) Prepending  PKG_CONFIG_SYSROOT_DIR to all search paths.
2) Making two passes over the pkgconfig file. After the first pass, it 
prepends PKG_CONFIG_SYSROOT_DIR  to all variables ending in 'dir'  e.g. 
pythondir . That  way all appropriate variables have their paths 
changed. A
"Libs:" directive in a .pc file will get mangled correctly because 
these typically go like 'Libs: ${libdir}/X11'  and so the change to 
${libdir} effects a change in 'Libs:'

The two passes are (for now) required in order to ensure that there are 
no redundant substitutions.  If the variable definitions and the 
directives were in separate files it wouldn't be necessary, but for the 
convenience of having both in one file, two passes are needed to do the 
job properly.

As for the 'xxxxdir='  idiom,  this is consistent with typical usage 
and other gnu software makes use of such idioms,  so this is nothing 
new (or everything Gnu ?) .


Anyhow, the attached patch is a 'git diff' patch from the current  
master branch of the pkg-config git repo.  It translates the search 
directories and the 'xxxdir' variables by  PKG_CONFIG_SYSROOT_DIR .  
Given that staged installations are becoming more and more important,  
I think this could be a valuable patch for software maintainers.   
however, your feedback is more valuable and so I submit it here.

LHB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pkg-config-sysroot.diff
Type: text/x-patch
Size: 7549 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/pkg-config/attachments/20111020/73fc236e/attachment.bin>


More information about the pkg-config mailing list