don't presume availability of gmp.pc upstream
authorMichael Gran <spk121@yahoo.com>
Wed, 3 Mar 2021 18:54:04 +0000 (10:54 -0800)
committerMichael Gran <spk121@yahoo.com>
Wed, 3 Mar 2021 22:06:29 +0000 (14:06 -0800)
This suggests moving the conditional that determines if mini-gmp is used
into scmconfig.h.

* configure.ac: replace PKG_CHECK_MODULES for gmp with AC_LIB_HAVE_LINKFLAGS
    Remove ENABLE_MINI_GMP define.  Also don't run mpz_inits test for
    --enable-mini-gmp.
* libguile/gen-scmconfig.c (main) [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_I_GSC_ENABLE_MINI_GMP
* libguile/bytevectors.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_ENABLE_MINI_GMP
* libguile/init.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_ENABLE_MINI_GMP
* libguile/numbers.c: include scm.h
    [SCM_ENABLE_MINI_GMP]: provide mpz_inits and mpz_clears
    [ENABLE_MINI_GMP]: prefer SCM_ENABLE_MINI_GMP to ENABLE_MINI_GMP
* libguile/numbers.h: include scm.h
* libguile/random.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_ENABLE_MINI_GMP
* libguile/socket.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_ENABLE_MINI_GMP

configure.ac
libguile/bytevectors.c
libguile/gen-scmconfig.c
libguile/init.c
libguile/numbers.c
libguile/numbers.h
libguile/random.c
libguile/socket.c

index 559f0ed50f28d8823d8bf88d246d014d1df1ea05..a3cdaff784daf1ee6ac1bb2d68c8f3fa9ea1d8e7 100644 (file)
@@ -647,33 +647,26 @@ AC_CACHE_SAVE
 
 dnl GMP tests
 
-PKG_CHECK_MODULES([GMP],[gmp],
-  [],
-  [$enable_mini_gmp=yes])
-
 SCM_I_GSC_ENABLE_MINI_GMP=0
 AC_ARG_ENABLE(mini-gmp,
   [AS_HELP_STRING([--enable-mini-gmp],
                   [use mini-gmp instead of the full GMP library])])
 
-if test "$enable_mini_gmp" = yes || test "$enable_mini_gmp" = y; then
+if test "x$enable_mini_gmp" = xyes || test "x$enable_mini_gmp" = xy; then
   SCM_I_GSC_ENABLE_MINI_GMP=1
-  AC_DEFINE([ENABLE_MINI_GMP], 1,
-      [Define this if you want to use mini-gmp.])
 else
-  LIBS="$GMP_LIBS $LIBS"
-  CFLAGS="$GMP_CFLAGS $CFLAGS"
+  AC_LIB_HAVE_LINKFLAGS([gmp],[],[#include <gmp.h>], [mpz_import (0,0,0,0,0,0,0);])
+  if test "x$HAVE_LIBGMP" != "xyes"; then
+    AC_MSG_ERROR([GNU MP 4.1 or greater not found])
+  fi
+  if test "x$LIBGMP_PREFIX" != "x"; then
+    CPPFLAGS="-I$LIBGMP_PREFIX $CPPFLAGS"
+  fi
+  AC_CHECK_DECLS([mpz_inits], [], [], [[#include <gmp.h>]])
 fi
 AC_SUBST([SCM_I_GSC_ENABLE_MINI_GMP])
 AM_CONDITIONAL([USE_MINI_GMP], [test "x$enable_mini_gmp" = "xyes"])
 
-AC_CHECK_DECLS([mpz_inits], [], [],
-  [[#if ENABLE_MINI_GMP
-    #include "libguile/mini-gmp.h"
-    #else
-    #include <gmp.h>
-    #endif]])
-
 dnl GNU libunistring is checked for by Gnulib's `libunistring' module.
 if test "x$LTLIBUNISTRING" = "x"; then
   AC_MSG_ERROR([GNU libunistring is required, please install it.])
index 2671eeeeaa4a4ed821c30e48c28a7f83dd8e1d9c..2d6cbdb3e451861f5b0acb060886a5417c1f3fe4 100644 (file)
@@ -35,7 +35,9 @@
 #include <alloca.h>
 #include <assert.h>
 
-#if ENABLE_MINI_GMP
+#include "scm.h"
+
+#if SCM_ENABLE_MINI_GMP
 #include "mini-gmp.h"
 #else
 #include <gmp.h>
index 667789e3bfe3d69fd845385739e218d2c8de7b1e..44b401fbc25ee3540b83b287385cf539efdbd43c 100644 (file)
@@ -379,7 +379,7 @@ main (int argc, char *argv[])
 
   pf ("\n");
   pf ("/* Define to 1 to use mini GMP.  */\n");
-#ifdef ENABLE_MINI_GMP
+#if SCM_I_GSC_ENABLE_MINI_GMP == 1
   pf ("#define SCM_ENABLE_MINI_GMP 1\n");
 #else
   pf ("#undef SCM_ENABLE_MINI_GMP\n");
index 68077d1d54fc87efa525ce6c7e366e1abd239b57..beffc2c7a9ff3addd60e098b17f96d99883a641f 100644 (file)
@@ -31,7 +31,9 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#if ENABLE_MINI_GMP
+#include "scm.h"
+
+#if SCM_ENABLE_MINI_GMP
 #include "mini-gmp.h"
 #else
 #include <gmp.h>
index 670c9ec694dcb11183d55b82a967bb8a75eac97a..107a05a9b26a8a89bbd9ec15dc1d5cfaa800014f 100644 (file)
@@ -110,9 +110,10 @@ verify (SCM_MOST_POSITIVE_FIXNUM <= (mp_limb_t) -1);
   (SCM_I_FIXNUM_BIT-1 <= DBL_MANT_DIG                                   \
    || ((n) ^ ((n) >> (SCM_I_FIXNUM_BIT-1))) < (1L << DBL_MANT_DIG))
 
-#if ! HAVE_DECL_MPZ_INITS
+#if (! HAVE_DECL_MPZ_INITS) || SCM_ENABLE_MINI_GMP
 
-/* GMP < 5.0.0 lacks `mpz_inits' and `mpz_clears'.  Provide them.  */
+/* GMP < 5.0.0 and mini-gmp lack `mpz_inits' and `mpz_clears'.  Provide
+   them.  */
 
 #define VARARG_MPZ_ITERATOR(func)              \
   static void                                  \
@@ -399,7 +400,7 @@ scm_i_big2dbl_2exp (SCM b, long *expon_p)
   {
     long expon;
     double signif;
-#if ENABLE_MINI_GMP
+#if SCM_ENABLE_MINI_GMP
     int iexpon;
     signif = mpz_get_d (SCM_I_BIG_MPZ (b));
     signif = frexp (signif, &iexpon);
index 58010cdf55b03b3fcafa7819a1e51153eada92fc..7fe807111888898853792890a061c470b25f4855 100644 (file)
 
 \f
 
-#include "libguile/scmconfig.h"
-#include "libguile/error.h"
-#include "libguile/gc.h"
-#include "libguile/print.h"
+#include "libguile/scm.h"
 #if SCM_ENABLE_MINI_GMP
 #include "libguile/mini-gmp.h"
 #else
 #include <gmp.h>
 #endif
 
+#include "libguile/error.h"
+#include "libguile/gc.h"
+#include "libguile/print.h"
+
 \f
 
 /* Immediate Numbers, also known as fixnums
index b955c2c4560eb9ae0365f584a59a73c96cf88773..63da7f5d6b022d01fea8941850c775cb5822d1b3 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "scm.h"
+#if SCM_ENABLE_MINI_GMP
+#include "mini-gmp.h"
+#else
+#include <gmp.h>
+#endif
+
 #include "arrays.h"
 #include "feature.h"
 #include "generalized-arrays.h"
 #include "generalized-vectors.h"
 #include "gsubr.h"
 #include "list.h"
-#if ENABLE_MINI_GMP
-#include "mini-gmp.h"
-#else
-#include <gmp.h>
-#endif
 #include "modules.h"
 #include "numbers.h"
 #include "numbers.h"
index 1bd56a0c72f909bc0618815e3fedf628362497d3..f463ec9016af1ea9828258338c092624a5cf4fc1 100644 (file)
@@ -44,7 +44,8 @@
 #include <netdb.h>
 #include <arpa/inet.h>
 
-#if ENABLE_MINI_GMP
+#include "scm.h"
+#if SCM_ENABLE_MINI_GMP
 #include "mini-gmp.h"
 #else
 #include <gmp.h>