[PATH] sysroot handling
JLM aka cityhunter
jlm_devel at laposte.net
Sun Oct 2 08:04:33 PDT 2005
here is a new patch, that don't segfault with me and is smaller... (and
better located)
please test it and include it in next pkg-config release
regards,
JLM
-------------- next part --------------
diff -ur pkg-config-0.19/main.c pkg-config-0.19-sysroot/main.c
--- pkg-config-0.19/main.c 2005-05-21 11:14:47.000000000 +0200
+++ pkg-config-0.19-sysroot/main.c 2005-10-02 16:40:05.227914591 +0200
@@ -46,6 +46,8 @@
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, ...)
@@ -195,7 +197,7 @@
GString *str;
GSList *packages = NULL;
char *search_path;
- char *pcbuilddir;
+ char *pcbuilddir;
const char *pkglibdir;
char **search_dirs;
char **iter;
@@ -343,6 +345,7 @@
}
}
#endif
+ pcsysrootdir = getenv ("PKG_CONFIG_SYSROOT_DIR");
pcbuilddir = getenv ("PKG_CONFIG_TOP_BUILD_DIR");
if (pcbuilddir)
diff -ur pkg-config-0.19/pkg.c pkg-config-0.19-sysroot/pkg.c
--- pkg-config-0.19/pkg.c 2005-07-15 10:20:20.000000000 +0200
+++ pkg-config-0.19-sysroot/pkg.c 2005-10-02 16:41:11.013075916 +0200
@@ -446,11 +446,23 @@
GSList *tmp;
GString *str = g_string_new ("");
char *retval;
+ int offset=0;
tmp = list;
while (tmp != NULL)
{
- g_string_append (str, tmp->data);
+ if (pcsysrootdir != NULL)
+ {
+ if (!strncmp(tmp->data,"-I",2) ||
+ !strncmp(tmp->data,"-L",2))
+ {
+ offset=2;
+ g_string_append_c (str,((char*)tmp->data)[0]);
+ g_string_append_c (str,((char*)tmp->data)[1]);
+ g_string_append (str,pcsysrootdir);
+ }
+ }
+ g_string_append (str, tmp->data+offset);
g_string_append_c (str, ' ');
tmp = g_slist_next (tmp);
diff -ur pkg-config-0.19/pkg-config.1 pkg-config-0.19-sysroot/pkg-config.1
--- pkg-config-0.19/pkg-config.1 2005-06-03 08:53:20.000000000 +0200
+++ pkg-config-0.19-sysroot/pkg-config.1 2005-10-02 16:57:59.552169479 +0200
@@ -260,6 +260,15 @@
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 -ur pkg-config-0.19/pkg.h pkg-config-0.19-sysroot/pkg.h
--- pkg-config-0.19/pkg.h 2005-06-27 21:53:05.000000000 +0200
+++ pkg-config-0.19-sysroot/pkg.h 2005-10-02 16:40:41.678334195 +0200
@@ -119,6 +119,9 @@
/* If TRUE, do not automatically prefer uninstalled versions */
extern gboolean disable_uninstalled;
+/* string that contain environment */
+extern char* pcsysrootdir;
+
#ifdef G_OS_WIN32
/* If TRUE, do not automatically define "prefix" while
* parsing each .pc file */
More information about the pkg-config
mailing list