]> Savannah Git Hosting - gnulib.git/commitdiff
libgmp: remove dependency on havelib
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 26 Jul 2020 16:57:47 +0000 (09:57 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 26 Jul 2020 17:07:29 +0000 (10:07 -0700)
* m4/libgmp.m4 (gl_LIBGMP): If gl_HAVE_MODULE_HAVELIB is not defined,
use the more-traditional AC_SEARCH_LIBS approach.
This should work better with GNU Emacs configuration,
which uses pkg-config instead of a havelib-style approach.
* modules/havelib (gl_HAVE_MODULE_HAVELIB): New witness macro.
* modules/libgmp (Depends-on): Remove havelib.

ChangeLog
m4/libgmp.m4
modules/havelib
modules/libgmp

index 44ce5301bd0bc88f72f14ce02ffaaa64ba8a669f..aee21afed7d6437a8cbc7bed67fe5eeeee8f4e62 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2020-07-26  Paul Eggert  <eggert@cs.ucla.edu>
 
+       libgmp: remove dependency on havelib
+       * m4/libgmp.m4 (gl_LIBGMP): If gl_HAVE_MODULE_HAVELIB is not defined,
+       use the more-traditional AC_SEARCH_LIBS approach.
+       This should work better with GNU Emacs configuration,
+       which uses pkg-config instead of a havelib-style approach.
+       * modules/havelib (gl_HAVE_MODULE_HAVELIB): New witness macro.
+       * modules/libgmp (Depends-on): Remove havelib.
+
        libgmp: remove HAVE_GMP, LIB_GMP
        * m4/libgmp.m4 (gl_LIBGMP): Do not define HAVE_GMP and LIB_GMP, as
        they’re redundant.  I’ll adjust GNU Coreutils accordingly.
index e48b5c2c2bf8c21188dedbd9649e6eb718703fda..82c065e2c2c5fee99da139cb0f5cc912292d5f57 100644 (file)
@@ -1,4 +1,4 @@
-# libgmp.m4 serial 3
+# libgmp.m4 serial 4
 # Configure the GMP library or a replacement.
 dnl Copyright 2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -6,10 +6,10 @@ dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 dnl gl_LIBGMP
-dnl Searches for an installed libgmp.
-dnl If found, it sets and AC_SUBSTs HAVE_LIBGMP=yes and the LIBGMP and LTLIBGMP
-dnl variables, and augments the CPPFLAGS variable, and #defines HAVE_LIBGMP.
-dnl Otherwise, it sets and AC_SUBSTs HAVE_LIBGMP=no and LIBGMP and LTLIBGMP to
+dnl Search for an installed libgmp.
+dnl If found, set and AC_SUBST HAVE_LIBGMP=yes and the LIBGMP and LTLIBGMP
+dnl variables, and augment the CPPFLAGS variable, and #define HAVE_LIBGMP to 1.
+dnl Otherwise, set and AC_SUBST HAVE_LIBGMP=no and LIBGMP and LTLIBGMP to
 dnl empty.
 
 AC_DEFUN([gl_LIBGMP],
@@ -25,19 +25,35 @@ AC_DEFUN([gl_LIBGMP],
       LTLIBGMP=
       ;;
     *)
-      AC_LIB_HAVE_LINKFLAGS([gmp], [],
-        [#include <gmp.h>],
-        [static const mp_limb_t x[2] = { 0x73, 0x55 };
-         mpz_t tmp;
-         mpz_roinit_n (tmp, x, 2);
-        ],
-        [no])
-      if test $HAVE_LIBGMP = no; then
-        case "$with_libgmp" in
-          yes)
-            AC_MSG_ERROR([GMP not found, although --with-libgmp was specified. Try specifying --with-libgmp-prefix=DIR.])
-            ;;
-        esac
+      dnl Prefer AC_LIB_HAVE_LINKFLAGS if the havelib module is also in use.
+      m4_ifdef([gl_HAVE_MODULE_HAVELIB],
+        [AC_LIB_HAVE_LINKFLAGS([gmp], [],
+           [#include <gmp.h>],
+           [static const mp_limb_t x[2] = { 0x73, 0x55 };
+            mpz_t tmp;
+            mpz_roinit_n (tmp, x, 2);
+           ],
+           [no])],
+        [gl_saved_LIBS=$LIBS
+         AC_SEARCH_LIBS([__gmpz_roinit_n], [gmp])
+         LIBS=$gl_saved_LIBS
+         case $ac_cv_search___gmpz_roinit_n in
+           'none needed')
+             HAVE_LIBGMP=yes LIBGMP=;;
+           -*)
+             HAVE_LIBGMP=yes LIBGMP=$ac_cv_search___gmpz_roinit_n;;
+           *)
+             HAVE_LIBGMP=no LIBGMP=;;
+         esac
+         LTLIBGMP=$LIBGMP
+         AC_SUBST([HAVE_LIBGMP])
+         AC_SUBST([LIBGMP])
+         AC_SUBST([LTLIBGMP])])
+      if test "$with_libgmp,$HAVE_LIBGMP" = yes,no; then
+        AC_MSG_ERROR(
+          [GMP not found, although --with-libgmp was specified.m4_ifdef(
+             [AC_LIB_HAVE_LINKFLAGS],
+             [ Try specifying --with-libgmp-prefix=DIR.])])
       fi
       ;;
   esac
index e47dbfc11b3f3f07d262e66f261f59520038cc20..2d8dd57f568e7fdc2bb31f16ec9858aa38425161 100644 (file)
@@ -11,6 +11,7 @@ build-aux/config.rpath
 Depends-on:
 
 configure.ac:
+AC_DEFUN([gl_HAVE_MODULE_HAVELIB])
 
 Makefile.am:
 
index 70f20cf70c816d25a0f19161823d7cff21a2b1e6..a0c77056d36bd668a41910c07b7ae115c7de2752 100644 (file)
@@ -8,7 +8,6 @@ lib/mini-gmp.h
 m4/libgmp.m4
 
 Depends-on:
-havelib
 
 configure.ac:
 gl_LIBGMP