Question

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).

Was it helpful?

Solution

UPDATE: Evidently there is now a way to do this:

pkg-config --variable pc_path pkg-config

Found in this bug report (see comment #4). The current man page appears to document this.

Original answer:

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;}'

OTHER TIPS

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

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top