where does 'pkg-config' takes its information from?
http://linux.die.net/man/1/pkg-config
pkg-config retrieves information about packages from special metadata files. These files are named after the package, with the extension .pc. By default, pkg-config looks in the directory prefix/lib/pkgconfig for these files; it will also look in the colon-separated (on Windows, semicolon-separated) list of directories specified by the PKG_CONFIG_PATH environment variable.
Following the manual (at least in my version of pc-config), the search path for the relevant *.pc-files will be displayed with the command:
pkg-config --variable pc_path pkg-config
So, if I want to compile something e.g. with libsoup and don't know the version number (let's say 2.4) of libsoup installed, I was successfull writing:
pkg-config --cflags --libs $(grep -l 'Cflags.*libsoup' $(find $(pkg-config --variable pc_path pkg-config|tr ':' ' ') -name "*.pc" 2>/dev/null)|tail -n1)