Description
Lots of packages generate pkg-config files at build time, usually written to ${prefix}/lib/pkgconfig
. These pkg-config files basically always seem to have a variable called prefix
, which is set to the build-time prefix and is used as a base path for the rest of the variables in the pkg-config file.
Here's an example from the Curl build, under lib/pkgconfig/curl.pc
(as of commit 45d2638
):
prefix=/
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
supported_protocols="DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS IPFS IPNS MQTT POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP"
supported_features="alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz NTLM SSL threadsafe TLS-SRP UnixSockets zstd"
Name: libcurl
URL: https://curl.se/
Description: Library to transfer files with ftp, http, etc.
Version: 8.9.1
Requires:
Requires.private: zlib,libzstd,openssl
Libs: -L${libdir} -lcurl
Libs.private: -lssl -lcrypto -lssl -lcrypto -lzstd -lz
Cflags: -I${includedir}
Note: license omitted, see
COPYING
You can actually use the ${pcfiledir}
variable to get the directory containing the .pc
file itself, so it's possible to tweak a pkg-config file to work with portable dirs. For example, we could patch the first line of Curl like this:
prefix=${pcfiledir}/../../
We already have a few packages that manually patch their pkg-config files with a script:
We should provide a utility in std
to handle this directly. The current scripts to patch these files are pretty minimal sed
scripts, so it should be pretty easy to just move one of the existing functions into std
directly. This might also be a good opportunity to figure out if we can make a more robust implementation that's a little less fragile
Activity