On Sat, 02 Apr 2011 at 01:48:02 -0700, Steve Langasek wrote:
> > http://git.debian.org/?p=users/smcv/multiarch/pkg-config.git;a=shortlog;h=refs/heads/multiarch
> 
> This git repository has gone missing sometime in the past year. :(

Resurrected, same location (I was asked to reduce space usage on Alioth, and
there seemed to be no interest in the branch at the time). No changes since
I last looked at this, so I haven't reviewed whether this is still suitable
for the current multiarch proposal, but hopefully it is...

> Please
> send patches to the BTS instead of referring to other websites for them!

Attached. I'll copy them upstream too.

> $ for opt in '' $(${CC-gcc} -print-multi-lib | sed -n -e's/.*;@/-/p'); do
>     gcc $opt -print-search-dirs | sed -n -e's/^libraries: =//p' \
>     | sed -e's/:/\n/g' | xargs -n1 readlink -f | grep -v 'gcc\|/[0-9.]\+$'
>   done | sort -u
> 
> on Ubuntu/amd64, for instance, this returns:
> 
> /lib
> /lib32
> /usr/lib
> /usr/lib32
> /usr/lib/x86_64-linux-gnu
> /usr/x86_64-linux-gnu/lib

In Debian I currently get nearly the same, but without the traditional
/usr/$(gnu_triplet)/lib cross-compiling path:

  amd64:
    /lib
    /lib64
    /usr/lib
    /usr/lib/i486-linux-gnu
    /usr/lib64

  i386 chroot:
    /lib
    /lib32
    /usr/lib
    /usr/lib32
    /usr/lib/x86_64-linux-gnu

> (I think the absence of the multiarch directory for i386 here may be a bug
> in the gcc multiarch path; there is certainly code in gcc to map -m32 to
> i386-linux-gnu... this will need investigating later.)

We could hard-code that case in pkg-config for the moment? It looks to me as
though it won't be fixed otherwise in Debian until
http://wiki.debian.org/Multiarch/Bootstrapping step 3, "stage1 multiarch
build of gcc-4.5:i386", is done?

    S
From c2bbde3531f21b2318344f0b3ab5d03398af74ed Mon Sep 17 00:00:00 2001
From: Colin Walters <[email protected]>
Date: Sun, 14 Feb 2010 16:22:43 +0000
Subject: [PATCH 1/3] fd.o#16095: exclude both /usr/lib and /usr/lib64

---
 pkg.c |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/pkg.c b/pkg.c
index 0409531..3099b43 100644
--- a/pkg.c
+++ b/pkg.c
@@ -935,31 +935,44 @@ verify_package (Package *pkg)
   g_slist_foreach (system_directories, (GFunc) g_free, NULL);
   g_slist_free (system_directories);
 
+
+  system_directories = g_slist_prepend (NULL, "/usr/lib");
 #ifdef PREFER_LIB64
-#define SYSTEM_LIBDIR "/usr/lib64"
-#else
-#define SYSTEM_LIBDIR "/usr/lib"
+  system_directories = g_slist_prepend (system_directories, "/usr/lib64");
 #endif
   count = 0;
   iter = pkg->L_libs;
   while (iter != NULL)
     {
-      if (strcmp (iter->data, "-L" SYSTEM_LIBDIR) == 0 ||
-          strcmp (iter->data, "-L " SYSTEM_LIBDIR) == 0)
+      GSList *subiter = system_directories;
+      while (subiter != NULL)
         {
-          debug_spew ("Package %s has -L" SYSTEM_LIBDIR " in Libs\n",
-                      pkg->name);
-          if (g_getenv ("PKG_CONFIG_ALLOW_SYSTEM_LIBS") == NULL)
-            {              
-              iter->data = NULL;
-              ++count;
-              debug_spew ("Removing -L" SYSTEM_LIBDIR " from libs for %s\n", pkg->key);
+          gboolean is_system = FALSE;
+          const char *linker_arg = iter->data;
+          const char *system_libpath = subiter->data;
+          if (strncmp (linker_arg, "-L ", 3) == 0 &&
+              strcmp (linker_arg + 3, system_libpath) == 0)
+            is_system = TRUE;
+          else if (strncmp (linker_arg, "-L", 2) == 0 &&
+              strcmp (linker_arg + 2, system_libpath) == 0)
+            is_system = TRUE;
+          if (is_system)
+            {
+              debug_spew ("Package %s has -L %s in Libs\n",
+                          pkg->name, system_libpath);
+              if (g_getenv ("PKG_CONFIG_ALLOW_SYSTEM_LIBS") == NULL)
+                {              
+                  iter->data = NULL;
+                  ++count;
+                  debug_spew ("Removing -L %s from libs for %s\n", system_libpath, pkg->key);
+                  break;
+                }
             }
+          subiter = subiter->next;
         }
-
       iter = iter->next;
     }
-#undef SYSTEM_LIBDIR
+  g_slist_free (system_directories);
 
   while (count)
     {
-- 
1.7.4.1

From 7a7283728b3e1663c80810d2650d1705a8db4eff Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Sun, 14 Feb 2010 16:28:40 +0000
Subject: [PATCH 2/3] Rename subiter to system_dir_iter to match logic for header files

The name @subiter doesn't seem appropriate; it iterates over a separate
list, not over an item of @iter.

Also remove some trailing whitespace.
---
 pkg.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/pkg.c b/pkg.c
index 3099b43..66d10f6 100644
--- a/pkg.c
+++ b/pkg.c
@@ -944,12 +944,14 @@ verify_package (Package *pkg)
   iter = pkg->L_libs;
   while (iter != NULL)
     {
-      GSList *subiter = system_directories;
-      while (subiter != NULL)
+      GSList *system_dir_iter = system_directories;
+
+      while (system_dir_iter != NULL)
         {
           gboolean is_system = FALSE;
           const char *linker_arg = iter->data;
-          const char *system_libpath = subiter->data;
+          const char *system_libpath = system_dir_iter->data;
+
           if (strncmp (linker_arg, "-L ", 3) == 0 &&
               strcmp (linker_arg + 3, system_libpath) == 0)
             is_system = TRUE;
@@ -961,14 +963,14 @@ verify_package (Package *pkg)
               debug_spew ("Package %s has -L %s in Libs\n",
                           pkg->name, system_libpath);
               if (g_getenv ("PKG_CONFIG_ALLOW_SYSTEM_LIBS") == NULL)
-                {              
+                {
                   iter->data = NULL;
                   ++count;
                   debug_spew ("Removing -L %s from libs for %s\n", system_libpath, pkg->key);
                   break;
                 }
             }
-          subiter = subiter->next;
+          system_dir_iter = system_dir_iter->next;
         }
       iter = iter->next;
     }
-- 
1.7.4.1

From 367e3333d7672e087d43c2e48107a2fb5470e628 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Sun, 14 Feb 2010 17:05:19 +0000
Subject: [PATCH 3/3] Add --with-system-include-path etc.

Instead of hard-coding /usr/include, we now use the environment variable
PKG_CONFIG_SYSTEM_INCLUDE_PATH, defaulting to the argument of
./configure --with-system-include-path, which in turn defaults to
/usr/include.

Similarly, PKG_CONFIG_SYSTEM_LIBRARY_PATH defaults to /usr/lib or
/usr/lib:/usr/lib64 as appropriate.

(As currently implemented, this causes a behaviour change on Win32 -
the option -I/usr/include will now be filtered out.)

The intended usage is for Debian to configure pkg-config with
--with-system-include-path=/usr/include/$(DEB_HOST_GNU_TYPE):/usr/include
and the corresponding library path, for multiarch support
(<http://bugs.debian.org/482884>).
---
 Makefile.am  |    6 +++++-
 configure.in |   30 +++++++++++++++++++++++++-----
 pkg.c        |   42 +++++++++++++++++++++++++++---------------
 3 files changed, 57 insertions(+), 21 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 95998a6..f3cf84e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,7 +17,11 @@ EXTRA_DIST = $(m4_DATA) $(man_MANS) README.win32
 bin_PROGRAMS = pkg-config
 AM_CFLAGS=@WARN_CFLAGS@
 
-INCLUDES=-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" $(included_glib_includes)
+INCLUDES= \
+	-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" \
+	-DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"$(system_include_path)\"" \
+	-DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"$(system_library_path)\"" \
+	$(included_glib_includes)
 
 pkg_config_SOURCES= \
 	pkg.h \
diff --git a/configure.in b/configure.in
index f7a424c..df43546 100644
--- a/configure.in
+++ b/configure.in
@@ -32,6 +32,31 @@ fi
 
 PKG_CONFIG_FIND_PC_PATH
 
+AC_MSG_CHECKING([for --with-system-include-path])
+AC_ARG_WITH(system_include_path,
+ [  --with-system-include-path    Avoid -I flags that add the given directories ],
+ [ system_include_path="$withval" ],
+ [ system_include_path="/usr/include" ])
+ AC_MSG_RESULT([$system_include_path])
+ AC_SUBST([system_include_path])
+
+AC_MSG_CHECKING([for --with-system-library-path])
+AC_ARG_WITH(system_library_path,
+ [  --with-system-library-path    Avoid -L flags that add the given directories ],
+ [ system_library_path="$withval" ],
+ [
+case "$libdir" in
+*lib64)
+  system_library_path="/usr/lib64:/usr/lib"
+  ;;
+*)
+  system_library_path="/usr/lib"
+  ;;
+esac
+])
+ AC_MSG_RESULT([$system_library_path])
+ AC_SUBST([system_library_path])
+
 #
 # Code taken from gtk+-2.0's configure.in.
 #
@@ -90,11 +115,6 @@ case "$host" in
 esac
 AC_MSG_RESULT([$native_win32])
 
-case "$libdir" in
-*lib64) AC_DEFINE(PREFER_LIB64,1,[Define if your native architecture defines libdir to be $prefix/lib64 instead of $prefix/lib.]) ;;
-*) : ;;
-esac
-
 if test x$native_win32 = xyes; then
   # On Win32, use the normal installed GLib.  Yes, this is a circular
   # dependency. But then, only experienced hackers that presumably can
