Dear Maintainer,
I'm building a library with its own pkg-config file.
That avoids repeating the information in the .pc file again in the Makefile.
And it also avoids releasing broken .pc files; if the .pc file was incorrect,
my library simply wouldn't build.
However, there's no easy way to do that (and I found today the source of a
bug in my build system due to a missing line). It would be easier if
pkg-config allowed that in a simple manner.
To build (link) a library, I have the following in my Makefile:
PC_ENV := PKG_CONFIG_PATH=lib/pkgconfig
req_pc := $(shell $(PC_ENV) pkg-config --print-requires-private libfoo)
LIBS := -L$(builddir)
LIBS += $(shell $(PC_ENV) pkg-config --libs libfoo)
LIBS += $(shell $(PC_ENV) pkg-config --libs $(req_pc))
However, I noticed today that I was missing the information in Libs.private
from my .pc file. But I don't want to invoke '--static --libs', since that
would pull the Libs.private from all my dependencies, which I don't need.
So I need to extract those with sed. But pkg-config could (and I think
should) do that.
To mirror cc syntax, where -static means link an executable against
static libraries, but -shared means build a shared library,
I think the best syntax for pkg-config would be to add a --shared flag.
For pkg-config, --static would be used for linking an executable against
a static library, and --shared would be used to build a shared object.
So, the following lines should be enough to pull all libs necessary for
building the shared object corresponding to a given .pc file:
PC_ENV := PKG_CONFIG_PATH=lib/pkgconfig
LIBS := $(shell $(PC_ENV) pkg-config --shared --libs libfoo)
Thanks,
Alex