[PATH] sysroot handling

Enrico Weigelt weigelt at metux.de
Fri Sep 16 06:05:30 PDT 2005


Hi folks,

i've a little patch to handle sysroot environments properly.
It simply adds $SYSROOT to library and include pathes if set.

cu
-- 
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux IT service

  phone:     +49 36207 519931         www:       http://www.metux.de/
  fax:       +49 36207 519932         email:     contact at metux.de
  cellphone: +49 174 7066481
---------------------------------------------------------------------
 -- DSL ab 0 Euro. -- statische IP -- UUCP -- Hosting -- Webshops --
---------------------------------------------------------------------
-------------- next part --------------
diff -ruN pkg-config-0.18.1.orig/pkg.c pkg-config-0.18.1/pkg.c
--- pkg-config-0.18.1.orig/pkg.c	Sat Aug 27 22:18:14 2005
+++ pkg-config-0.18.1/pkg.c	Sat Aug 27 22:38:30 2005
@@ -886,6 +886,31 @@
       iter = iter->next;
     }
 
+  /* special handling for SYSROOT */
+  const char* sysroot = getenv("SYSROOT");
+
+  if (sysroot)
+  {
+    iter = pkg->I_cflags;
+    while (iter != NULL)
+    {
+      gint offset = 0;
+      /* we put things in canonical -I/usr/include (vs. -I /usr/include) format,
+       * but if someone changes it later we may as well be robust
+       */
+      if (strncmp(iter->data,"-I/", 3)==0)
+      {
+	char buffer[4096];
+        strcpy(buffer,"-I");
+	strcat(buffer,sysroot);
+	strcat(buffer,(iter->data)+2);
+        free(iter->data);
+	iter->data = strdup(buffer);
+      }
+      iter = iter->next;
+    }
+  }
+
   while (count)
     {
       pkg->I_cflags = g_slist_remove (pkg->I_cflags, NULL);
@@ -920,6 +945,26 @@
       iter = iter->next;
     }
 #undef SYSTEM_LIBDIR
+    
+  /* --- special handling for sysroot --- */
+  if (sysroot)
+  {
+     debug_spew("Special handling for SYSROOT ...\n");
+     iter = pkg->L_libs;
+     while (iter != NULL)
+     {
+      char buffer[4096] = "\0";
+      if (strncmp(iter->data, "-L/", 3)==0)
+      {
+        strcpy(buffer,"-L");
+	strcat(buffer,sysroot);
+	strcat(buffer,(iter->data)+2);
+        free(iter->data);
+	iter->data = strdup(buffer);
+      }
+      iter = iter->next;
+    }
+  }
 
   while (count)
     {


More information about the pkg-config mailing list