summaryrefslogtreecommitdiff
path: root/m4/libgmp.m4
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-07-06 18:54:11 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-07-06 19:03:03 -0700
commit3b0ef0b854a43aea12364fafd4bb053d59c116f2 (patch)
treec2d66ee7ed712b946a7db881aa15a8eb1f1eb4db /m4/libgmp.m4
parent4cfff6810c595e60cf4411dc9bac83c0328e8812 (diff)
downloadgnulib-3b0ef0b854a43aea12364fafd4bb053d59c116f2.tar.gz
libgmp: new module
The idea is to let programs simply include <gmp.h>, and so long as they live within the mini-gmp subset they need not worry about whether the GMP libraries are installed. * MODULES.html.sh: Mention it. * config/srclist.txt: Mention files copied from GMP source. * config/srclistvars.sh (GMP): New var. * lib/mini-gmp-gnulib.c, m4/libgmp.m4, modules/libgmp: * modules/libgmp-tests, tests/test-libgmp.c: New files. * lib/mini-gmp.c, lib/mini-gmp.h: New files, copied from GMP.
Diffstat (limited to 'm4/libgmp.m4')
-rw-r--r--m4/libgmp.m444
1 files changed, 44 insertions, 0 deletions
diff --git a/m4/libgmp.m4 b/m4/libgmp.m4
new file mode 100644
index 0000000000..b569bb7346
--- /dev/null
+++ b/m4/libgmp.m4
@@ -0,0 +1,44 @@
+# Configure the GMP library or a replacement.
+
+dnl Copyright 2020 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_LIBGMP],
+[
+ AC_ARG_WITH([libgmp],
+ [AS_HELP_STRING([--without-libgmp],
+ [do not use the GNU Multiple Precision (GMP) library;
+ this is the default on systems lacking libgmp.])])
+
+ AC_CHECK_HEADERS_ONCE([gmp.h])
+ GMP_H=gmp.h
+ LIB_GMP=
+
+ case $with_libgmp in
+ no) ;;
+ yes) GMP_H= LIB_GMP=-lgmp;;
+ *) if test "$ac_cv_header_gmp_h" = yes; then
+ 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')
+ GMP_H=;;
+ -*)
+ GMP_H= LIB_GMP=$ac_cv_search___gmpz_roinit_n;;
+ esac
+ fi;;
+ esac
+
+ if test -z "$GMP_H"; then
+ AC_DEFINE([HAVE_GMP], 1,
+ [Define to 1 if you have the GMP library instead of just the
+ mini-gmp replacement.])
+ fi
+
+ AC_SUBST([LIB_GMP])
+ AC_SUBST([GMP_H])
+ AM_CONDITIONAL([GL_GENERATE_GMP_H], [test -n "$GMP_H"])
+])