main: implement support for PKG_CONFIG_SYSROOT_DIR (issue #5)

pull/29/head
William Pitcock 2012-05-07 03:45:24 -05:00
parent 9885643e45
commit 2aaa1ce0df
1 changed files with 24 additions and 2 deletions

26
main.c
View File

@ -64,11 +64,11 @@ static char *required_exact_module_version = NULL;
static char *required_max_module_version = NULL;
static char *required_module_version = NULL;
static char *want_variable = NULL;
static char *sysroot_dir = NULL;
static bool
fragment_has_system_dir(pkg_fragment_t *frag)
{
switch (frag->type)
{
case 'L':
@ -84,6 +84,23 @@ fragment_has_system_dir(pkg_fragment_t *frag)
return false;
}
static inline const char *
print_sysroot_dir(pkg_fragment_t *frag)
{
if (sysroot_dir == NULL)
return "";
else switch (frag->type)
{
case 'L':
case 'I':
return sysroot_dir;
default:
break;
}
return "";
}
static void
print_fragment(pkg_fragment_t *frag)
{
@ -91,7 +108,7 @@ print_fragment(pkg_fragment_t *frag)
return;
if (frag->type)
printf("-%c%s ", frag->type, frag->data);
printf("-%c%s%s ", frag->type, print_sysroot_dir(frag), frag->data);
else
printf("%s ", frag->data);
}
@ -580,6 +597,11 @@ main(int argc, char *argv[])
else
pkg_tuple_add_global("pc_top_builddir", "$(top_builddir)");
if ((sysroot_dir = getenv("PKG_CONFIG_SYSROOT_DIR")) != NULL)
pkg_tuple_add_global("pc_sysrootdir", sysroot_dir);
else
pkg_tuple_add_global("pc_sysrootdir", "/");
if (required_pkgconfig_version != NULL)
{
if (pkg_compare_version(PKG_PKGCONFIG_VERSION_EQUIV, required_pkgconfig_version) >= 0)