views:

161

answers:

4

How do I know where to install my .pc file? These files are put in different places on different operating systems. The goal is to be able to use something like $(INSTALL) mylib.pc $$(pkg-config --pcdir) in the install target. I thought pkg-config would be able to tell me somehow, but can't find anything.

I'm looking for a "standalone" solution usable in plain Makefile (must not require support from autotools or similar).

+1  A: 

Unfortunately, for a stock pkg-config installation (for version 0.23), there is no way to extract the default "pc path", short of running strings on the binary (e.g., strings /usr/bin/pkg-config | grep '/usr/.*/pkgconfig').

If you are able to install a custom build, just patch it to write out the value of PKG_CONFIG_PC_PATH when run with the appropriate option.

Another option, which probably won't help you (but that I'd mention anyway for completeness), is to set the PKG_CONFIG_PATH environment variable when calling pkg-config.

Chris Jester-Young
"impossible": that's been my conclusion as well. not an answer i'd be overly happy with, but unless harry potter shows up, i'll accept this.
just somebody
+2  A: 

Horrible hackish solution (assuming bourne shell):

pkg-config --debug 2>&1 |grep Scanning | sed -e 's/Scanning directory //' -e "s/'//g"

This may give you more than one location.

edit by @just somebody

shorter version

pkg-config --debug 2>&1 | sed -ne '/Scanning directory /s///p'

and to stop after the first directory:

pkg-config --debug 2>&1 | sed -ne '/Scanning directory /{s///p;q;}'
Craig
harry potter shows up! ;)
just somebody
@just somebody: Congrats! Very nice (but hacky, but so is my solution :-P) approach to use debug messages. :-P
Chris Jester-Young
A: 

it should go into ${libdir}/pkgconfig (ie ${prefix}/lib/pkgconfig)

basically if you install libraries and they go in ${libdir} then your .pc file should be in ${libdir}/pkgconfig and nowhere else.

Spudd86
it'd be nice if the real world was this simple, but for whatever reason, FreeBSD puts pkgconfig files in ${prefix}/libdata/pkgconfig. it's stupid, but it's there.
just somebody
in that case look at what stuff like glib does
Spudd86
+1  A: 

As of pkg-config 0.24, you can do "pkg-config --variable=pc_path pkg-config".

https://bugs.freedesktop.org/show_bug.cgi?id=14975

scop
hey, that's great news! thanks a lot!
just somebody