summaryrefslogtreecommitdiff
path: root/configure.in
blob: c547b9d93f71023f75d193fc91385509e9ff7bdd (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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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_build, [  --with-gmp-build=DIR    GMP source directory], with_gmp_include=$withval/ with_gmp_lib=$withval/.libs)
AC_ARG_WITH(gmp, [  --with-gmp=DIR          GMP install 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)

AC_ARG_ENABLE(cache, [  --disable-cache         Disable the cache of the global const ], , [enable_cache=yes])

AC_ARG_ENABLE(assert,
AC_HELP_STRING(--enable-assert,enable ASSERT checking [[default=no]]),
[case $enableval in
yes|no|full) ;;
*) AC_MSG_ERROR([bad value $enableval for --enable-assert: yes, no or full]) ;;
esac],
[enable_assert=no])

if test "$enable_assert" = "yes"; then
  AC_DEFINE([WANT_ASSERT],1)
fi
if test "$enable_assert" = "full"; then
  AC_DEFINE([WANT_ASSERT],1)
  AC_DEFINE([CHECK_AGAINST_SUB1],1)
fi

if test "$enable_cache" = "no"; then
  AC_DEFINE([MPFR_NO_CACHE],1)
fi


test_CFLAGS=${CFLAGS+set}

dnl  Same as in gmp acinclude.m4, though currently we're using the normal
dnl  config.sub, so the additional exact cpu types don't arise.
define(X86_PATTERN,
[[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*]])

dnl Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
AC_CANONICAL_HOST
AC_CHECK_OS
AC_CHECK_MACHTYPE

dnl Check if compiler is ICC, and if such a case, disable GCC
dnl And add some specific flags.
dnl Don't add Warnings Flags (Otherwise you'll get more than 20000 warnings).
dnl Add -long_double flags ?
AC_MSG_CHECKING(for ICC)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if !defined(__ICC)
# error "ICC Not Found"
#endif
]], [[]])],[AC_MSG_RESULT(yes)
 GCC=
 CFLAGS="-pc64 -fp_port -mp $CFLAGS"
],[AC_MSG_RESULT(no)])

dnl If compiler is gcc, then use some specific flags.
dnl But don't touch user specified flags.
if test "$test_CFLAGS" != set && test -n "$GCC"; then
  CFLAGS="-Wall -Wmissing-prototypes $CFLAGS"
fi

dnl Set the OS-dependent flags.
case $OS_TYPE in
	HP-UX*)
		if test -n "$GCC"; then
		  LDFLAGS="-Xlinker +allowunsats $LDFLAGS"
		fi
		;;
	IRIX64)
		if [[ "$irix64" = "on" ]]; then
		  CFLAGS ="-mabi=64 $CFLAGS"
		else
		  CFLAGS ="-mabi=n32 $CFLAGS"
		fi
		;;
esac

dnl Tests concerning the include directories.
if test -d "$with_gmp_include"; then
  CPPFLAGS="$CPPFLAGS -I$with_gmp_include"
else
  with_gmp_include=
fi

AC_C_CONST
AC_C_VOLATILE
MPFR_CONFIGS

dnl Check for GMP
AC_MSG_CHECKING(for gmp.h)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include "gmp.h"
]], [[]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)
     AC_MSG_ERROR([gmp.h may be missing ${with_gmp_include:+in $with_gmp_include}])
])

AC_MSG_CHECKING(for recent GMP)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include "gmp.h"
#if (__GNU_MP_VERSION*100+__GNU_MP_VERSION_MINOR*10 < 410)
# error "min GMP version is 4.1.0"
#endif
]], [[]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)
     AC_MSG_ERROR([GMP 4.1.0 min required])
])

dnl Check if we can use internal header files of GMP.
AC_MSG_CHECKING(for gmp internal files)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
]], [[]])],[AC_MSG_RESULT(yes)
     AC_DEFINE([MPFR_HAVE_GMP_IMPL],1)
     dnl Check for valid 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)
	   AC_MSG_ERROR([BITS_PER_MP_LIMB 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.])],
	AC_MSG_RESULT([can't test])
   )
   ],[AC_MSG_RESULT(no) AC_FUNC_ALLOCA
])

# Recent autoconf creates AC_DEFINEs of PACKAGE_VERSION etc, unfortunately
# those -D defines in $DEFS conflict with the same defines in config.h from
# GMP.  Unless or until autoconf gives us a better way for two closely
# related packages to cooperate, use this hack to get rid of them from $DEFS
# here.
#
if test -f confdefs.h; then
  sed '/#define PACKAGE_/d' <confdefs.h >confdefs.tmp
  mv confdefs.tmp confdefs.h
fi

AC_MY_LIBS($with_gmp_lib, gmp)

dnl Check for corresponding 'gmp.h' and libgmp.a
AC_MSG_CHECKING(if gmp.h version and libgmp version are the same)
AC_TRY_RUN([
#include <stdio.h>
#include <string.h>
#include "gmp.h"
int main()
{
  char buffer[100];
  if (__GNU_MP_VERSION_PATCHLEVEL != 0)
    sprintf (buffer, "%d.%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR,
	    __GNU_MP_VERSION_PATCHLEVEL); 
  else
    sprintf (buffer, "%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR);
  return (strcmp (buffer, gmp_version) != 0) ? 1 : 0;
}
], AC_MSG_RESULT(yes), 
   [AC_MSG_RESULT(no)
    AC_MSG_ERROR(['gmp.h' and 'libgmp' have different versions! you have to properly reinstall GMP.])],
    AC_MSG_RESULT([can't test])
)

AC_SUBST(INCLUDES)
AC_SUBST(LDADD)
AC_SUBST(LDFLAGS)
AC_SUBST(CFLAGS)
AC_CONFIG_FILES([Makefile tests/Makefile])
AC_OUTPUT

dnl NEWS README AUTHORS Changelog