diff --git a/pkg.c b/pkg.c
index 66d10f6..d5602fa 100644
--- a/pkg.c
+++ b/pkg.c
@@ -757,7 +757,7 @@ verify_package (Package *pkg)
   GSList *conflicts_iter;
   GSList *system_dir_iter = NULL;
   int count;
-  const gchar *c_include_path;
+  const gchar *search_path;
 
   /* Be sure we have the required fields */
 
@@ -869,20 +869,26 @@ verify_package (Package *pkg)
   /* We make a list of system directories that gcc expects so we can remove
    * them.
    */
-#ifndef G_OS_WIN32
-  system_directories = g_slist_append (NULL, g_strdup ("/usr/include"));
-#endif
 
-  c_include_path = g_getenv ("C_INCLUDE_PATH");
-  if (c_include_path != NULL)
+  search_path = g_getenv ("PKG_CONFIG_SYSTEM_INCLUDE_PATH");
+
+  if (search_path == NULL)
     {
-      system_directories = add_env_variable_to_list (system_directories, c_include_path);
+      search_path = PKG_CONFIG_SYSTEM_INCLUDE_PATH;
     }
-  
-  c_include_path = g_getenv ("CPLUS_INCLUDE_PATH");
-  if (c_include_path != NULL)
+
+  system_directories = add_env_variable_to_list (system_directories, search_path);
+
+  search_path = g_getenv ("C_INCLUDE_PATH");
+  if (search_path != NULL)
+    {
+      system_directories = add_env_variable_to_list (system_directories, search_path);
+    }
+
+  search_path = g_getenv ("CPLUS_INCLUDE_PATH");
+  if (search_path != NULL)
     {
-      system_directories = add_env_variable_to_list (system_directories, c_include_path);
+      system_directories = add_env_variable_to_list (system_directories, search_path);
     }
 
   count = 0;
@@ -935,11 +941,17 @@ verify_package (Package *pkg)
   g_slist_foreach (system_directories, (GFunc) g_free, NULL);
   g_slist_free (system_directories);
 
+  system_directories = NULL;
+
+  search_path = g_getenv ("PKG_CONFIG_SYSTEM_LIBRARY_PATH");
+
+  if (search_path == NULL)
+    {
+      search_path = PKG_CONFIG_SYSTEM_LIBRARY_PATH;
+    }
+
+  system_directories = add_env_variable_to_list (system_directories, search_path);
 
-  system_directories = g_slist_prepend (NULL, "/usr/lib");
-#ifdef PREFER_LIB64
-  system_directories = g_slist_prepend (system_directories, "/usr/lib64");
-#endif
   count = 0;
   iter = pkg->L_libs;
   while (iter != NULL)
-- 
1.7.4.1

Reply via email to