configure.ac revision 1.1.1.2
1dnl Process this file with autoconf to produce a configure script. 2 3AC_COPYRIGHT([ 4Copyright 1999-2016 Free Software Foundation, Inc. 5Contributed by the AriC and Caramba projects, INRIA. 6 7This file is part of the GNU MPFR Library. 8 9The GNU MPFR Library is free software; you can redistribute it and/or modify 10it under the terms of the GNU Lesser General Public License as published 11by the Free Software Foundation; either version 3 of the License, or (at 12your option) any later version. 13 14The GNU MPFR Library is distributed in the hope that it will be useful, but 15WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17License for more details. 18 19You should have received a copy of the GNU Lesser General Public License 20along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see 21http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 2251 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 23]) 24 25dnl Add check-news when it checks for more than 15 lines 26AC_INIT([MPFR],[3.1.5]) 27 28dnl Older Automake versions than 1.13 may still be supported, but no longer 29dnl tested, and many things have changed in 1.13. Moreover the INSTALL file 30dnl and MPFR manual assume that MPFR has been built using Automake 1.13+ 31dnl (due to parallel tests, introduced by default in Automake 1.13). 32AM_INIT_AUTOMAKE([1.13 no-define dist-bzip2 dist-xz dist-zip]) 33AM_MAINTAINER_MODE(enable) 34 35AC_CONFIG_MACRO_DIR([m4]) 36 37dnl FIXME: The AC_ARG_ENABLE(decimal-float...) part does things too 38dnl early, even when this option is not used. In particular, it must 39dnl be put after AC_PROG_CC; another problem is that the GMP CFLAGS 40dnl and CC check may modify the compiler. 41 42test_CFLAGS=${CFLAGS+set} 43 44dnl Check if user request its CC and CFLAGS 45if test -n "$CFLAGS" || test -n "$CC" ; then 46 user_redefine_cc=yes 47fi 48 49dnl Basic Autoconf macros. At this point, they must not make Autoconf 50dnl choose a compiler because of the CC and CFLAGS setup from gmp.h! 51 52AC_CANONICAL_HOST 53 54AC_PROG_EGREP 55AC_PROG_SED 56 57dnl To use a separate config header. 58dnl There is still some problem with GMP's HAVE_CONFIG 59dnl AC_CONFIG_HEADERS([mpfrconf.h:mpfrconf.in]) 60 61dnl Extra arguments to configure 62unset gmp_lib_path GMP_CFLAGS GMP_CC 63AC_ARG_WITH(gmp_include, 64 [ --with-gmp-include=DIR GMP include directory ], 65 MPFR_PARSE_DIRECTORY(["$withval"],[withval]) 66 CPPFLAGS="$CPPFLAGS -I$withval") 67AC_ARG_WITH(gmp_lib, 68 [ --with-gmp-lib=DIR GMP lib directory ], [ 69 MPFR_PARSE_DIRECTORY(["$withval"],[withval]) 70 LDFLAGS="$LDFLAGS -L$withval" 71 gmp_lib_path="$withval" 72 ]) 73AC_ARG_WITH(gmp, 74 [ --with-gmp=DIR GMP install directory ], [ 75 MPFR_PARSE_DIRECTORY(["$withval"],[withval]) 76 if test -z "$with_gmp_lib" && test -z "$with_gmp_include" ; then 77 CPPFLAGS="$CPPFLAGS -I$withval/include" 78 LDFLAGS="$LDFLAGS -L$withval/lib" 79 gmp_lib_path="$withval/lib" 80 else 81 AC_MSG_FAILURE([Do not use --with-gmp and --with-gmp-include/--with-gmp-lib options simultaneously.]) 82 fi 83 ]) 84 85AC_ARG_WITH(gmp_build, 86 [ --with-gmp-build=DIR GMP build directory (please read INSTALL file)], 87 [ 88 MPFR_PARSE_DIRECTORY(["$withval"],[withval]) 89 if test -z "$gmp_lib_path" && test -z "$with_gmp_include" ; then 90 CPPFLAGS="$CPPFLAGS -I$withval -I$withval/tune" 91 LDFLAGS="$LDFLAGS -L$withval -L$withval/.libs -L$withval/tune" 92 gmp_lib_path="$withval$PATH_SEPARATOR$withval/.libs$PATH_SEPARATOR$withval/tune" 93 if test -r $withval/Makefile ; then 94 GMP_CFLAGS=`$SED -n 's/^CFLAGS = //p' $withval/Makefile` 95 GMP_CC=`$SED -n 's/^CC = //p' $withval/Makefile` 96 GMP_SOURCE=`$SED -n 's/^srcdir = *//p' $withval/Makefile` 97 case "$GMP_SOURCE" in 98 .) GMP_SOURCE="" ;; 99 /*) ;; 100 ?*) GMP_SOURCE="$withval/$GMP_SOURCE" ;; 101 esac 102 if test -d "$GMP_SOURCE" ; then 103 CPPFLAGS="$CPPFLAGS -I$GMP_SOURCE -I$GMP_SOURCE/tune" 104 fi 105 fi 106 use_gmp_build=yes 107 else 108 AC_MSG_FAILURE([Do not use --with-gmp-build and other --with-gmp options simultaneously.]) 109 fi 110 ]) 111 112AC_ARG_WITH(mulhigh_size, 113 [ --with-mulhigh-size=NUM internal threshold table for mulhigh], 114 AC_DEFINE_UNQUOTED([MPFR_MULHIGH_SIZE],$withval, [Mulhigh size])) 115 116AC_ARG_ENABLE(gmp-internals, 117 [ --enable-gmp-internals enable use of GMP undocumented functions [[default=no]]], 118 [ case $enableval in 119 yes) AC_DEFINE([WANT_GMP_INTERNALS],1,[Want GMP internals]) ;; 120 no) ;; 121 *) AC_MSG_ERROR([bad value for --enable-gmp-internals: yes or no]) ;; 122 esac]) 123 124AC_ARG_ENABLE(assert, 125 [ --enable-assert enable ASSERT checking [[default=no]]], 126 [ case $enableval in 127 yes) AC_DEFINE([MPFR_WANT_ASSERT],1,[Want assertion]) ;; 128 no) ;; 129 full) AC_DEFINE([MPFR_WANT_ASSERT],2,[Want assertion]) ;; 130 *) AC_MSG_ERROR([bad value for --enable-assert: yes, no or full]) ;; 131 esac]) 132AC_ARG_ENABLE(logging, 133 [ --enable-logging enable MPFR logging (the system must support it) 134 [[default=no]]], 135 [ case $enableval in 136 yes) AC_DEFINE([MPFR_USE_LOGGING],1,[Log what MPFR does]) ;; 137 no) ;; 138 *) AC_MSG_ERROR([bad value for --enable-logging: yes or no]) ;; 139 esac]) 140AC_ARG_ENABLE(thread-safe, 141 [ --disable-thread-safe explicitly disable TLS support 142 --enable-thread-safe build MPFR as thread safe, i.e. with TLS support 143 (the system must support it) [[default=autodetect]]], 144 [ case $enableval in 145 yes) ;; 146 no) ;; 147 *) AC_MSG_ERROR([bad value for --enable-thread-safe: yes or no]) ;; 148 esac]) 149AC_ARG_ENABLE(warnings, 150 [ --enable-warnings allow MPFR to output warnings to stderr [[default=no]]], 151 [ case $enableval in 152 yes) AC_DEFINE([MPFR_USE_WARNINGS],1,[Allow MPFR to output warnings to stderr]) ;; 153 no) ;; 154 *) AC_MSG_ERROR([bad value for --enable-warnings: yes or no]) ;; 155 esac]) 156 157AC_ARG_ENABLE(tests-timeout, 158 [ --enable-tests-timeout=NUM enable timeout (NUM seconds) for test programs 159 (NUM <= 9999) [[default=no]]; if enabled, env variable 160 $MPFR_TESTS_TIMEOUT overrides NUM (0: no timeout).], 161 [ case $enableval in 162 no) ;; 163 yes) AC_DEFINE([MPFR_TESTS_TIMEOUT], 0, [timeout limit]) ;; 164 [[0-9]]|[[0-9]][[0-9]]|[[0-9]][[0-9]][[0-9]]|[[0-9]][[0-9]][[0-9]][[0-9]]) 165 AC_DEFINE_UNQUOTED([MPFR_TESTS_TIMEOUT], $enableval, [timeout limit]) ;; 166 *) AC_MSG_ERROR([bad value for --enable-tests-timeout]) ;; 167 esac]) 168 169 170dnl 171dnl Setup CC and CFLAGS 172dnl 173 174dnl ******************************************************************** 175dnl Check for CC and CFLAGS in gmp.h 176 177dnl Warning! The following tests must be done before Autoconf selects 178dnl a compiler. This means that some macros such as AC_PROG_CC and 179dnl AM_PROG_AR must be put after the following code. 180 181if test -z "$user_redefine_cc" && test "$cross_compiling" != yes ; then 182 183dnl We need to guess the C preprocessor instead of using AC_PROG_CPP, 184dnl since AC_PROG_CPP implies AC_PROG_CC, which chooses a compiler 185dnl (before we have the chance to get it from gmp.h) and does some 186dnl checking related to this compiler (such as dependency tracking 187dnl options); if the compiler changes due to __GMP_CC in gmp.h, one 188dnl would have incorrect settings. 189dnl FIXME: Move this in aclocal ? 190if test -z "$GMP_CC$GMP_CFLAGS" ; then 191 AC_MSG_CHECKING(for CC and CFLAGS in gmp.h) 192 GMP_CC=__GMP_CC 193 GMP_CFLAGS=__GMP_CFLAGS 194 # /lib/cpp under Solaris doesn't support some environment variables 195 # used by GCC, such as C_INCLUDE_PATH. If the user has set up such 196 # environment variables, he probably wants to use them. So, let us 197 # prefer cpp and gcc to /lib/cpp. 198 for cpp in cpp gcc /lib/cpp cc c99 199 do 200 case $cpp in 201 *cpp*) ;; 202 *) cpp="$cpp -E" ;; 203 esac 204 echo foo > conftest.c 205 if $cpp $CPPFLAGS conftest.c > /dev/null 2> /dev/null ; then 206 # Get CC 207 echo "#include \"gmp.h\"" > conftest.c 208 echo "MPFR_OPTION __GMP_CC" >> conftest.c 209 GMP_CC=`$cpp $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e 's/MPFR_OPTION //g;s/ *" *//g'` 210 # Get CFLAGS 211 echo "#include \"gmp.h\"" > conftest.c 212 echo "MPFR_OPTION __GMP_CFLAGS" >> conftest.c 213 unset rmpedantic 214 [test "$enable_logging" = yes && rmpedantic='s/[ "]-pedantic[ "]/ /g;'] 215 GMP_CFLAGS=`$cpp $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e "$rmpedantic"'s/MPFR_OPTION //g;s/ *" *//g'` 216 break 217 fi 218 done 219 rm -f conftest* 220 if test "x$GMP_CC" = "x__GMP_CC" || test "x$GMP_CFLAGS" = "x__GMP_CFLAGS" ; then 221 AC_MSG_RESULT(no) 222 GMP_CFLAGS= 223 GMP_CC= 224 else 225 AC_MSG_RESULT(yes [CC=$GMP_CC CFLAGS=$GMP_CFLAGS]) 226 fi 227fi 228 229dnl But these variables may be invalid, so we must check them first. 230dnl Note: we do not use AC_RUN_IFELSE, as it implies AC_PROG_CC. 231if test -n "$GMP_CC$GMP_CFLAGS" ; then 232 AC_MSG_CHECKING(for CC=$GMP_CC and CFLAGS=$GMP_CFLAGS) 233 echo "int main (void) { return 0; }" > conftest.c 234 if $GMP_CC $GMP_CFLAGS -o conftest conftest.c 2> /dev/null ; then 235 AC_MSG_RESULT(yes) 236 CFLAGS=$GMP_CFLAGS 237 CC=$GMP_CC 238 else 239 AC_MSG_RESULT(no) 240 fi 241 rm -f conftest* 242fi 243 244fi 245 246dnl ******************************************************************** 247 248AC_PROG_CC 249AC_PROG_CPP 250AC_LANG(C) 251 252dnl Support unusual archivers. 253AM_PROG_AR 254 255dnl For GCC, _Decimal64 was introduced in GCC 4.3 for some targets 256dnl (note that it is not guaranteed to be available because it may 257dnl be disabled in the GCC build). See: 258dnl https://gcc.gnu.org/gcc-4.3/changes.html 259dnl _Decimal64 is not yet defined in GCC for C++: 260dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51364 261dnl _Decimal64 support is broken with GCC 4.6.3 and 4.7.2 on powerpc64 262dnl with the mode32 ABI, e.g. "-m32 -mpowerpc64 -mtune=970 -O3"; this 263dnl is detected by the x != x test below. 264AC_ARG_ENABLE(decimal-float, 265 [ --enable-decimal-float build conversion functions from/to decimal floats 266 [[default=no]]], 267 [ case $enableval in 268 yes) AC_DEFINE([MPFR_WANT_DECIMAL_FLOATS],1, 269 [Build decimal float functions]) 270 AC_MSG_CHECKING(if compiler knows _Decimal64) 271 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[_Decimal64 x;]])], 272 [AC_MSG_RESULT(yes) 273 if test "$use_gmp_build" != yes ; then 274 AC_MSG_ERROR([decimal float support requires --with-gmp-build]) 275 fi 276 AC_MSG_CHECKING(if _GMP_IEEE_FLOATS is defined) 277 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 278#include "gmp.h" 279#include "gmp-impl.h" 280#ifndef _GMP_IEEE_FLOATS 281#error "_GMP_IEEE_FLOATS is not defined" 282#endif]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no) 283 AC_MSG_ERROR([decimal float support requires _GMP_IEEE_FLOATS])]) 284 ], 285 [AC_MSG_RESULT(no) 286AC_MSG_ERROR([Compiler doesn't know _Decimal64 (ISO/IEC TR 24732). 287Please use another compiler or build MPFR without --enable-decimal-float.])] 288 ) 289 AC_MSG_CHECKING(decimal float format) 290 AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 291#include <stdlib.h> 292]], [[ 293volatile _Decimal64 x = 1; 294union { double d; _Decimal64 d64; } y; 295if (x != x) return 3; 296y.d64 = 1234567890123456.0dd; 297return y.d == 0.14894469406741037E-123 ? 0 : 298 y.d == 0.59075095508629822E-68 ? 1 : 2; 299]])], [AC_MSG_RESULT(DPD) 300 AC_DEFINE([DPD_FORMAT],1,[])], 301 [case "$?" in 302 1) AC_MSG_RESULT(BID) ;; 303 2) AC_MSG_FAILURE(neither DPD nor BID) ;; 304 3) AC_MSG_FAILURE([_Decimal64 support is broken. 305Please use another compiler or build MPFR without --enable-decimal-float.]) ;; 306 *) AC_MSG_FAILURE(internal error) ;; 307 esac], 308 [AC_MSG_RESULT(assuming DPD) 309 AC_DEFINE([DPD_FORMAT],1,[])]) 310 ;; 311 no) ;; 312 *) AC_MSG_ERROR([bad value for --enable-decimal-float: yes or no]) ;; 313 esac]) 314 315dnl Check if compiler is ICC, and if such a case, disable GCC 316dnl And add some specific flags. 317dnl Don't add Warnings Flags (Otherwise you'll get more than 20000 warnings). 318dnl Add -long_double flags? Don't use -pc64 ! 319dnl Notes (VL): 320dnl * With icc 10.1 20080212 on itanium, the __ICC macro is not defined, 321dnl even when the -icc option is used (contrary to what is documented 322dnl on the icc man page). 323dnl * When ICC is correctly detected (__ICC macro defined), unsetting 324dnl the GCC variable confuses libtool. See: 325dnl https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=485421 326dnl * If need be, the gcc predefined macros __GNUC_* can be disabled 327dnl thanks to the -no-gcc option. 328AC_MSG_CHECKING(for ICC) 329AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 330#if !defined(__ICC) 331# error "ICC Not Found" 332error 333#endif 334]], [[]])],[ 335 AC_MSG_RESULT(yes) 336 CFLAGS="-fp_port -mp -wd1572 -wd265 -wd186 -wd239 $CFLAGS" 337],[AC_MSG_RESULT(no)]) 338 339dnl If compiler is gcc, then use some specific flags. 340dnl But don't touch user other flags. 341if test "$test_CFLAGS" != set && test -n "$GCC"; then 342 CFLAGS="-Wpointer-arith $CFLAGS" 343 AC_MSG_CHECKING(whether the selected language is C++) 344 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 345#if defined (__cplusplus) 346# error "C++" 347error 348#endif 349 ]], [[]])],[ 350 AC_MSG_RESULT(no) 351 CFLAGS="-Wmissing-prototypes $CFLAGS" 352 ],[ 353 AC_MSG_RESULT(yes) 354 CFLAGS="-Wmissing-declarations -Wno-sign-compare $CFLAGS" 355 ]) 356 CFLAGS="-Wall $CFLAGS" 357fi 358 359AM_PROG_CC_C_O 360 361case $host in 362 *-apple-darwin*) 363dnl This allows to take the first GMP library in the library paths, 364dnl whether it is dynamic or static. This behavior is more sensible, 365dnl in particular because it is the only way to link with a version 366dnl only available in static form when another version is available 367dnl in dynamic, and also for consistency, because the compiler will 368dnl take the first gmp.h found in the include paths (so, we need to 369dnl take a library that corresponds to this header file). This is a 370dnl common problem with darwin. 371 MPFR_LD_SEARCH_PATHS_FIRST ;; 372esac 373 374AC_C_CONST 375AC_C_VOLATILE 376MPFR_CONFIGS 377 378# (Based on GMP 5.1) 379# clock_gettime is in librt on *-*-osf5.1 and on glibc < 2.17, so add -lrt to 380# TUNE_LIBS if needed (e.g. if clock_gettime is not already in the C library). 381# On linux (tested on x86_32, 2.6.26), clock_getres reports ns accuracy, 382# while in a quick test on osf, clock_getres said only 1 millisecond. 383old_LIBS="$LIBS" 384AC_SEARCH_LIBS(clock_gettime, rt, [ 385 AC_DEFINE([HAVE_CLOCK_GETTIME],1,[Define to 1 if you have the `clock_gettime' function])]) 386TUNE_LIBS="$LIBS" 387LIBS="$old_LIBS" 388AC_SUBST(TUNE_LIBS) 389 390dnl 391dnl Setup GMP detection 392dnl 393 394dnl Check GMP Header 395AC_MSG_CHECKING(for gmp.h) 396AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 397#include "gmp.h" 398]])],[AC_MSG_RESULT(yes)],[ 399 AC_MSG_RESULT(no) 400 AC_MSG_ERROR([gmp.h can't be found, or is unusable.]) 401]) 402 403dnl Configs for Windows DLLs. 404dnl libtool requires "-no-undefined" for win32 dll 405dnl 406dnl "-Wl,output-def" is used to get a .def file for use by MS lib to make 407dnl a .lib import library, described in the manual. 408dnl 409dnl Incidentally, libtool does generate an import library libmpfr.dll.a, 410dnl but it's "ar" format and cannot be used by the MS linker. There 411dnl doesn't seem to be any GNU tool for generating or converting to .lib. 412AC_SUBST(MPFR_LDFLAGS) 413AC_SUBST(LIBMPFR_LDFLAGS) 414LT_INIT(win32-dll) 415case $host in 416 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) 417 AC_MSG_CHECKING(for DLL/static GMP) 418 if test "$enable_shared" = yes; then 419 MPFR_LDFLAGS="$MPFR_LDFLAGS -no-undefined" 420 LIBMPFR_LDFLAGS="$LIBMPFR_LDFLAGS -Wl,--output-def,.libs/libmpfr-4.dll.def" 421 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 422#include "gmp.h" 423#if !__GMP_LIBGMP_DLL 424# error "Dead man" 425error 426#endif 427 ]], [[]])],[AC_MSG_RESULT(DLL)],[ 428 AC_MSG_RESULT(static) 429 AC_MSG_ERROR([gmp.h isn't a DLL: use --enable-static --disable-shared]) ]) 430 else 431 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 432#include "gmp.h" 433#if __GMP_LIBGMP_DLL 434# error "Dead man" 435error 436#endif 437 ]], [[]])],[AC_MSG_RESULT(static)],[ 438 AC_MSG_RESULT(DLL) 439 AC_MSG_ERROR([gmp.h is a DLL: use --disable-static --enable-shared]) ]) 440 fi 441 ;; 442esac 443 444 445dnl 446dnl For mpfr-longlong.h - TODO: should be replaced (see acinclude.m4). 447dnl 448 449GMP_C_ATTRIBUTE_MODE 450 451 452dnl 453dnl Setup GMP detection (continued) 454dnl 455 456dnl Check minimal GMP version 457dnl We only guarantee that with a *functional* and recent enough GMP version, 458dnl MPFR will compile; we do not guarantee that GMP will compile. 459dnl In particular fat builds are broken in GMP 4.3.2 and GMP 5.0.0 460dnl (at least on 64-bit Core 2 under Linux), 461dnl see http://gmplib.org/list-archives/gmp-bugs/2011-August/002345.html. 462AC_MSG_CHECKING(for recent GMP) 463AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 464#include "gmp.h" 465#if (__GNU_MP_VERSION*100+__GNU_MP_VERSION_MINOR*10 < 410) 466# error "min GMP version is 4.1.0" 467error 468#endif 469]])],[AC_MSG_RESULT(yes)],[ 470 AC_MSG_RESULT(no) 471 AC_MSG_ERROR([GMP 4.1.0 min required]) 472]) 473 474dnl Check if gmp.h is usable at link time; this may detect errors such as 475dnl with GMP 4.1, which uses "extern __inline__" unconditionally with all 476dnl GCC versions, which breaks by default with GCC 5. 477dnl Note: No linking is done against the GMP library at this time, as we 478dnl do not use any GMP symbol. The goal of this test is to avoid obscure 479dnl errors with the following gmp.h tests. 480AC_MSG_CHECKING(usable gmp.h at link time) 481AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 482#include "gmp.h" 483]],[[]])],[AC_MSG_RESULT(yes)],[ 484 AC_MSG_RESULT(no) 485 AC_MSG_ERROR([There is an incompatibility between gmp.h and the compiler. 486See 'config.log' for details. 487Such an incompatibility is known between GMP 4.1, which uses 488"extern __inline__" with all GCC versions, and GCC 5.]) 489]) 490 491dnl Check if we can use internal header files of GMP (only --with-gmp-build) 492if test "$use_gmp_build" = yes ; then 493 AC_MSG_CHECKING(for gmp internal files) 494 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 495 #include "gmp.h" 496 #include "gmp-impl.h" 497 #include "longlong.h" 498 ]])],[ 499 AC_MSG_RESULT(yes) 500 AC_DEFINE([MPFR_HAVE_GMP_IMPL],1,[Use GMP Internal Files]) 501 ],[ 502 AC_MSG_ERROR([header files gmp-impl.h and longlong.h not found]) 503 ]) 504fi 505 506dnl Check for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency. 507dnl Problems may occur if gmp.h was generated with some ABI 508dnl and is used with another ABI (or if nails are used). 509dnl This test doesn't need to link with libgmp (at least it shouldn't). 510AC_MSG_CHECKING(for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency) 511AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 512#include <stdio.h> 513#include <limits.h> 514#include "gmp.h" 515]], [[ 516 if (GMP_NUMB_BITS == sizeof(mp_limb_t) * CHAR_BIT) 517 return 0; 518 fprintf (stderr, "GMP_NUMB_BITS = %ld\n", (long) GMP_NUMB_BITS); 519 fprintf (stderr, "sizeof(mp_limb_t) = %ld\n", (long) sizeof(mp_limb_t)); 520 fprintf (stderr, "sizeof(mp_limb_t) * CHAR_BIT = %ld != GMP_NUMB_BITS\n", 521 (long) (sizeof(mp_limb_t) * CHAR_BIT)); 522 return 1; 523]])], [AC_MSG_RESULT(yes)], [ 524 AC_MSG_RESULT(no) 525 AC_MSG_ERROR([GMP_NUMB_BITS and sizeof(mp_limb_t) are not consistent. 526You probably need to change some of the GMP or MPFR compile options. 527See 'config.log' for details (search for GMP_NUMB_BITS).])], 528 [AC_MSG_RESULT([cannot test])]) 529 530 531dnl Check if we can link with GMP 532AC_CHECK_LIB(gmp, __gmpz_init, [LIBS="-lgmp $LIBS"], 533 [AC_MSG_ERROR(libgmp not found or uses a different ABI (including static vs shared). 534Please read the INSTALL file -- see "In case of problem".)]) 535 536dnl Check for corresponding 'gmp.h' and libgmp.a 537AC_MSG_CHECKING(if gmp.h version and libgmp version are the same) 538dnl We do not set LD_LIBRARY_PATH, as it is not possible to set it just 539dnl before the test program is run, and we do not want to affect other 540dnl programs (such as the compiler), because the behavior could be 541dnl incorrect and even have security implications. 542dnl WARNING! LD_RUN_PATH is not taken into account by the GNU gold ld, 543dnl e.g. from binutils-gold 2.22-5 under Debian; see 544dnl https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660813 545saved_LD_RUN_PATH="$LD_RUN_PATH" 546LD_RUN_PATH="${LD_RUN_PATH:+$LD_RUN_PATH$PATH_SEPARATOR}$gmp_lib_path" 547export LD_RUN_PATH 548AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 549#include <stdio.h> 550#include <string.h> 551#include "gmp.h" 552]], [[ 553 char buffer[100]; 554 sprintf (buffer, "%d.%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, 555 __GNU_MP_VERSION_PATCHLEVEL); 556 printf ("(%s/%s) ", buffer, gmp_version); 557 if (strcmp (buffer, gmp_version) == 0) 558 return 0; 559 if (__GNU_MP_VERSION_PATCHLEVEL != 0) 560 return 1; 561 sprintf (buffer, "%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR); 562 return (strcmp (buffer, gmp_version) != 0) ? 1 : 0; 563]])], 564 [AC_MSG_RESULT(yes) 565 MPFR_CHECK_GMP 566 MPFR_CHECK_DBL2INT_BUG 567 MPFR_CHECK_PRINTF_SPEC], 568 [AC_MSG_RESULT(no) 569 AC_MSG_WARN([==========================================================]) 570 AC_MSG_WARN(['gmp.h' and 'libgmp' seem to have different versions or]) 571 AC_MSG_WARN([we cannot run a program linked with GMP (if you cannot]) 572 AC_MSG_WARN([see the version numbers above). A cause may be different]) 573 AC_MSG_WARN([GMP versions with different ABI's or the use of --with-gmp]) 574 AC_MSG_WARN([or --with-gmp-include with a system include directory]) 575 AC_MSG_WARN([(such as /usr/include or /usr/local/include).]) 576 AC_MSG_WARN([However since we can't use 'libtool' inside the configure,]) 577 AC_MSG_WARN([we can't be sure. See 'config.log' for details.]) 578 AC_MSG_WARN([CC="$CC"]) 579 AC_MSG_WARN([CFLAGS="$CFLAGS"]) 580 AC_MSG_WARN([CPPFLAGS="$CPPFLAGS"]) 581 AC_MSG_WARN([LDFLAGS="$LDFLAGS"]) 582 AC_MSG_WARN([LIBS="$LIBS"]) 583 AC_MSG_WARN([Temporary LD_RUN_PATH was "$LD_RUN_PATH".]) 584 AC_MSG_WARN([==========================================================]) 585 ],AC_MSG_RESULT([cannot test]) 586) 587LD_RUN_PATH="$saved_LD_RUN_PATH" 588 589dnl Warning! __gmpn_rootrem is an internal GMP symbol; thus its behavior 590dnl may change or this symbol may be removed in the future (without being 591dnl handled by the library versioning system, which is even worse, as this 592dnl can mean undetected incompatibilities in case of GMP library upgrade, 593dnl without rebuilding MPFR). So, this symbol must not be used, unless 594dnl WANT_GMP_INTERNALS is defined. Only the GMP public API should be used 595dnl by default, in particular by binary distributions. Moreover the check 596dnl below may yield an incorrect result as libtool isn't used in configure 597dnl (see above). 598dnl Same for __gmpn_sbpi1_divappr_q. 599AC_CHECK_FUNCS([__gmpn_rootrem __gmpn_sbpi1_divappr_q]) 600 601dnl Remove also many MACROS (AC_DEFINE) which are unused by MPFR 602dnl and polluate (and slow down because libtool has to parse them) the build. 603if test -f confdefs.h; then 604 $SED '/#define PACKAGE_/d' <confdefs.h >confdefs.tmp 605 $SED '/#define HAVE_STRING/d' <confdefs.tmp >confdefs.h 606 $SED '/#define HAVE_ALLOCA /d' <confdefs.h >confdefs.tmp 607 $SED '/#define HAVE_DLFCN_H/d' <confdefs.tmp >confdefs.h 608 $SED '/#define HAVE_MEM/d' <confdefs.h >confdefs.tmp 609 $SED '/#define STDC_HEADERS/d' <confdefs.tmp >confdefs.h 610 $SED '/#define HAVE_STRTOL/d' <confdefs.h >confdefs.tmp 611 $SED '/#define HAVE_STDLIB_H/d' <confdefs.tmp >confdefs.h 612 $SED '/#define HAVE_UNISTD_H/d' <confdefs.h >confdefs.tmp 613 $SED '/#define HAVE_STDC_HEADERS/d' <confdefs.tmp >confdefs.h 614 $SED '/#define HAVE_LONG_DOUBLE/d' <confdefs.h >confdefs.tmp 615 $SED '/#define HAVE_SYS_STAT_H/d' <confdefs.tmp >confdefs.h 616 $SED '/#define HAVE_SYS_TYPES_H/d' <confdefs.h >confdefs.tmp 617 $SED '/#define PROTOTYPES/d' <confdefs.tmp >confdefs.h 618 $SED '/#define __PROTOTYPES/d' <confdefs.h >confdefs.tmp 619 620 mv confdefs.tmp confdefs.h 621fi 622 623if $EGREP -q -e '-dev$' $srcdir/VERSION; then 624 AC_SUBST([DATAFILES])dnl 625 DATAFILES=`echo \`$SED -n \ 626 's/^ *data_check *("\(data\/[[^"]]*\)".*/tests\/\1/p' \ 627 $srcdir/tests/*.c\`` 628fi 629 630dnl Output 631AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile tests/Makefile tune/Makefile src/mparam.h:src/mparam_h.in]) 632AC_OUTPUT 633 634dnl NEWS README AUTHORS Changelog 635