1dnl MPFR specific autoconf macros 2 3dnl Copyright 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. 4dnl Contributed by the AriC and Caramel projects, INRIA. 5dnl 6dnl This file is part of the GNU MPFR Library. 7dnl 8dnl The GNU MPFR Library is free software; you can redistribute it and/or modify 9dnl it under the terms of the GNU Lesser General Public License as published 10dnl by the Free Software Foundation; either version 3 of the License, or (at 11dnl your option) any later version. 12dnl 13dnl The GNU MPFR Library is distributed in the hope that it will be useful, but 14dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16dnl License for more details. 17dnl 18dnl You should have received a copy of the GNU Lesser General Public License 19dnl along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see 20dnl http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 21dnl 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 22 23dnl autoconf 2.60 is necessary because of the use of AC_PROG_SED. 24dnl The following line allows the autoconf wrapper (when installed) 25dnl to work as expected. 26dnl If you change the required version, please update README.dev too! 27AC_PREREQ(2.60) 28 29dnl ------------------------------------------------------------ 30dnl You must put in MPFR_CONFIGS everything which configure MPFR 31dnl except: 32dnl -everything dealing with CC and CFLAGS in particular the ABI 33dnl but the IEEE-754 specific flags must be set here. 34dnl -GMP's linkage. 35dnl -Libtool stuff. 36dnl -Handling of special arguments of MPFR's configure. 37AC_DEFUN([MPFR_CONFIGS], 38[ 39AC_REQUIRE([AC_OBJEXT]) 40AC_REQUIRE([MPFR_CHECK_LIBM]) 41AC_REQUIRE([AC_HEADER_TIME]) 42AC_REQUIRE([AC_CANONICAL_HOST]) 43 44AC_CHECK_HEADER([limits.h],, AC_MSG_ERROR([limits.h not found])) 45AC_CHECK_HEADER([float.h],, AC_MSG_ERROR([float.h not found])) 46AC_CHECK_HEADER([string.h],, AC_MSG_ERROR([string.h not found])) 47 48dnl Check for locales 49AC_CHECK_HEADERS([locale.h]) 50 51dnl Check for wide characters (wchar_t and wint_t) 52AC_CHECK_HEADERS([wchar.h]) 53 54dnl Check for stdargs 55AC_CHECK_HEADER([stdarg.h],[AC_DEFINE([HAVE_STDARG],1,[Define if stdarg])], 56 [AC_CHECK_HEADER([varargs.h],, 57 AC_MSG_ERROR([stdarg.h or varargs.h not found]))]) 58 59dnl sys/fpu.h - MIPS specific 60AC_CHECK_HEADERS([sys/time.h sys/fpu.h]) 61 62dnl Check how to get `alloca' 63AC_FUNC_ALLOCA 64 65dnl SIZE_MAX macro 66gl_SIZE_MAX 67 68dnl va_copy macro 69AC_MSG_CHECKING([how to copy va_list]) 70AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 71#include <stdarg.h> 72]], [[ 73 va_list ap1, ap2; 74 va_copy(ap1, ap2); 75]])], [ 76 AC_MSG_RESULT([va_copy]) 77 AC_DEFINE(HAVE_VA_COPY) 78], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 79#include <stdarg.h> 80]], [[ 81 va_list ap1, ap2; 82 __va_copy(ap1, ap2); 83]])], [AC_DEFINE([HAVE___VA_COPY]) AC_MSG_RESULT([__va_copy])], 84 [AC_MSG_RESULT([memcpy])])]) 85 86dnl FIXME: The functions memmove, memset and strtol are really needed by 87dnl MPFR, but if they are implemented as macros, this is also OK (in our 88dnl case). So, we do not return an error, but their tests are currently 89dnl useless. 90dnl gettimeofday is not defined for MinGW 91AC_CHECK_FUNCS([memmove memset setlocale strtol gettimeofday]) 92 93dnl Check for IEEE-754 switches on Alpha 94case $host in 95alpha*-*-*) 96 saved_CFLAGS="$CFLAGS" 97 AC_CACHE_CHECK([for IEEE-754 switches], mpfr_cv_ieee_switches, [ 98 if test -n "$GCC"; then 99 mpfr_cv_ieee_switches="-mfp-rounding-mode=d -mieee-with-inexact" 100 else 101 mpfr_cv_ieee_switches="-fprm d -ieee_with_inexact" 102 fi 103 CFLAGS="$CFLAGS $mpfr_cv_ieee_switches" 104 AC_TRY_COMPILE(,,, mpfr_cv_ieee_switches="none") 105 ]) 106 if test "$mpfr_cv_ieee_switches" = "none"; then 107 CFLAGS="$saved_CFLAGS" 108 else 109 CFLAGS="$saved_CFLAGS $mpfr_cv_ieee_switches" 110 fi 111esac 112 113dnl check for long long 114AC_CHECK_TYPE([long long int], 115 AC_DEFINE(HAVE_LONG_LONG, 1, [Define if compiler supports long long]),,) 116 117dnl intmax_t is C99 118AC_CHECK_TYPES([intmax_t]) 119if test "$ac_cv_type_intmax_t" = yes; then 120 AC_CACHE_CHECK([for working INTMAX_MAX], mpfr_cv_have_intmax_max, [ 121 saved_CPPFLAGS="$CPPFLAGS" 122 CPPFLAGS="$CPPFLAGS -I$srcdir/src" 123 AC_TRY_COMPILE([#include "mpfr-intmax.h"], [intmax_t x = INTMAX_MAX;], 124 mpfr_cv_have_intmax_max=yes, mpfr_cv_have_intmax_max=no) 125 CPPFLAGS="$saved_CPPFLAGS" 126 ]) 127 if test "$mpfr_cv_have_intmax_max" = "yes"; then 128 AC_DEFINE(MPFR_HAVE_INTMAX_MAX,1,[Define if you have a working INTMAX_MAX.]) 129 fi 130fi 131 132AC_CHECK_TYPE( [union fpc_csr], 133 AC_DEFINE(HAVE_FPC_CSR,1,[Define if union fpc_csr is available]), , 134[ 135#if HAVE_SYS_FPU_H 136# include <sys/fpu.h> 137#endif 138]) 139 140dnl Check for fesetround 141AC_CACHE_CHECK([for fesetround], mpfr_cv_have_fesetround, [ 142saved_LIBS="$LIBS" 143LIBS="$LIBS $MPFR_LIBM" 144AC_TRY_LINK([#include <fenv.h>], [fesetround(FE_TONEAREST);], 145 mpfr_cv_have_fesetround=yes, mpfr_cv_have_fesetround=no) 146LIBS="$saved_LIBS" 147]) 148if test "$mpfr_cv_have_fesetround" = "yes"; then 149 AC_DEFINE(MPFR_HAVE_FESETROUND,1,[Define if you have the `fesetround' function via the <fenv.h> header file.]) 150fi 151 152dnl Check for gcc float-conversion bug; if need be, -ffloat-store is used to 153dnl force the conversion to the destination type when a value is stored to 154dnl a variable (see ISO C99 standard 5.1.2.3#13, 6.3.1.5#2, 6.3.1.8#2). This 155dnl is important concerning the exponent range. Note that this doesn't solve 156dnl the double-rounding problem. 157if test -n "$GCC"; then 158 AC_CACHE_CHECK([for gcc float-conversion bug], mpfr_cv_gcc_floatconv_bug, [ 159 saved_LIBS="$LIBS" 160 LIBS="$LIBS $MPFR_LIBM" 161 AC_TRY_RUN([ 162#include <float.h> 163#ifdef MPFR_HAVE_FESETROUND 164#include <fenv.h> 165#endif 166static double get_max (void); 167int main() { 168 double x = 0.5; 169 double y; 170 int i; 171 for (i = 1; i <= 11; i++) 172 x *= x; 173 if (x != 0) 174 return 1; 175#ifdef MPFR_HAVE_FESETROUND 176 /* Useful test for the G4 PowerPC */ 177 fesetround(FE_TOWARDZERO); 178 x = y = get_max (); 179 x *= 2.0; 180 if (x != y) 181 return 1; 182#endif 183 return 0; 184} 185static double get_max (void) { static volatile double d = DBL_MAX; return d; } 186 ], [mpfr_cv_gcc_floatconv_bug="no"], 187 [mpfr_cv_gcc_floatconv_bug="yes, use -ffloat-store"], 188 [mpfr_cv_gcc_floatconv_bug="cannot test, use -ffloat-store"]) 189 LIBS="$saved_LIBS" 190 ]) 191 if test "$mpfr_cv_gcc_floatconv_bug" != "no"; then 192 CFLAGS="$CFLAGS -ffloat-store" 193 fi 194fi 195 196dnl Check if denormalized numbers are supported 197AC_CACHE_CHECK([for denormalized numbers], mpfr_cv_have_denorms, [ 198AC_TRY_RUN([ 199#include <math.h> 200#include <stdio.h> 201int main() { 202 double x = 2.22507385850720138309e-308; 203 fprintf (stderr, "%e\n", x / 2.0); 204 return 2.0 * (x / 2.0) != x; 205} 206], mpfr_cv_have_denorms=yes, mpfr_cv_have_denorms=no, mpfr_cv_have_denorms=no) 207]) 208if test "$mpfr_cv_have_denorms" = "yes"; then 209 AC_DEFINE(HAVE_DENORMS,1,[Define if denormalized floats work.]) 210fi 211 212dnl Check the FP division by 0 fails (e.g. on a non-IEEE-754 platform). 213dnl In such a case, MPFR_ERRDIVZERO is defined to disable the tests 214dnl involving a FP division by 0. 215dnl For the developers: to check whether all these tests are disabled, 216dnl configure MPFR with "-DMPFR_TEST_DIVBYZERO=1 -DMPFR_ERRDIVZERO=1". 217AC_CACHE_CHECK([if the FP division by 0 fails], mpfr_cv_errdivzero, [ 218AC_TRY_RUN([ 219int main() { 220 volatile double d = 0.0, x; 221 x = 0.0 / d; 222 x = 1.0 / d; 223 return 0; 224} 225], [mpfr_cv_errdivzero="no"], 226 [mpfr_cv_errdivzero="yes"], 227 [mpfr_cv_errdivzero="cannot test, assume no"]) 228]) 229if test "$mpfr_cv_errdivzero" = "yes"; then 230 AC_DEFINE(MPFR_ERRDIVZERO,1,[Define if the FP division by 0 fails.]) 231 AC_MSG_WARN([The floating-point division by 0 fails instead of]) 232 AC_MSG_WARN([returning a special value: NaN or infinity. Tests]) 233 AC_MSG_WARN([involving a FP division by 0 will be disabled.]) 234fi 235 236dnl Check whether NAN != NAN (as required by the IEEE-754 standard, 237dnl but not by the ISO C standard). For instance, this is false with 238dnl MIPSpro 7.3.1.3m under IRIX64. By default, assume this is true. 239AC_CACHE_CHECK([if NAN == NAN], mpfr_cv_nanisnan, [ 240AC_TRY_RUN([ 241#include <stdio.h> 242#include <math.h> 243#ifndef NAN 244# define NAN (0.0/0.0) 245#endif 246int main() { 247 double d; 248 d = NAN; 249 return d != d; 250} 251], [mpfr_cv_nanisnan="yes"], 252 [mpfr_cv_nanisnan="no"], 253 [mpfr_cv_nanisnan="cannot test, assume no"]) 254]) 255if test "$mpfr_cv_nanisnan" = "yes"; then 256 AC_DEFINE(MPFR_NANISNAN,1,[Define if NAN == NAN.]) 257 AC_MSG_WARN([The test NAN != NAN is false. The probable reason is that]) 258 AC_MSG_WARN([your compiler optimizes floating-point expressions in an]) 259 AC_MSG_WARN([unsafe way because some option, such as -ffast-math or]) 260 AC_MSG_WARN([-fast (depending on the compiler), has been used. You]) 261 AC_MSG_WARN([should NOT use such an option, otherwise MPFR functions]) 262 AC_MSG_WARN([such as mpfr_get_d and mpfr_set_d may return incorrect]) 263 AC_MSG_WARN([results on special FP numbers (e.g. NaN or signed zeros).]) 264 AC_MSG_WARN([If you did not use such an option, please send us a bug]) 265 AC_MSG_WARN([report so that we can try to find a workaround for your]) 266 AC_MSG_WARN([platform and/or document the behavior.]) 267fi 268 269dnl Check if the chars '0' to '9' are consecutive values 270AC_MSG_CHECKING([if charset has consecutive values]) 271AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 272char *number = "0123456789"; 273char *lower = "abcdefghijklmnopqrstuvwxyz"; 274char *upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 275]],[[ 276 int i; 277 unsigned char *p; 278 for (p = (unsigned char*) number, i = 0; i < 9; i++) 279 if ( (*p)+1 != *(p+1) ) return 1; 280 for (p = (unsigned char*) lower, i = 0; i < 25; i++) 281 if ( (*p)+1 != *(p+1) ) return 1; 282 for (p = (unsigned char*) upper, i = 0; i < 25; i++) 283 if ( (*p)+1 != *(p+1) ) return 1; 284]])], [AC_MSG_RESULT(yes)],[ 285 AC_MSG_RESULT(no) 286 AC_DEFINE(MPFR_NO_CONSECUTIVE_CHARSET,1,[Charset is not consecutive]) 287], [AC_MSG_RESULT(cannot test)]) 288 289dnl Must be checked with the LIBM 290dnl but we don't want to add the LIBM to MPFR dependency. 291dnl Can't use AC_CHECK_FUNCS since the function may be in LIBM but 292dnl not exported in math.h 293saved_LIBS="$LIBS" 294LIBS="$LIBS $MPFR_LIBM" 295dnl AC_CHECK_FUNCS([round trunc floor ceil nearbyint]) 296AC_MSG_CHECKING(for math/round) 297AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 298#include <math.h> 299int f (double (*func)(double)) { return 0;} 300]], [[ 301 double a = 17.42; 302 a = f (round); 303 return 0; 304]])], [ 305 AC_MSG_RESULT(yes) 306 AC_DEFINE(HAVE_ROUND, 1,[Have ISO-C99 round function]) 307],[AC_MSG_RESULT(no)]) 308 309AC_MSG_CHECKING(for math/trunc) 310AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 311#include <math.h> 312int f (double (*func)(double)) { return 0;} 313]], [[ 314 double a = 17.42; 315 a = f(trunc); 316 return 0; 317]])], [ 318 AC_MSG_RESULT(yes) 319 AC_DEFINE(HAVE_TRUNC, 1,[Have ISO-C99 trunc function]) 320],[AC_MSG_RESULT(no)]) 321 322AC_MSG_CHECKING(for math/floor) 323AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 324#include <math.h> 325int f (double (*func)(double)) { return 0;} 326]], [[ 327 double a = 17.42; 328 a = f(floor); 329 return 0; 330]])], [ 331 AC_MSG_RESULT(yes) 332 AC_DEFINE(HAVE_FLOOR, 1,[Have ISO-C99 floor function]) 333],[AC_MSG_RESULT(no)]) 334 335AC_MSG_CHECKING(for math/ceil) 336AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 337#include <math.h> 338int f (double (*func)(double)) { return 0;} 339]], [[ 340 double a = 17.42; 341 a = f(ceil); 342 return 0; 343]])], [ 344 AC_MSG_RESULT(yes) 345 AC_DEFINE(HAVE_CEIL, 1,[Have ISO-C99 ceil function]) 346],[AC_MSG_RESULT(no)]) 347 348AC_MSG_CHECKING(for math/rint) 349AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 350#include <math.h> 351int f (double (*func)(double)) { return 0;} 352]], [[ 353 double a = 17.42; 354 a = f(nearbyint); 355 return 0; 356]])], [ 357 AC_MSG_RESULT(yes) 358 AC_DEFINE(HAVE_NEARBYINT, 1,[Have ISO-C99 rint function]) 359],[AC_MSG_RESULT(no)]) 360 361LIBS="$saved_LIBS" 362 363dnl Now try to check the long double format 364MPFR_C_LONG_DOUBLE_FORMAT 365 366if test "$enable_logging" = yes; then 367 if test "$enable_thread_safe" = yes; then 368 AC_MSG_ERROR([Enable either `Logging' or `thread-safe', not both]) 369 else 370 enable_thread_safe=no 371 fi 372fi 373 374dnl Check if thread-local variables are supported. 375dnl At least two problems can occur in practice: 376dnl 1. The compilation fails, e.g. because the compiler doesn't know 377dnl about the __thread keyword. 378dnl 2. The compilation succeeds, but the system doesn't support TLS or 379dnl there is some ld configuration problem. One of the effects can 380dnl be that thread-local variables always evaluate to 0. So, it is 381dnl important to run the test below. 382if test "$enable_thread_safe" != no; then 383AC_MSG_CHECKING(for TLS support) 384saved_CPPFLAGS="$CPPFLAGS" 385CPPFLAGS="$CPPFLAGS -I$srcdir/src" 386AC_RUN_IFELSE([AC_LANG_SOURCE([[ 387#define MPFR_USE_THREAD_SAFE 1 388#include "mpfr-thread.h" 389MPFR_THREAD_ATTR int x = 17; 390int main() { 391 return x != 17; 392} 393 ]])], 394 [AC_MSG_RESULT(yes) 395 AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe]) 396 ], 397 [AC_MSG_RESULT(no) 398 if test "$enable_thread_safe" = yes; then 399 AC_MSG_ERROR([please configure with --disable-thread-safe]) 400 fi 401 ], 402 [if test "$enable_thread_safe" = yes; then 403 AC_MSG_RESULT([cannot test, assume yes]) 404 AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe]) 405 else 406 AC_MSG_RESULT([cannot test, assume no]) 407 fi 408 ]) 409CPPFLAGS="$saved_CPPFLAGS" 410fi 411]) 412dnl end of MPFR_CONFIGS 413 414 415dnl MPFR_C_LONG_DOUBLE_FORMAT 416dnl ------------------------- 417dnl Determine the format of a long double. 418dnl 419dnl The object file is grepped, so as to work when cross compiling. A 420dnl start and end sequence is included to avoid false matches, and 421dnl allowance is made for the desired data crossing an "od -b" line 422dnl boundary. The test number is a small integer so it should appear 423dnl exactly, no rounding or truncation etc. 424dnl 425dnl "od -b" is supported even by Unix V7, and the awk script used doesn't 426dnl have functions or anything, so even an "old" awk should suffice. 427dnl 428dnl The 10-byte IEEE extended format is generally padded to either 12 or 16 429dnl bytes for alignment purposes. The SVR4 i386 ABI is 12 bytes, or i386 430dnl gcc -m128bit-long-double selects 16 bytes. IA-64 is 16 bytes in LP64 431dnl mode, or 12 bytes in ILP32 mode. The first 10 bytes is the relevant 432dnl part in all cases (big and little endian). 433dnl 434dnl Enhancements: 435dnl 436dnl Could match more formats, but no need to worry until there's code 437dnl wanting to use them. 438dnl 439dnl Don't want to duplicate the double matching from GMP_C_DOUBLE_FORMAT, 440dnl perhaps we should merge with that macro, to match data formats 441dnl irrespective of the C type in question. Or perhaps just let the code 442dnl use DOUBLE macros when sizeof(double)==sizeof(long double). 443 444AC_DEFUN([MPFR_C_LONG_DOUBLE_FORMAT], 445[AC_REQUIRE([AC_PROG_CC]) 446AC_REQUIRE([AC_PROG_AWK]) 447AC_REQUIRE([AC_OBJEXT]) 448AC_CHECK_TYPES([long double]) 449AC_CACHE_CHECK([format of `long double' floating point], 450 mpfr_cv_c_long_double_format, 451[mpfr_cv_c_long_double_format=unknown 452if test "$ac_cv_type_long_double" != yes; then 453 mpfr_cv_c_long_double_format="not available" 454else 455 cat >conftest.c <<\EOF 456[ 457/* "before" is 16 bytes to ensure there's no padding between it and "x". 458 We're not expecting any "long double" bigger than 16 bytes or with 459 alignment requirements stricter than 16 bytes. */ 460struct { 461 char before[16]; 462 long double x; 463 char after[8]; 464} foo = { 465 { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', 466 '\001', '\043', '\105', '\147', '\211', '\253', '\315', '\357' }, 467 -123456789.0, 468 { '\376', '\334', '\272', '\230', '\166', '\124', '\062', '\020' } 469}; 470] 471EOF 472 mpfr_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC 2>&1" 473 if AC_TRY_EVAL(mpfr_compile); then 474 cat >conftest.awk <<\EOF 475[ 476BEGIN { 477 found = 0 478} 479 480# got[] holds a sliding window of bytes read the input. got[0] is the most 481# recent byte read, and got[31] the oldest byte read, so when looking to 482# match some data the indices are "reversed". 483# 484{ 485 for (f = 2; f <= NF; f++) 486 { 487 # new byte, shift others up 488 for (i = 31; i >= 0; i--) 489 got[i+1] = got[i]; 490 got[0] = $f; 491 492 # end sequence 493 if (got[7] != "376") continue 494 if (got[6] != "334") continue 495 if (got[5] != "272") continue 496 if (got[4] != "230") continue 497 if (got[3] != "166") continue 498 if (got[2] != "124") continue 499 if (got[1] != "062") continue 500 if (got[0] != "020") continue 501 502 # start sequence, with 8-byte body 503 if (got[23] == "001" && \ 504 got[22] == "043" && \ 505 got[21] == "105" && \ 506 got[20] == "147" && \ 507 got[19] == "211" && \ 508 got[18] == "253" && \ 509 got[17] == "315" && \ 510 got[16] == "357") 511 { 512 saw = " (" got[15] \ 513 " " got[14] \ 514 " " got[13] \ 515 " " got[12] \ 516 " " got[11] \ 517 " " got[10] \ 518 " " got[9] \ 519 " " got[8] ")" 520 521 if (got[15] == "301" && \ 522 got[14] == "235" && \ 523 got[13] == "157" && \ 524 got[12] == "064" && \ 525 got[11] == "124" && \ 526 got[10] == "000" && \ 527 got[9] == "000" && \ 528 got[8] == "000") 529 { 530 print "IEEE double, big endian" 531 found = 1 532 exit 533 } 534 535 if (got[15] == "000" && \ 536 got[14] == "000" && \ 537 got[13] == "000" && \ 538 got[12] == "124" && \ 539 got[11] == "064" && \ 540 got[10] == "157" && \ 541 got[9] == "235" && \ 542 got[8] == "301") 543 { 544 print "IEEE double, little endian" 545 found = 1 546 exit 547 } 548 } 549 550 # start sequence, with 12-byte body 551 if (got[27] == "001" && \ 552 got[26] == "043" && \ 553 got[25] == "105" && \ 554 got[24] == "147" && \ 555 got[23] == "211" && \ 556 got[22] == "253" && \ 557 got[21] == "315" && \ 558 got[20] == "357") 559 { 560 saw = " (" got[19] \ 561 " " got[18] \ 562 " " got[17] \ 563 " " got[16] \ 564 " " got[15] \ 565 " " got[14] \ 566 " " got[13] \ 567 " " got[12] \ 568 " " got[11] \ 569 " " got[10] \ 570 " " got[9] \ 571 " " got[8] ")" 572 573 if (got[19] == "000" && \ 574 got[18] == "000" && \ 575 got[17] == "000" && \ 576 got[16] == "000" && \ 577 got[15] == "240" && \ 578 got[14] == "242" && \ 579 got[13] == "171" && \ 580 got[12] == "353" && \ 581 got[11] == "031" && \ 582 got[10] == "300") 583 { 584 print "IEEE extended, little endian" 585 found = 1 586 exit 587 } 588 589 if (got[19] == "300" && \ 590 got[18] == "031" && \ 591 got[17] == "000" && \ 592 got[16] == "000" && \ 593 got[15] == "353" && \ 594 got[14] == "171" && \ 595 got[13] == "242" && \ 596 got[12] == "240" && \ 597 got[11] == "000" && \ 598 got[10] == "000" && \ 599 got[09] == "000" && \ 600 got[08] == "000") 601 { 602 # format found on m68k 603 print "IEEE extended, big endian" 604 found = 1 605 exit 606 } 607 } 608 609 # start sequence, with 16-byte body 610 if (got[31] == "001" && \ 611 got[30] == "043" && \ 612 got[29] == "105" && \ 613 got[28] == "147" && \ 614 got[27] == "211" && \ 615 got[26] == "253" && \ 616 got[25] == "315" && \ 617 got[24] == "357") 618 { 619 saw = " (" got[23] \ 620 " " got[22] \ 621 " " got[21] \ 622 " " got[20] \ 623 " " got[19] \ 624 " " got[18] \ 625 " " got[17] \ 626 " " got[16] \ 627 " " got[15] \ 628 " " got[14] \ 629 " " got[13] \ 630 " " got[12] \ 631 " " got[11] \ 632 " " got[10] \ 633 " " got[9] \ 634 " " got[8] ")" 635 636 if (got[23] == "000" && \ 637 got[22] == "000" && \ 638 got[21] == "000" && \ 639 got[20] == "000" && \ 640 got[19] == "240" && \ 641 got[18] == "242" && \ 642 got[17] == "171" && \ 643 got[16] == "353" && \ 644 got[15] == "031" && \ 645 got[14] == "300") 646 { 647 print "IEEE extended, little endian" 648 found = 1 649 exit 650 } 651 652 if (got[23] == "300" && \ 653 got[22] == "031" && \ 654 got[21] == "326" && \ 655 got[20] == "363" && \ 656 got[19] == "105" && \ 657 got[18] == "100" && \ 658 got[17] == "000" && \ 659 got[16] == "000" && \ 660 got[15] == "000" && \ 661 got[14] == "000" && \ 662 got[13] == "000" && \ 663 got[12] == "000" && \ 664 got[11] == "000" && \ 665 got[10] == "000" && \ 666 got[9] == "000" && \ 667 got[8] == "000") 668 { 669 # format used on HP 9000/785 under HP-UX 670 print "IEEE quad, big endian" 671 found = 1 672 exit 673 } 674 675 if (got[23] == "000" && \ 676 got[22] == "000" && \ 677 got[21] == "000" && \ 678 got[20] == "000" && \ 679 got[19] == "000" && \ 680 got[18] == "000" && \ 681 got[17] == "000" && \ 682 got[16] == "000" && \ 683 got[15] == "000" && \ 684 got[14] == "000" && \ 685 got[13] == "100" && \ 686 got[12] == "105" && \ 687 got[11] == "363" && \ 688 got[10] == "326" && \ 689 got[9] == "031" && \ 690 got[8] == "300") 691 { 692 print "IEEE quad, little endian" 693 found = 1 694 exit 695 } 696 697 if (got[23] == "301" && \ 698 got[22] == "235" && \ 699 got[21] == "157" && \ 700 got[20] == "064" && \ 701 got[19] == "124" && \ 702 got[18] == "000" && \ 703 got[17] == "000" && \ 704 got[16] == "000" && \ 705 got[15] == "000" && \ 706 got[14] == "000" && \ 707 got[13] == "000" && \ 708 got[12] == "000" && \ 709 got[11] == "000" && \ 710 got[10] == "000" && \ 711 got[9] == "000" && \ 712 got[8] == "000") 713 { 714 # format used on 32-bit PowerPC (Mac OS X and Debian GNU/Linux) 715 print "possibly double-double, big endian" 716 found = 1 717 exit 718 } 719 } 720 } 721} 722 723END { 724 if (! found) 725 print "unknown", saw 726} 727] 728EOF 729 mpfr_cv_c_long_double_format=`od -b conftest.$OBJEXT | $AWK -f conftest.awk` 730 case $mpfr_cv_c_long_double_format in 731 unknown*) 732 echo "cannot match anything, conftest.$OBJEXT contains" >&AC_FD_CC 733 od -b conftest.$OBJEXT >&AC_FD_CC 734 ;; 735 esac 736 else 737 AC_MSG_WARN([oops, cannot compile test program]) 738 fi 739fi 740rm -f conftest* 741]) 742 743AH_VERBATIM([HAVE_LDOUBLE], 744[/* Define one of the following to 1 for the format of a `long double'. 745 If your format is not among these choices, or you don't know what it is, 746 then leave all undefined. 747 IEEE_EXT is the 10-byte IEEE extended precision format. 748 IEEE_QUAD is the 16-byte IEEE quadruple precision format. 749 LITTLE or BIG is the endianness. */ 750#undef HAVE_LDOUBLE_IEEE_EXT_LITTLE 751#undef HAVE_LDOUBLE_IEEE_QUAD_BIG]) 752 753case $mpfr_cv_c_long_double_format in 754 "IEEE extended, little endian") 755 AC_DEFINE(HAVE_LDOUBLE_IEEE_EXT_LITTLE, 1) 756 ;; 757 "IEEE quad, big endian") 758 AC_DEFINE(HAVE_LDOUBLE_IEEE_QUAD_BIG, 1) 759 ;; 760 "IEEE quad, little endian") 761 AC_DEFINE(HAVE_LDOUBLE_IEEE_QUAD_LITTLE, 1) 762 ;; 763 "possibly double-double, big endian") 764 AC_MSG_WARN([This format is known on GCC/PowerPC platforms,]) 765 AC_MSG_WARN([but due to GCC PR26374, we can't test further.]) 766 AC_MSG_WARN([You can safely ignore this warning, though.]) 767 # Since we are not sure, we do not want to define a macro. 768 ;; 769 unknown* | "not available") 770 ;; 771 *) 772 AC_MSG_WARN([oops, unrecognised float format: $mpfr_cv_c_long_double_format]) 773 ;; 774esac 775]) 776 777 778dnl MPFR_CHECK_LIBM 779dnl --------------- 780dnl Determine a math library -lm to use. 781 782AC_DEFUN([MPFR_CHECK_LIBM], 783[AC_REQUIRE([AC_CANONICAL_HOST]) 784AC_SUBST(MPFR_LIBM,'') 785case $host in 786 *-*-beos* | *-*-cygwin* | *-*-pw32*) 787 # According to libtool AC CHECK LIBM, these systems don't have libm 788 ;; 789 *-*-solaris*) 790 # On Solaris the math functions new in C99 are in -lm9x. 791 # FIXME: Do we need -lm9x as well as -lm, or just instead of? 792 AC_CHECK_LIB(m9x, main, MPFR_LIBM="-lm9x") 793 AC_CHECK_LIB(m, main, MPFR_LIBM="$MPFR_LIBM -lm") 794 ;; 795 *-ncr-sysv4.3*) 796 # FIXME: What does -lmw mean? Libtool AC CHECK LIBM does it this way. 797 AC_CHECK_LIB(mw, _mwvalidcheckl, MPFR_LIBM="-lmw") 798 AC_CHECK_LIB(m, main, MPFR_LIBM="$MPFR_LIBM -lm") 799 ;; 800 *) 801 AC_CHECK_LIB(m, main, MPFR_LIBM="-lm") 802 ;; 803esac 804]) 805 806 807dnl MPFR_LD_SEARCH_PATHS_FIRST 808dnl -------------------------- 809 810AC_DEFUN([MPFR_LD_SEARCH_PATHS_FIRST], 811[case "$LD $LDFLAGS" in 812 *-Wl,-search_paths_first*) ;; 813 *) AC_MSG_CHECKING([if the compiler understands -Wl,-search_paths_first]) 814 saved_LDFLAGS="$LDFLAGS" 815 LDFLAGS="-Wl,-search_paths_first $LDFLAGS" 816 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], 817 [AC_MSG_RESULT(yes)], 818 [AC_MSG_RESULT(no)] 819 LDFLAGS="$saved_LDFLAGS") 820 ;; 821 esac 822]) 823 824 825dnl GMP_C_ATTRIBUTE_MODE 826dnl -------------------- 827dnl Introduced in gcc 2.2, but perhaps not in all Apple derived versions. 828dnl Needed for mpfr-longlong.h; this is currently necessary for s390. 829dnl 830dnl TODO: Replace this with a cleaner type size detection, as this 831dnl solution only works with gcc and assumes CHAR_BIT == 8. Probably use 832dnl <stdint.h>, and <http://gcc.gnu.org/viewcvs/trunk/config/stdint.m4> 833dnl as a fallback. 834 835AC_DEFUN([GMP_C_ATTRIBUTE_MODE], 836[AC_CACHE_CHECK([whether gcc __attribute__ ((mode (XX))) works], 837 gmp_cv_c_attribute_mode, 838[AC_TRY_COMPILE([typedef int SItype __attribute__ ((mode (SI)));], , 839 gmp_cv_c_attribute_mode=yes, gmp_cv_c_attribute_mode=no) 840]) 841if test $gmp_cv_c_attribute_mode = yes; then 842 AC_DEFINE(HAVE_ATTRIBUTE_MODE, 1, 843 [Define to 1 if the compiler accepts gcc style __attribute__ ((mode (XX)))]) 844fi 845]) 846 847 848dnl MPFR_FUNC_GMP_PRINTF_SPEC 849dnl ------------------------------------ 850dnl MPFR_FUNC_GMP_PRINTF_SPEC(spec, type, [includes], [if-true], [if-false]) 851dnl Check if gmp_sprintf supports the conversion specification 'spec' 852dnl with type 'type'. 853dnl Expand 'if-true' if printf supports 'spec', 'if-false' otherwise. 854 855AC_DEFUN([MPFR_FUNC_GMP_PRINTF_SPEC],[ 856AC_MSG_CHECKING(if gmp_printf supports "%$1") 857AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 858#include <stdio.h> 859$3 860#include <gmp.h> 861]], [[ 862 char s[256]; 863 $2 a = 17; 864 865 if (gmp_sprintf (s, "(%0.0$1)(%d)", a, 42) == -1) return 1; 866 return (strcmp (s, "(17)(42)") != 0); 867]])], 868 [AC_MSG_RESULT(yes) 869 $4], 870 [AC_MSG_RESULT(no) 871 $5]) 872]) 873 874 875dnl MPFR_CHECK_PRINTF_SPEC 876dnl ---------------------- 877dnl Check if gmp_printf supports some optional length modifiers. 878dnl Defined symbols are negative to shorten the gcc command line. 879 880AC_DEFUN([MPFR_CHECK_PRINTF_SPEC], [ 881AC_REQUIRE([MPFR_CONFIGS])dnl 882if test "$ac_cv_type_intmax_t" = yes; then 883 MPFR_FUNC_GMP_PRINTF_SPEC([jd], [intmax_t], [ 884#ifdef HAVE_INTTYPES_H 885# include <inttypes.h> 886#endif 887#ifdef HAVE_STDINT_H 888# include <stdint.h> 889#endif 890 ],, 891 [AC_DEFINE([NPRINTF_J], 1, [gmp_printf cannot read intmax_t])]) 892fi 893 894MPFR_FUNC_GMP_PRINTF_SPEC([hhd], [char], [ 895#include <gmp.h> 896 ],, 897 [AC_DEFINE([NPRINTF_HH], 1, [gmp_printf cannot use `hh' length modifier])]) 898 899MPFR_FUNC_GMP_PRINTF_SPEC([lld], [long long int], [ 900#include <gmp.h> 901 ],, 902 [AC_DEFINE([NPRINTF_LL], 1, [gmp_printf cannot read long long int])]) 903 904MPFR_FUNC_GMP_PRINTF_SPEC([Lf], [long double], [ 905#include <gmp.h> 906 ],, 907 [AC_DEFINE([NPRINTF_L], 1, [gmp_printf cannot read long double])]) 908 909MPFR_FUNC_GMP_PRINTF_SPEC([td], [ptrdiff_t], [ 910#if defined (__cplusplus) 911#include <cstddef> 912#else 913#include <stddef.h> 914#endif 915#include "gmp.h" 916 ],, 917 [AC_DEFINE([NPRINTF_T], 1, [gmp_printf cannot read ptrdiff_t])]) 918]) 919