From: Tollef Fog Heen Date: Wed, 16 Jan 2008 22:10:25 +0000 (+0100) Subject: 2008-01-16 Tollef Fog Heen X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed75a7dd4b9cd07286c873e97f5b470d45dbd587;p=pkg-config 2008-01-16 Tollef Fog Heen * 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. --- diff --git a/ChangeLog b/ChangeLog index 187ca61..5b1136b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-01-16 Tollef Fog Heen + + * 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 * pkg.c (internal_get_package): Don't add the internal-only diff --git a/main.c b/main.c index 68c3d42..13cdd2e 100644 --- a/main.c +++ b/main.c @@ -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) { diff --git a/pkg-config.1 b/pkg-config.1 index 80775ef..10fe55b 100644 --- a/pkg-config.1 +++ b/pkg-config.1 @@ -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. diff --git a/pkg.c b/pkg.c index 2c67af5..7f252bd 100644 --- a/pkg.c +++ b/pkg.c @@ -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); diff --git a/pkg.h b/pkg.h index 8043205..d749de4 100644 --- a/pkg.h +++ b/pkg.h @@ -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 */