Package: pkg-config
Version: 0.29.2-1
Severity: wishlist
Tags: upstream
X-Debbugs-Cc: [email protected]

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


-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.14.0-1-amd64 (SMP w/12 CPU threads)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages pkg-config depends on:
ii  libc6         2.32-4
ii  libdpkg-perl  1.20.9
ii  libglib2.0-0  2.70.0-3

pkg-config recommends no packages.

Versions of packages pkg-config suggests:
ii  dpkg-dev  1.20.9

-- no debconf information

Reply via email to