Subject: bug#12224: Several testsuite failures on OpenIndiana

From: Paul Eggert <[email-masked]>
Date: Sat, 18 Aug 2012 11:29:13 -0700

On 08/18/2012 08:29 AM, Paul Eggert wrote:
> This looks like a setup problem

I reproduced a similar (but not identical) setup problem
on Solaris 11, and propose the following coreutils patch, which fixes
things for me there.  Does it also fix the OpenIndiana
problem?

>From 4661019854961b4985620c17530d7da8e66fd827 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sat, 18 Aug 2012 11:26:36 -0700
Subject: [PATCH] expr: port cu_GMP to Solaris 11

* m4/gmp.m4 (cu_GMP): Port to Solaris 11, which puts libgmp under
pkg-config control.  Related to a problem reported by Stefano
Lattarini in <http://bugs.gnu.org/12224>.
---
 m4/gmp.m4 |   49 ++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/m4/gmp.m4 b/m4/gmp.m4
index e337e16..c458cc8 100644
--- a/m4/gmp.m4
+++ b/m4/gmp.m4
@@ -24,15 +24,46 @@ AC_DEFUN([cu_GMP],
 
   if test $cu_use_gmp != no; then
     cu_saved_libs=$LIBS
-    AC_SEARCH_LIBS([__gmpz_init], [gmp],
-      [test "$ac_cv_search___gmpz_init" = "none required" ||
-       {
-        LIB_GMP=$ac_cv_search___gmpz_init
-        AC_DEFINE([HAVE_GMP], [1],
-          [Define if you have GNU libgmp (or replacement)])
-       }],
-      [AC_MSG_WARN([libgmp development library was not found or not usable.])
-       AC_MSG_WARN([AC_PACKAGE_NAME will be built without GMP support.])])
+    cu_have_gmp=no
+    AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no])
+    if test "$PKG_CONFIG" != "no"; then
+      AC_MSG_CHECKING([for libgmp under pkg-config])
+      if $PKG_CONFIG --exists "libgmp" 2>&AS_MESSAGE_LOG_FD &&
+        cu_CFLAGS_GMP=`$PKG_CONFIG --cflags "libgmp" 2>&AS_MESSAGE_LOG_FD` &&
+        cu_LIB_GMP=`$PKG_CONFIG --libs "libgmp" 2>&AS_MESSAGE_LOG_FD`; then
+          if test "$gl_gcc_warnings" != yes; then
+            isystem='-I'
+          else
+            isystem='-isystem '
+          fi
+          edit_cflags="
+            s,///*,/,g
+            s/^/ /
+            s/ -I/ $isystem/g
+            s/^ //
+            s/./ &/
+          "
+          cu_CFLAGS_GMP=`AS_ECHO(["$cu_CFLAGS_GMP"]) | sed -e "$edit_cflags"`
+          CFLAGS=$CFLAGS$cu_CFLAGS_GMP
+          LIB_GMP=`AS_ECHO(["$cu_LIB_GMP"]) | sed -e 's,///*,/,g'`
+          cu_have_gmp="yes CFLAGS='$cu_CFLAGS_GMP' LIBS='$LIB_GMP'"
+      fi
+      AC_MSG_RESULT([$cu_have_gmp])
+    fi
+    if test "$cu_have_gmp" = no; then
+      AC_SEARCH_LIBS([__gmpz_init], [gmp],
+        [test "$ac_cv_search___gmpz_init" = "none required" ||
+         {
+          LIB_GMP=$ac_cv_search___gmpz_init
+          cu_have_gmp=yes
+         }],
+        [AC_MSG_WARN([libgmp development library was not found or not usable.])
+         AC_MSG_WARN([AC_PACKAGE_NAME will be built without GMP support.])])
+    fi
+    if test "$cu_have_gmp" != no; then
+      AC_DEFINE([HAVE_GMP], [1],
+        [Define if you have GNU libgmp (or replacement)])
+    fi
     LIBS=$cu_saved_libs
   fi
 ])
-- 
1.7.6.5