2008-01-16 Tollef Fog Heen <tfheen@err.no>

* pkg.h, pkg.c (string_list_to_string), pkg-config.1, main.c
             (main): Add sysroot support and document same.  Triggered by
             setting PKG_CONFIG_SYSROOT_DIR in the environment.
This commit is contained in:
Tollef Fog Heen 2008-01-16 23:10:25 +01:00
parent 138f9219b4
commit ed75a7dd4b
5 changed files with 45 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2008-01-16 Tollef Fog Heen <tfheen@err.no>
* pkg.h, pkg.c (string_list_to_string), pkg-config.1, main.c
(main): Add sysroot support and document same. Triggered by
setting PKG_CONFIG_SYSROOT_DIR in the environment.
2007-12-29 Tollef Fog Heen <tfheen@err.no>
* pkg.c (internal_get_package): Don't add the internal-only

11
main.c
View file

@ -46,6 +46,7 @@
static int want_debug_spew = 0;
static int want_verbose_errors = 0;
static int want_stdout_errors = 0;
char *pcsysrootdir = NULL;
void
debug_spew (const char *format, ...)
@ -346,6 +347,16 @@ main (int argc, char **argv)
}
#endif
pcsysrootdir = getenv ("PKG_CONFIG_SYSROOT_DIR");
if (pcsysrootdir)
{
define_global_variable ("pc_sysrootdir", pcsysrootdir);
}
else
{
define_global_variable ("pc_sysrootdir", "/");
}
pcbuilddir = getenv ("PKG_CONFIG_TOP_BUILD_DIR");
if (pcbuilddir)
{

View file

@ -259,6 +259,15 @@ Don't strip -I/usr/include out of cflags.
.I "PKG_CONFIG_ALLOW_SYSTEM_LIBS"
Don't strip -L/usr/lib out of libs
.TP
.I "PKG_CONFIG_SYSROOT_DIR"
Modify -I and -L to use the directories located in target sysroot.
this option is usefull when crosscompiling package that use pkg-config
to determine CFLAGS anf LDFLAGS. -I and -L are modified to point to
the new system root. this means that a -I/usr/include/libfoo will
become -I/var/target/usr/include/libfoo with a PKG_CONFIG_SYSROOT_DIR
equal to /var/target (same rule apply to -L)
.TP
.I "PKG_CONFIG_LIBDIR"
Replaces the default \fIpkg-config\fP search directory.

18
pkg.c
View file

@ -471,7 +471,23 @@ string_list_to_string (GSList *list)
tmp = list;
while (tmp != NULL)
{
g_string_append (str, tmp->data);
char *tmpstr = (char*) tmp->data;
if (pcsysrootdir != NULL)
{
if (tmpstr[0] == '-' &&
(tmpstr[1] == 'I' ||
tmpstr[1] == 'L'))
{
g_string_append_c (str, '-');
g_string_append_c (str, tmpstr[1]);
g_string_append (str, pcsysrootdir);
g_string_append (str, tmpstr+2);
}
}
else
{
g_string_append (str, tmpstr);
}
g_string_append_c (str, ' ');
tmp = g_slist_next (tmp);

2
pkg.h
View file

@ -123,6 +123,8 @@ void disable_private_libs(void);
/* If TRUE, do not automatically prefer uninstalled versions */
extern gboolean disable_uninstalled;
extern char *pcsysrootdir;
#ifdef G_OS_WIN32
/* If TRUE, do not automatically define "prefix" while
* parsing each .pc file */