pkg-config: platform-neutral way to find out where to install my .pc file?

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


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