1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
AC_DEFUN(AC_MY_LIBS,
[
if ` test "$1" `
then
AC_MSG_CHECKING(gmp library)
if test -r "$1/lib$2.a"
then
LDADD="$LDADD $1/lib$2.a"
else
AC_MSG_ERROR($2 not found)
fi
AC_MSG_RESULT(yes)
else
AC_CHECK_LIB($2, main, , AC_MSG_ERROR($2 not found))
fi
]
)
AC_DEFUN(AC_MY_HEADERS,
[
if test "$1"
then
AC_CHECK_HEADER($1/$2, INCLUDES="$INCLUDES -I$1",AC_MSG_ERROR(echo $2 not found in $1))
else
AC_CHECK_HEADER($2,, AC_MSG_ERROR($2 not found))
fi
])
AC_DEFUN(AC_CHECK_OS,
[
AC_CACHE_CHECK([OS type], mpfr_cv_os_type, [
mpfr_cv_os_type=`uname -s`
])
OS_TYPE=$mpfr_cv_os_type
])
AC_DEFUN(AC_CHECK_MACHTYPE,
[
AC_CACHE_CHECK([Mach type], mpfr_cv_mach_type, [
mpfr_cv_mach_type=`uname -m`
])
MACHTYPE=$mpfr_cv_mach_type
])
dnl ------------------------------------------------------------
AC_DEFUN(MPFR_CONFIGS,
[
case $OS_TYPE in
SunOS*)
LM9X="-lm9x"
;;
esac
AC_REPLACE_FUNCS(strcasecmp)
dnl Check for IEEE-754 switches on Alpha
if test "$MACHTYPE" = "alpha"; then
saved_CFLAGS="$CFLAGS"
AC_CACHE_CHECK([for IEEE-754 switches], mpfr_cv_ieee_switches, [
if test -n "$GCC"; then
mpfr_cv_ieee_switches="-mfp-rounding-mode=d -mieee-with-inexact"
else
mpfr_cv_ieee_switches="-fprm d -ieee_with_inexact"
fi
CFLAGS="$CFLAGS $mpfr_cv_ieee_switches"
AC_TRY_COMPILE(,,, mpfr_cv_ieee_switches="none")
])
if test "$mpfr_cv_ieee_switches" = "none"; then
CFLAGS="$saved_CFLAGS"
else
CFLAGS="$saved_CFLAGS $mpfr_cv_ieee_switches"
fi
fi
AC_CHECK_HEADERS(fpu_control.h)
dnl Check for fesetround
AC_CACHE_CHECK([for fesetround], mpfr_cv_have_fesetround, [
saved_LIBS="$LIBS"
LIBS="$LIBS $LM9X"
AC_TRY_LINK([#include <fenv.h>], [fesetround(FE_TONEAREST);],
mpfr_cv_have_fesetround=yes, mpfr_cv_have_fesetround=no)
LIBS="$saved_LIBS"
])
if test "$mpfr_cv_have_fesetround" = "yes"; then
LIBS="$LIBS $LM9X"
AC_DEFINE(MPFR_HAVE_FESETROUND,1,[Define if you have the `fesetround' function via the <fenv.h> header file.])
fi
dnl Check random functions
AC_CHECK_FUNCS(lrand48)
dnl Check whether 0/0, 1/0, -1/0, sqrt(-1) are valid expressions
AC_CACHE_CHECK([for valid NaN], mpfr_cv_valid_nan, [
AC_TRY_RUN([
#include <math.h>
int main()
{
double x = (0.0/0.0) + sqrt(-1.0);
return x == 1.0/0.0;
}
], mpfr_cv_valid_nan=yes, mpfr_cv_valid_nan=no, mpfr_cv_valid_nan=no)
])
if test "$mpfr_cv_valid_nan" = "yes"; then
AC_DEFINE(HAVE_INFS,1,[Define if 0/0, 1/0, -1/0 and sqrt(-1) work to generate NaN/infinities.])
fi
dnl Check for gcc float-conversion bug; if need be, -ffloat-store is used to
dnl force the conversion to the destination type when a value is stored to
dnl a variable (see ISO C99 standard 5.1.2.3#13, 6.3.1.5#2, 6.3.1.8#2). This
dnl is important concerning the exponent range. Note that this doesn't solve
dnl the double-rounding problem (x86 processors still have to be set to the
dnl IEEE-754 compatible rounding mode).
if test -n "$GCC"; then
AC_CACHE_CHECK([for gcc float-conversion bug], mpfr_cv_gcc_floatconv_bug, [
AC_TRY_RUN([
int main()
{
double x = 0.5;
int i;
for (i = 1; i <= 11; i++)
x *= x;
return x == 0;
}
], [mpfr_cv_gcc_floatconv_bug="yes, use -ffloat-store"],
[mpfr_cv_gcc_floatconv_bug="no"],
[mpfr_cv_gcc_floatconv_bug="cannot test, use -ffloat-store"])
])
if test "$mpfr_cv_gcc_floatconv_bug" != "no"; then
CFLAGS="$CFLAGS -ffloat-store"
fi
fi
dnl Check if denormalized numbers are supported
AC_CACHE_CHECK([for denormalized numbers], mpfr_cv_have_denorms, [
AC_TRY_RUN([
#include <math.h>
#include <stdio.h>
int main()
{
double x = 2.22507385850720138309e-308;
fprintf (stderr, "%e\n", x / 2.0);
return 2.0 * (x / 2.0) != x;
}
], mpfr_cv_have_denorms=yes, mpfr_cv_have_denorms=no, mpfr_cv_have_denorms=no)
])
if test "$mpfr_cv_have_denorms" = "yes"; then
AC_DEFINE(HAVE_DENORMS,1,[Define if denormalized floats work.])
fi
])
|