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).
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.
pkg-config is a useful tool for making sure compiler options are correct when compiling and linking software. Very often with compilers, you will need to determine the proper paths to library header files and code in order to link them to your software project.
pkg-config is a computer program that defines and supports a unified interface for querying installed libraries for the purpose of compiling software that depends on them. It allows programmers and installation scripts to work without explicit knowledge of detailed library path information.
pc files include compiler and linker flags necessary to use a given library, as well as any other relevant metadata. These . pc files are processed by a utility called pkg-config, of which pkgconf is an implementation.
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;}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With