3 # Configure the GMP library or a replacement.
4 dnl Copyright 2020-2024 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
10 dnl Search for an installed libgmp.
11 dnl If found, set and AC_SUBST HAVE_LIBGMP=yes and the LIBGMP and LTLIBGMP
12 dnl variables, and augment the CPPFLAGS variable, and #define HAVE_LIBGMP to 1.
13 dnl Otherwise, set and AC_SUBST HAVE_LIBGMP=no and LIBGMP and LTLIBGMP to
19 [AS_HELP_STRING([[--without-libgmp]],
20 [do not use the GNU Multiple Precision (GMP) library;
21 this is the default on systems lacking libgmp.])])
25 AS_IF([test "$with_libgmp" != no],
26 [AC_CHECK_HEADERS([gmp.h gmp/gmp.h], [break])
27 dnl Prefer AC_LIB_HAVE_LINKFLAGS if the havelib module is also in use.
28 AS_IF([test "$ac_cv_header_gmp_h" = yes ||
29 test "$ac_cv_header_gmp_gmp_h" = yes],
30 [m4_ifdef([gl_HAVE_MODULE_HAVELIB],
31 [AC_LIB_HAVE_LINKFLAGS([gmp], [],
37 [static const mp_limb_t x[2] = { 0x73, 0x55 };
39 mpz_roinit_n (tmp, x, 2);
43 AC_SEARCH_LIBS([__gmpz_roinit_n], [gmp])
45 case $ac_cv_search___gmpz_roinit_n in
50 LIBGMP=$ac_cv_search___gmpz_roinit_n
53 AC_SUBST([HAVE_LIBGMP])
55 AC_SUBST([LTLIBGMP])])])
56 if test "$with_libgmp,$HAVE_LIBGMP" = yes,no; then
58 [GMP not found, although --with-libgmp was specified.m4_ifdef(
59 [AC_LIB_HAVE_LINKFLAGS],
60 [ Try specifying --with-libgmp-prefix=DIR.])])
62 if test $HAVE_LIBGMP = yes && test "$ac_cv_header_gmp_h" = yes; then
63 GL_GENERATE_GMP_H=false
65 GL_GENERATE_GMP_H=true
67 gl_CONDITIONAL([GL_GENERATE_MINI_GMP_H],
68 [test $HAVE_LIBGMP != yes])
69 gl_CONDITIONAL([GL_GENERATE_GMP_GMP_H],
70 [test $HAVE_LIBGMP = yes && test "$ac_cv_header_gmp_h" != yes])