main: if PKG_CONFIG_FDO_SYSROOT_RULES is set, or DESTDIR matches PKG_CONFIG_SYSROOT_DIRS, disable the automatic sysroot rewriting

Closes #205.
pull/216/head
Ariadne Conill 2021-03-18 06:22:11 -06:00
parent b6c8f6fb0a
commit fd1b8ccca6
4 changed files with 23 additions and 2 deletions

View File

@ -1015,6 +1015,9 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
if (getenv("PKG_CONFIG_FDO_SYSROOT_RULES"))
want_client_flags |= PKGCONF_PKG_PKGF_FDO_SYSROOT_RULES;
if ((want_flags & PKG_SHORT_ERRORS) == PKG_SHORT_ERRORS)
want_client_flags |= PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS;
@ -1101,8 +1104,18 @@ main(int argc, char *argv[])
pkgconf_client_set_buildroot_dir(&pkg_client, builddir);
if ((sysroot_dir = getenv("PKG_CONFIG_SYSROOT_DIR")) != NULL)
{
const char *destdir;
pkgconf_client_set_sysroot_dir(&pkg_client, sysroot_dir);
if ((destdir = getenv("DESTDIR")) != NULL)
{
if (!strcmp(destdir, sysroot_dir))
want_client_flags |= PKGCONF_PKG_PKGF_FDO_SYSROOT_RULES;
}
}
/* we have determined what features we want most likely. in some cases, we override later. */
pkgconf_client_set_flags(&pkg_client, want_client_flags);

View File

@ -251,6 +251,7 @@ PKGCONF_API pkgconf_cross_personality_t *pkgconf_cross_personality_find(const ch
#define PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS 0x1000
#define PKGCONF_PKG_PKGF_DONT_FILTER_INTERNAL_CFLAGS 0x2000
#define PKGCONF_PKG_PKGF_DONT_MERGE_SPECIAL_FRAGMENTS 0x4000
#define PKGCONF_PKG_PKGF_FDO_SYSROOT_RULES 0x8000
#define PKGCONF_PKG_DEPF_INTERNAL 0x1

View File

@ -254,8 +254,11 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const
const char *ptr;
char *bptr = buf;
if (*value == '/' && client->sysroot_dir != NULL && strncmp(value, client->sysroot_dir, strlen(client->sysroot_dir)))
bptr += pkgconf_strlcpy(buf, client->sysroot_dir, sizeof buf);
if (!(client->flags & PKGCONF_PKG_PKGF_FDO_SYSROOT_RULES))
{
if (*value == '/' && client->sysroot_dir != NULL && strncmp(value, client->sysroot_dir, strlen(client->sysroot_dir)))
bptr += pkgconf_strlcpy(buf, client->sysroot_dir, sizeof buf);
}
for (ptr = value; *ptr != '\0' && bptr - buf < PKGCONF_BUFSIZE; ptr++)
{

View File

@ -213,6 +213,10 @@ The format of the debug log messages is implementation-specific.
If set, disables the path relocation feature.
.It Va PKG_CONFIG_MSVC_SYNTAX
If set, uses MSVC syntax for fragments.
.It Va PKG_CONFIG_FDO_SYSROOT_RULES
If set, follow the sysroot prefixing rules that freedesktop.org pkg-config uses.
.It Va DESTDIR
If set to PKG_CONFIG_SYSROOT_DIR, assume that PKG_CONFIG_FDO_SYSROOT_RULES is set.
.El
.Sh EXAMPLES
Displaying the CFLAGS of a package: