Subject: Re: bug#14025: Configure problem in coreutils 8.13

From: Pádraig Brady <[email-masked]>
Date: Fri, 22 Mar 2013 14:10:10 +0000

On 03/21/2013 04:55 PM, Ellis N. Thomas wrote:
>     Configure problem in coreutils 8.13
> 
> To: <[email-masked]>
> 
> 1 Background
> 
>     The release used was NOT the latest, so it is quite likely that these matters
> have been previously addressed.  On the other hand, it is possible that
> installation has not been attempted for this actual Unix version.
> 
> Running Mac OS X:
> 
>   System Version:    Mac OS X 10.5.8 (9L30)
>   Kernel Version:    Darwin 9.8.0
>   >uname -mpv
>   Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 i386
> 
>     The reason for installing 8.13 was that version 8.21 from the ftp area
> (ftp://ftp.gnu.org/gnu/coreutils/) was an xz version and there seemed to be
> no support for that format on this machine.  The latest gz was 8.13 from
> Sep 2011, so also downloaded version 8.13, and proceeded to install this.
> 
>     This problem was formerly included in bug#13912, but has now been
> split off from other topics covered there.
> 
> 
> 2 Failure
> 
>     When `make' was run, many errors were reported, concerning expr.c
> The first error is
> expr.c:54:18: error: gmp.h: No such file or directory
> 
>     Noted that config.status has
>     D["HAVE_GMP"]=" 1"
> and the expr.c source tests this.  It seems that configure has
> incorrectly decided that gmp is available, and expr.c fails to find the header,
> and all other errors arise from this.
> 
>     Since the expr.c source allowed for the test failing, it seemed possible to
> proceed without gmp.  So config.status was modified so that
>     D["HAVE_GMP"]=" 0"
> then make reran OK.  This seems to confirm that the problem is in configure.
> 
> 
> 3 Extra Information
> 
>     It was only later that it was realised that configure --help included:
> **** From --help ****
>   --without-gmp           do not use the GNU MP library for arbitrary
>                                       precision calculation (default: use it if available)
> 
> **** End from --help ****
> 
>     The optional nature of gmp and this option ought to be included in the
> README.  However, the decision made by configure "use it if available"
> still seems incorrect.
> 
>     Although gmp was not installed at the time, there was a source download
> in a nearby directory.  The download of gcc-4.7.2 was being prepared for
> building.  It had previously been established that gmp was a Prerequisite,
> so it was placed ready to be installed along with the gcc sources.
> 
> Directories:
> 
> /Gnu/coreutils/coreutils-8.13    Being used to build coreutils.
> 
> /Gnu/gcc/src/gcc-4.7.2/    Sources preparing for installation
> /Gnu/gcc/obj/                Area for building
> 
> /Gnu/gmp/gmp-5.1.0        Sources preparing for installation
> 
> The gcc directory includes a link for gmp
> /Gnu/gcc/src/gcc-4.7.2/gmp -> /Gnu/gmp/gmp-5.1.0
> 
> (As suggested in the gcc downloading information:
> "Likewise the GMP, MPFR and MPC libraries can be automatically built
> together with GCC.  Unpack the GMP, MPFR and/or MPC source distributions
> in the directory containing the GCC sources and rename their directories to
> gmp, mpfr and mpc, respectively (or use symbolic links with the same name)."
> 
>     It is possible that one of these gmp directories was identified
> by configure.
> 
> 
> 4 Conclusion
> 
>     The config.log file is available (5.3MB), plus config.status (96kB).  There
> is also a file from redirecting standard output during the run of configure (60kB).
> 
>     If extra information about the matters reported above would be of
> value please contact:
>     [email-masked]
> 
> Ellis N. Thomas/21-Mar-2013

So here on GNU/Linux AC_SEARCH_LIBS indicates that GMP is not
available unless the gmp-devel package is installed.
The devel package makes _both_ the header available to the compiler,
and the lib available to the linker.

$ ld -lgmp
ld: cannot find -lgmp
$ sudo yum install gmp-devel
$ ld -lgmp
linking...

So it seems on your system that the lib is available to the linker
but the header is not.  We can work around that in configure
with the attached patch.

thanks,
Pádraig.
>From cbedc43a3b18e99995cbc35146567382ec29d948 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
Date: Fri, 22 Mar 2013 13:58:55 +0000
Subject: [PATCH] build: fix building with GMP on Mac OS X

* m4/gmp.m4 (cu_GMP): Also check that gmp.h is available
which is required on one Mac OS X 10.5.8 system at least.
---
 m4/gmp.m4 |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/m4/gmp.m4 b/m4/gmp.m4
index 2592090..ffe0113 100644
--- a/m4/gmp.m4
+++ b/m4/gmp.m4
@@ -23,18 +23,23 @@ AC_DEFUN([cu_GMP],
     [cu_use_gmp=auto])
 
   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)])
-        # This only available in GMP >= 5
-        AC_CHECK_DECLS([mpz_inits], [], [], [[#include <gmp.h>]])
-       }],
-      [AC_MSG_WARN([libgmp development library was not found or not usable.])
-       AC_MSG_WARN([AC_PACKAGE_NAME will be built without GMP support.])])
-    LIBS=$cu_saved_libs
+    dnl It was noticed on one MacOS X 10.5.8 system at least
+    dnl that the libs were available but the header wasn't
+    AC_CHECK_HEADERS_ONCE([gmp.h])
+    if test $ac_cv_header_gmp_h = yes; 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)])
+          # This only available in GMP >= 5
+          AC_CHECK_DECLS([mpz_inits], [], [], [[#include <gmp.h>]])
+         }],
+        [AC_MSG_WARN([libgmp development library was not found or not usable.])
+         AC_MSG_WARN([AC_PACKAGE_NAME will be built without GMP support.])])
+      LIBS=$cu_saved_libs
+    fi
   fi
 ])
-- 
1.7.7.6