summaryrefslogtreecommitdiff
path: root/configure.in
blob: bfaead467976db78e633a1bae7a392f71918fe43 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
dnl Process this file with autoconf to produce a configure script.
AC_INIT()

mpfr_version=`cat $srcdir/VERSION`
AM_INIT_AUTOMAKE(mpfr, $mpfr_version, [no-define])

AC_ARG_WITH(gmp_include, [ --with-gmp-include=DIR  GMP include directory ], with_gmp_include=$withval)
AC_ARG_WITH(gmp_lib, [ --with-gmp-lib=DIR      GMP lib directory ], with_gmp_lib=$withval)
AC_ARG_WITH(gmp, [ --with-gmp=DIR          GMP directory ], with_gmp_include=$withval/include with_gmp_lib=$withval/lib)

AC_ARG_WITH(irix64, [ --with-irix64=on/off    Irix 32/64 bits support ], with_irix64=$withval, with_irix64=off)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
AC_CHECK_OS
AC_CHECK_MACHTYPE

dnl If compiler is gcc, then use some specific flags.
if test -n "$GCC"; then
  CFLAGS="-g -O2 -Wall -Wmissing-prototypes $CFLAGS"
fi

MISCFLAGS='$<'
dnl Set the OS-dependent flags.
case $OS_TYPE in
	HP-UX*)
		AC_CHECK_LIB(M, main)
		AC_DEFINE(hpux)
	        LDFLAGS="$LDFLAGS -L/lib/pa1.1"
		;;
	SunOS*)
		MISCFLAGS="trunc.c"
		AC_CHECK_LIB(m, main)
		;;
	Linux*)
		AC_CHECK_LIB(m, main)
		if [[ "$MACHTYPE" = "alpha" ]];	then
		  CFLAGS="$CFLAGS -mfp-rounding-mode=d -mieee-with-inexact"
		fi
		;;
	IRIX64)
		AC_CHECK_LIB(m, main)
		if [[ "$irix64" = "on" ]]; then
		  CFLAGS ="-mabi=64 $CFLAGS"
		else
		  CFLAGS ="-mabi=n32 $CFLAGS"
		fi
		;;
	OSF*)
		AC_CHECK_LIB(m, main)
		CFLAGS="$CFLAGS -mfp-rounding-mode=d -mieee-with-inexact -ffloat-store"
		AC_DEFINE(__STDC__)
		;;
	*)
		AC_CHECK_LIB(m, main)
		;;
esac

AC_CHECK_HEADERS(fpu_control.h)

dnl Tests concerning the include directories.
AC_MSG_CHECKING(for gmp files)
if test -d "$with_gmp_include"; then
  CPPFLAGS="$CPPFLAGS -I$with_gmp_include"
else
  with_gmp_include=
fi
AC_TRY_COMPILE([
#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
], , AC_MSG_RESULT(yes),
    [AC_MSG_RESULT(no)
     AC_MSG_ERROR(gmp.h or gmp-impl.h or config.h or gmp-mparam.h or longlong.h may be missing ${with_gmp_include:+in $with_gmp_include})]
)

dnl Check BITS_PER_MP_LIMB and BYTES_PER_MP_LIMB
AC_MSG_CHECKING(for valid BITS_PER_MP_LIMB and BYTES_PER_MP_LIMB)
AC_TRY_RUN([
#include <limits.h>
#include "gmp.h"
#include "gmp-impl.h"
int main()
{
  return BITS_PER_MP_LIMB == BYTES_PER_MP_LIMB * CHAR_BIT
         && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB ? 0 : 1;
}
], AC_MSG_RESULT(yes),
  [AC_MSG_RESULT(no)
dnl do not use the AC_MSG_ERROR macro because of message truncation...
{ echo "configure: error: BITS_PER_MP_LIMB and/or BYTES_PER_MP_LIMB are incorrect.
You probably need to change some of the GMP or MPFR compile options:
MPFR doesn't currently do as many architecture checks as GMP, so the
default target architecture may be different, hence the error." 1>&2
  exit 1; }])

dnl Check random functions
AC_MSG_CHECKING(for rand48 functions)
AC_TRY_RUN([#include <stdlib.h>
int main() { long int l = lrand48 (); return 0; }],
  [AC_MSG_RESULT(yes)
   AC_DEFINE(HAVE_RAND48)],
  AC_MSG_RESULT(no),
  AC_MSG_RESULT(no)
)

dnl Check for ISOC9X interface for rounding modes
AC_MSG_CHECKING(for fenv.h)
AC_TRY_CPP([#include <fenv.h>],
  [AC_MSG_RESULT(yes)
   AC_DEFINE(HAVE_FENV)],
  AC_MSG_RESULT(no)
)

dnl Check whether 0/0, 1/0, -1/0 are valid expressions
AC_MSG_CHECKING(for 0/0 as a valid expression)
AC_TRY_RUN([#include <math.h>
int main() { double x = 0.0/0.0; exit (0); }],
  [AC_MSG_RESULT(yes)
   AC_DEFINE(HAVE_INFS)],
  AC_MSG_RESULT(no),
  AC_MSG_RESULT(no)
)

dnl Check if denormalized numbers are supported
AC_MSG_CHECKING(for denormalized numbers)
AC_TRY_RUN([
#include <math.h>
#include <stdio.h>
int main() { double x = 2.22507385850720138309e-308;
             fprintf (stderr, "%e\n", x / 2.0);
             exit (2.0 * (x / 2.0) != x);}],
  [AC_MSG_RESULT(yes)
   AC_DEFINE(HAVE_DENORMS)],
  AC_MSG_RESULT(no),
  AC_MSG_RESULT(no)
)

dnl Check for extended precision
AC_MSG_CHECKING(for extended precision)
AC_TRY_RUN([
int main()
{
  double c, d, dj;
  int j;

  c = 1.46484375e-3;

  dj = 1.0;
  for (j=0; j<54; j++) dj *= 0.5;
  d = 0.75 + dj;
  d /= 1 << 9;
  exit (c == d);
}],
  [AC_MSG_RESULT(yes)
   CFLAGS="$CFLAGS -ffloat-store"
   AC_DEFINE(USE_EXTENDED)],
  AC_MSG_RESULT(no),
  AC_MSG_RESULT(no)
)

AC_MY_LIBS($with_gmp_lib, gmp)
AC_SUBST(INCLUDES)
AC_SUBST(LDADD)
AC_SUBST(LDFLAGS)
AC_SUBST(CFLAGS)
AC_SUBST(MISCFLAGS)
AC_OUTPUT(Makefile tests/Makefile)

dnl NEWS README AUTHORS Changelog