WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: pkg-config improvement  (Read 4345 times)

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
pkg-config improvement
« 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).

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: pkg-config improvement
« Reply #1 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.

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: pkg-config improvement
« Reply #2 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 ;)

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: pkg-config improvement
« Reply #3 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':
  • The extensions that contain one .pc file each in '/usr/local/share/pkgconfig' are: gnome-doc-utils, gnome-icon-theme, gnome-mime-data, gtk-doc, icon-naming-utils, iso-codes, shared-mime-info, and usb-utils.
  • Apart from this there are only three files in openssl-0.9.8k-dev (which might not be around for much longer) and one file in xine-xvesa-dev that are not in one of the "obvious places".

Edit: Plus, I don't think that this is super-urgent. Nothing is broken, it would be more a matter of convenience.
« Last Edit: March 29, 2010, 12:06:36 AM by maro »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: pkg-config improvement
« Reply #4 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.

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: pkg-config improvement
« Reply #5 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.

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: pkg-config improvement
« Reply #6 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'

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: pkg-config improvement
« Reply #7 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
The only barriers that can stop you are the ones you create yourself.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: pkg-config improvement
« Reply #8 on: April 01, 2010, 06:00:45 AM »
posted