Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[std] Add a utility for fixing pkg-config files #135

Open
kylewlacy opened this issue Oct 19, 2024 · 0 comments
Open

[std] Add a utility for fixing pkg-config files #135

kylewlacy opened this issue Oct 19, 2024 · 0 comments

Comments

@kylewlacy
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant