From c8b6006d82196f9063581e988ea12d6c99c95536 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 9 Jul 2020 16:35:48 -0700 Subject: Use Gnulib libgmp module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of doing GMP by hand, use the Gnulib libgmp module. * .gitignore: Add lib/gmp.h. * admin/merge-gnulib (GNULIB_MODULES): Add libgmp. * configure.ac (GMP_LIB, GMP_OBJ): Remove. Gnulib uses the name LIB_GMP, so all uses changed. All uses of GMP_OBJ removed. (HAVE_GMP): Set this from Gnulib’s variables. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/mini-gmp-gnulib.c, lib/mini-gmp.c, lib/mini-gmp.h, m4/libgmp.m4: New files, copied from Gnulib. * src/bignum.h, test/data/emacs-module/mod-test.c: Include gmp.h unconditionally. * src/mini-gmp-emacs.c, src/mini-gmp.c, src/mini-gmp.h: Remove. This moves these files from src to lib, and updates them to the current GMP version. * test/Makefile.in (GMP_H): New macro. ($(test_module)): Use it to decide whether to compile mini-gmp-gnulib.c too. --- m4/gnulib-comp.m4 | 9 +++++++++ m4/libgmp.m4 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 m4/libgmp.m4 (limited to 'm4') diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 3a0fae11c44..f577a6fa741 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -118,6 +118,7 @@ AC_DEFUN([gl_EARLY], AC_REQUIRE([AC_SYS_LARGEFILE]) # Code from module lchmod: # Code from module libc-config: + # Code from module libgmp: # Code from module limits-h: # Code from module localtime-buffer: # Code from module lstat: @@ -345,6 +346,10 @@ AC_DEFUN([gl_INIT], gl_INTTYPES_INCOMPLETE AC_REQUIRE([gl_LARGEFILE]) gl___INLINE + gl_LIBGMP + if test -n "$GMP_H"; then + AC_LIBOBJ([mini-gmp-gnulib]) + fi gl_LIMITS_H gl_FUNC_LSTAT if test $REPLACE_LSTAT = 1; then @@ -1035,6 +1040,9 @@ AC_DEFUN([gl_FILE_LIST], [ lib/memmem.c lib/mempcpy.c lib/memrchr.c + lib/mini-gmp-gnulib.c + lib/mini-gmp.c + lib/mini-gmp.h lib/minmax.h lib/mkostemp.c lib/mktime-internal.h @@ -1166,6 +1174,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/inttypes.m4 m4/largefile.m4 m4/lchmod.m4 + m4/libgmp.m4 m4/limits-h.m4 m4/localtime-buffer.m4 m4/lstat.m4 diff --git a/m4/libgmp.m4 b/m4/libgmp.m4 new file mode 100644 index 00000000000..b569bb73462 --- /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"]) +]) -- cgit v1.2.1