Tiny Core Linux

Tiny Core Extensions => TCE Talk => Topic started by: maro on March 28, 2010, 08:19:53 PM

Title: pkg-config improvement
Post by: maro on March 28, 2010, 08:19:53 PM
Yesterday late in the evening I stumbled upon the fact that not setting $PKG_CONFIG_PATH can stop you from compiling some sources. I wanted to find out, if the situation could potentially be improved. Let's face it, not everybody "remembers" to define this variable, even though it is mentioned in the wiki and (several times) in this forum.

First I had a quick look what search path might have been compiled into 'pkg-config':
Code: [Select]
tc@box:~$ strings /usr/local/bin/pkg-config | grep -E '\/pkgconfig(:|$)'
/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig
Please note that this is merely a "rough guess" and not the proper way to "proof" a fact, but at least it got me interested to download the source and have a look into the configure options. There I found the --with-pc-path option. The default value for this is '${libdir}/pkgconfig:${datadir}/pkgconfig' which equates in our case to '/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig'.

So I simply did
  ./configure --with-pc-path='${libdir}/pkgconfig:${datadir}/pkgconfig:/usr/lib/pkgconfig' ; make

The "crude check" of the result indicates to me that this might have done the trick:
Code: [Select]
tc@box:~/pkg-config-0.23$ strings ./pkg-config | grep -E '\/pkgconfig(:|$)'
/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig

So maybe a little rebuild of the extension could help those users that (like me) are having difficulties to remember things, or are not reading all the stuff they should read. And if things work out as I hope, the hint may just become redundant information (and could be therefore removed).
Title: Re: pkg-config improvement
Post by: Juanito on March 28, 2010, 11:17:56 PM
We could probably just do:
Code: [Select]
./configure --with-pc-path="/usr/lib/pkgconfig:/usr/local/lib/pkgconfig"
I'll have a look in a day or two.
Title: Re: pkg-config improvement
Post by: ^thehatsrule^ on March 28, 2010, 11:53:59 PM
Something like this was suggested... a while ago but afaik it was just left alone/forgotten since anyone compiling with our guidelines will have to set some flags.  But if it's in, it's all good ;)
Title: Re: pkg-config improvement
Post by: maro on March 29, 2010, 12:02:35 AM
Well, if one can trust the .list files (which are not 100% correct for all extensions), then I believe there are just a few .pc files "outside" of '/usr/lib/pkgconfig:/usr/local/lib/pkgconfig':
Edit: Plus, I don't think that this is super-urgent. Nothing is broken, it would be more a matter of convenience.
Title: Re: pkg-config improvement
Post by: Juanito on March 29, 2010, 12:15:54 AM
hmm - I've certainly compiled against shared-mime-info using PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/local/lib/pkgconfig" without problems, so perhaps the pkg-config default is appended to $PKG_CONFIG_PATH, but I doubt it as I have  seen plenty of errors if $PKG_CONFIG_PATH is not set.
Title: Re: pkg-config improvement
Post by: ^thehatsrule^ on March 29, 2010, 12:39:39 AM
Yes, it does something like that.  IIRC it attempts to look at PKG_CONFIG_PATH first, then falls back to built-in defaults.

As for compiling against some things, it doesn't always have to rely on pkgconfig and may have other checks or conventions in place.
Title: Re: pkg-config improvement
Post by: maro on March 29, 2010, 01:12:20 AM
Hats, I believe you are correct (search path sequence: $PKG_CONFIG_PATH, followed by compile-time default).

A way to demonstrate this (providing that all directories in question exists):
Code: [Select]
tc@box:~$ pkg-config --list-all --debug 2>&1 | grep '^Scanning'
Scanning directory '/usr/local/lib/pkgconfig'
Scanning directory '/usr/local/share/pkgconfig'
tc@box:~$
tc@box:~$ PKG_CONFIG_PATH=/usr/lib/pkgconfig pkg-config --list-all --debug 2>&1 | grep '^Scanning'
Scanning directory '/usr/lib/pkgconfig'
Scanning directory '/usr/local/lib/pkgconfig'
Scanning directory '/usr/local/share/pkgconfig'
Title: Re: pkg-config improvement
Post by: curaga on March 29, 2010, 04:50:21 AM
If a new default is to be placed, I think including all four would be best - /usr/{local,}/{share,lib}/pkgconfig
Title: Re: pkg-config improvement
Post by: Juanito on April 01, 2010, 06:00:45 AM
posted