summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac35
-rw-r--r--src/Makefile.am9
-rw-r--r--src/mpfr-impl.h4
-rw-r--r--src/mpfr.h4
4 files changed, 49 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index ffea2614d..8c6c2b4a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,9 @@ dnl Older Automake versions than 1.13 may still be supported, but no longer
dnl tested, and many things have changed in 1.13. Moreover the INSTALL file
dnl and MPFR manual assume that MPFR has been built using Automake 1.13+
dnl (due to parallel tests, introduced by default in Automake 1.13).
-AM_INIT_AUTOMAKE([1.13 no-define dist-bzip2 dist-xz dist-zip])
+dnl The subdir-objects option is needed due to configuration related to
+dnl mini-gmp, which has sources in an external directory.
+AM_INIT_AUTOMAKE([1.13 no-define dist-bzip2 dist-xz dist-zip subdir-objects])
AM_MAINTAINER_MODE(enable)
AC_CONFIG_MACRO_DIR([m4])
@@ -121,6 +123,25 @@ AC_ARG_WITH(gmp_build,
fi
])
+AC_ARG_WITH(mini_gmp,
+ [ --with-mini-gmp=DIR use mini-gmp (sources in DIR) instead of GMP],
+ [
+ MPFR_PARSE_DIRECTORY(["$withval"],[withval])
+ if test -z "$gmp_lib_path" && test -z "$with_gmp_include" && \
+ test -z "$use_gmp_build"; then
+ if test -f "$withval/mini-gmp.c" && test -f "$withval/mini-gmp.h"; then
+ AC_DEFINE([MPFR_USE_MINI_GMP],1,[Use mini-gmp])
+ CPPFLAGS="$CPPFLAGS -I$withval"
+ mini_gmp_path="$withval"
+ AC_SUBST(mini_gmp_path)
+ else
+ AC_MSG_FAILURE([mini-gmp.{c,h} not found in $withval])
+ fi
+ else
+ AC_MSG_FAILURE([Do not use --with-mini-gmp and other --with-gmp options simultaneously.])
+ fi
+ ])
+
AC_ARG_WITH(mulhigh_size,
[ --with-mulhigh-size=NUM internal threshold table for mulhigh],
AC_DEFINE_UNQUOTED([MPFR_MULHIGH_SIZE],$withval, [Mulhigh size]))
@@ -204,6 +225,9 @@ AC_ARG_ENABLE(tune-for-coverage,
*) AC_MSG_ERROR([bad value for --enable-tune-for-coverage]) ;;
esac])
+dnl Makefile.am files can use "if MINI_GMP" / ... / "endif".
+AM_CONDITIONAL([MINI_GMP], [test -n "$mini_gmp_path"])
+
dnl
dnl Setup CC and CFLAGS
@@ -218,7 +242,7 @@ dnl AM_PROG_AR must be put after the following code.
dnl We do not do this check if mini-gmp is used. Note that the status of
dnl --enable-mini-gmp is already available even though this option will
-dnl be handled later (at this time, --with-mini-gmp is not handled yet).
+dnl be handled later.
if test -z "$user_redefine_cc" && \
test "$cross_compiling" != yes && \
@@ -374,7 +398,7 @@ dnl it were a real GMP) and that the corresponding gmp.h is the one of
dnl mini-gmp. Thus the --enable-mini-gmp is misused, because the fact
dnl that mini-gmp is enabled or not is what the gmp.h file contains.
dnl Said otherwise, this should have just been an autodetection.
-dnl Note: A future --with-mini-gmp option may make this one obsolete.
+dnl Note: The --with-mini-gmp option may make this one obsolete.
AC_ARG_ENABLE(mini-gmp,
[ --enable-mini-gmp build MPFR with mini-gmp (experimental) [[default=no]]],
[ case $enableval in
@@ -619,6 +643,8 @@ dnl
dnl Setup GMP detection (continued)
dnl
+if test -z "$mini_gmp_path" ; then
+
dnl Check minimal GMP version
dnl We only guarantee that with a *functional* and recent enough GMP version,
dnl MPFR will compile; we do not guarantee that GMP will compile.
@@ -777,6 +803,9 @@ AC_CHECK_FUNCS([__gmpn_rsblsh1_n])
MPFR_CHECK_MP_LIMB_T_VS_LONG
MPFR_CHECK_MP_LIMB_T_VS_INTMAX
+dnl End of the GMP checks (no mini-gmp)
+fi
+
dnl The getrusage function is needed for MPFR bench (cf tools/bench)
AC_CHECK_FUNCS([getrusage])
diff --git a/src/Makefile.am b/src/Makefile.am
index 496cc53ad..886a70d2e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -91,6 +91,15 @@ libmpfr_la_LDFLAGS = $(MPFR_LDFLAGS) $(LIBMPFR_LDFLAGS) -version-info 6:0:0
$(srcdir)/get_patches.c: $(top_srcdir)/PATCHES $(top_srcdir)/tools/get_patches.sh
(cd $(top_srcdir) && ./tools/get_patches.sh) > $@ || rm -f $@
+if MINI_GMP
+# FIXME: The noinst_ below may be wrong. The idea was to avoid a libminigmp
+# installation in case of static build only, but this is probably incorrect
+# in case of an installation of a dynamic build. To be decided later...
+noinst_LTLIBRARIES = libminigmp.la
+libminigmp_la_SOURCES = $(mini_gmp_path)/mini-gmp.h $(mini_gmp_path)/mini-gmp.c
+libmpfr_la_LIBADD += libminigmp.la
+endif
+
# For check-gmp-symbols
GMPC = $(top_builddir)/src/gmp.c
GMPI = $(top_builddir)/src/gmp.i
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h
index bd3ab22a6..5d337297e 100644
--- a/src/mpfr-impl.h
+++ b/src/mpfr-impl.h
@@ -88,7 +88,11 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#endif
#include "mpfr-thread.h"
+#ifndef MPFR_USE_MINI_GMP
#include "gmp.h"
+#else
+#include "mini-gmp.h"
+#endif
/* With the current code, MPFR_LONG_WITHIN_LIMB must be defined if an
unsigned long fits in a limb. Since one cannot rely on the configure
diff --git a/src/mpfr.h b/src/mpfr.h
index 95762297d..f960b5763 100644
--- a/src/mpfr.h
+++ b/src/mpfr.h
@@ -49,7 +49,11 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#define MPFR_VERSION \
MPFR_VERSION_NUM(MPFR_VERSION_MAJOR,MPFR_VERSION_MINOR,MPFR_VERSION_PATCHLEVEL)
+#ifndef MPFR_USE_MINI_GMP
#include <gmp.h>
+#else
+#include <mini-gmp.h>
+#endif
/* Avoid some problems with macro expansion if the user defines macros
with the same name as keywords. By convention, identifiers and macro