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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
|
dnl Process this file with autoconf to produce a configure script.
AC_COPYRIGHT([
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Contributed by the Arenaire and Cacao projects, INRIA.
This file is part of the MPFR Library.
The MPFR Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
The MPFR Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the MPFR Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
MA 02110-1301, USA.
])
dnl If MPFR becomes GNU MPFR, change to GNU MPFR in update-version
dnl Add check-news when it checks for more than 15 lines
AC_INIT([MPFR],[2.4.0-dev])
AM_INIT_AUTOMAKE([1.6 no-define dist-zip dist-bzip2])
dnl AM_MAINTAINER_MODE
dnl FIXME: The AC_ARG_ENABLE(decimal-float...) part does things too
dnl early, even when this option is not used. In particular, it must
dnl be put after AC_PROG_CC; another problem is that the GMP CFLAGS
dnl and CC check may modify the compiler.
test_CFLAGS=${CFLAGS+set}
AC_CANONICAL_HOST
dnl To use a separate config header.
dnl There is still some problem with GMP's HAVE_CONFIG
dnl AC_CONFIG_HEADERS([mpfrconf.h:mpfrconf.in])
dnl Extra arguments to configure
unset gmp_lib_path GMP_CFLAGS GMP_CC
AC_ARG_WITH(gmp_include,
[ --with-gmp-include=DIR GMP include directory ],
CPPFLAGS="$CPPFLAGS -I$withval")
AC_ARG_WITH(gmp_lib,
[ --with-gmp-lib=DIR GMP lib directory ], [
LDFLAGS="$LDFLAGS -L$withval"
gmp_lib_path="$withval"
])
AC_ARG_WITH(gmp_build,
[ --with-gmp-build=DIR GMP build directory], [
CPPFLAGS="$CPPFLAGS -I$withval -I$withval/tune"
LDFLAGS="$LDFLAGS -L$withval -L$withval/.libs -L$withval/tune/"
gmp_lib_path="$withval$PATH_SEPARATOR$withval/.libs$PATH_SEPARATOR$withval/tune"
if test -r $withval/Makefile ; then
GMP_CFLAGS=`grep -w "CFLAGS =" $withval/Makefile | sed 's/CFLAGS = //'`
GMP_CC=`grep -w "CC =" $withval/Makefile | sed 's/CC = //'`
fi
use_gmp_build=yes
])
AC_ARG_WITH(gmp,
[ --with-gmp=DIR GMP install directory ], [
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
gmp_lib_path="$withval/lib"
])
AC_ARG_WITH(mulhigh_size,
[ --with-mulhigh-size=NUM internal threshold table for mulhigh],
AC_DEFINE_UNQUOTED([MPFR_MULHIGH_SIZE],$withval, [Mulhigh size]))
AC_ARG_ENABLE(assert,
[ --enable-assert enable ASSERT checking [[default=no]]],
[ case $enableval in
yes) AC_DEFINE([WANT_ASSERT],1,[Want assertion]) ;;
no) ;;
full) AC_DEFINE([WANT_ASSERT],2,[Want assertion]) ;;
*) AC_MSG_ERROR([bad value for --enable-assert: yes, no or full]) ;;
esac])
AC_ARG_ENABLE(logging,
[ --enable-logging enable MPFR logging (the system must support it)
[[default=no]]],
[ disable_gcc_format_warning=yes
case $enableval in
yes) AC_DEFINE([MPFR_USE_LOGGING],1,[Log what MPFR does]) ;;
no) ;;
*) AC_MSG_ERROR([bad value for --enable-logging: yes or no]) ;;
esac])
AC_ARG_ENABLE(thread-safe,
[ --enable-thread-safe build MPFR as thread safe [[default=no]]],
[ case $enableval in
yes) AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe]) ;;
no) ;;
*) AC_MSG_ERROR([bad value for --enable-thread-safe: yes or no]) ;;
esac])
AC_ARG_ENABLE(warnings,
[ --enable-warnings allow MPFR to output warnings to stderr [[default=no]]],
[ case $enableval in
yes) AC_DEFINE([MPFR_USE_WARNINGS],1,[Allow MPFR to output warnings to stderr]) ;;
no) ;;
*) AC_MSG_ERROR([bad value for --enable-warnings: yes or no]) ;;
esac])
AC_ARG_ENABLE(tests-timeout,
[ --enable-tests-timeout=NUM enable timeout (NUM seconds) for test programs
(NUM <= 9999) [[default=no]]; if enabled, env variable
$MPFR_TESTS_TIMEOUT overrides NUM (0: no timeout).],
[ case $enableval in
no) ;;
yes) AC_DEFINE([MPFR_TESTS_TIMEOUT], 0, [timeout limit]) ;;
[[0-9]]|[[0-9]][[0-9]]|[[0-9]][[0-9]][[0-9]]|[[0-9]][[0-9]][[0-9]][[0-9]])
AC_DEFINE_UNQUOTED([MPFR_TESTS_TIMEOUT], $enableval, [timeout limit]) ;;
*) AC_MSG_ERROR([bad value for --enable-tests-timeout]) ;;
esac])
dnl
dnl Setup CC and CFLAGS
dnl
dnl Check if user request its CC and CFLAGS
if test -n "$CFLAGS" || test -n "$CC" ; then
user_redefine_cc=yes
fi
dnl Autoconf detection
AC_PROG_CC
AC_LANG(C)
dnl Check for GMP CFLAGS and CC (More optimized for the target)
dnl But they may be invalid, so we must check them first
dnl Don't redefine it if the user force them!
if test -n "$GMP_CFLAGS" && test -z "$user_redefine_cc" ; then
old_cflags=$CFLAGS
old_cc=$CC
CFLAGS=$GMP_CFLAGS
CC=$GMP_CC
AC_MSG_CHECKING(for CC=$GMP_CC and CFLAGS=$GMP_CFLAGS)
AC_RUN_IFELSE(AC_LANG_PROGRAM([[/*hello*/]],[[/*world*/]]), [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
CFLAGS=$old_cflags
CC=$old_cc
], [
AC_MSG_RESULT([can't test])
CFLAGS=$old_cflags
CC=$old_cc
])
dnl CC may have change. Recheck for GCC.
GCC=
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifndef __GNUC__
# error "GCC Not Found"
error
#endif
]])], [
GCC=yes
])
fi
AC_ARG_ENABLE(decimal-float,
[ --enable-decimal-float build conversion functions from/to decimal floats [[default=no]]],
[ case $enableval in
yes) AC_DEFINE([MPFR_WANT_DECIMAL_FLOATS],1,
[Build decimal float functions])
AC_MSG_CHECKING(if compiler knows _Decimal64)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[_Decimal64 x;]])],
[AC_MSG_RESULT(yes)
if test "$use_gmp_build" != yes ; then
AC_MSG_ERROR([decimal float support requires --with-gmp-build])
fi
AC_MSG_CHECKING(if _GMP_IEEE_FLOATS is defined)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "gmp.h"
#include "gmp-impl.h"
#ifndef _GMP_IEEE_FLOATS
#error "_GMP_IEEE_FLOATS is not defined"
#endif]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)
AC_MSG_ERROR([decimal float support requires _GMP_IEEE_FLOATS])])
],
[AC_MSG_ERROR([Compiler doesn't know _Decimal64; try GCC >= 4.2, configured with --enable-decimal-float]
)])
AC_MSG_CHECKING(decimal float format)
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <stdlib.h>
]], [[
union { double d; _Decimal64 d64; } y;
y.d64 = 1234567890123456.0dd;
return y.d == 0.14894469406741037E-123 ? 0 :
y.d == 0.59075095508629822E-68 ? 1 : 2;
]])], [AC_MSG_RESULT(DPD)
AC_DEFINE([DPD_FORMAT],1,[])],
[if test "$?" != 1 ; then
AC_MSG_FAILURE(neither DPD nor BID)
fi
AC_MSG_RESULT(BID)],
[AC_MSG_RESULT(assuming DPD)
AC_DEFINE([DPD_FORMAT],1,[])])
;;
no) ;;
*) AC_MSG_ERROR([bad value for --enable-decimal-float: yes or no]) ;;
esac])
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? Don't use -pc64 !
AC_MSG_CHECKING(for ICC)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if !defined(__ICC)
# error "ICC Not Found"
error
#endif
]], [[]])],[
AC_MSG_RESULT(yes)
GCC=
CFLAGS="-fp_port -mp -wd1572 -wd265 -wd186 -wd239 $CFLAGS"
],[AC_MSG_RESULT(no)])
dnl If compiler is gcc, then use some specific flags.
dnl But don't touch user other flags.
if test "$test_CFLAGS" != set && test -n "$GCC"; then
CFLAGS="-Wall -Wmissing-prototypes $CFLAGS"
if test -n "$disable_gcc_format_warning" ; then
CFLAGS="$CFLAGS -Wno-format"
fi
fi
AM_C_PROTOTYPES
case $host in
*-apple-darwin*)
dnl This allows to take the first GMP library in the library paths,
dnl whether it is dynamic or static. This behavior is more sensible,
dnl in particular because it is the only way to link with a version
dnl only available in static form when another version is available
dnl in dynamic, and also for consistency, because the compiler will
dnl take the first gmp.h found in the include paths (so, we need to
dnl take a library that corresponds to this header file). This is a
dnl common problem with darwin.
MPFR_LD_SEARCH_PATHS_FIRST ;;
esac
AC_C_CONST
AC_C_VOLATILE
MPFR_CONFIGS
dnl
dnl Setup LIBTOOL
dnl
dnl Currently libtool always want to detect a C++ and fortran compiler
dnl Remove this by hacking a few: AC_PROG_CXX, AC_PROG_F77 are defined
dnl but they are never called. Set with_tag to ''
dnl Set am__fastdepCXX to something
dnl Remove this when Libtool >= 2.0 is used
if test -n "$variable_indefinie" ; then
AC_PROG_CXX([g++])
AC_PROG_F77([g77])
AC_PROG_CXXCPP
fi
am__fastdepCXX_FALSE='#'
if test "${with_tags+set}" != set; then
with_tags=
fi
dnl
dnl Setup GMP detection
dnl
dnl Check GMP Header
AC_MSG_CHECKING(for gmp.h)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "gmp.h"
]])],[AC_MSG_RESULT(yes)],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([gmp.h can't be found, or is unusable.])
])
dnl Configs for Windows DLLs.
dnl libtool requires "-no-undefined" for win32 dll
dnl It also disables the tests involving the linking with LIBGMP if DLL
AC_LIBTOOL_WIN32_DLL
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
AC_MSG_CHECKING(for DLL/static GMP)
if test "$enable_shared" = yes; then
LDFLAGS="$LDFLAGS -no-undefined"
dont_link_with_gmp="yes"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include "gmp.h"
#if !__GMP_LIBGMP_DLL
# error "Dead man"
error
#endif
]], [[]])],[AC_MSG_RESULT(DLL)],[
AC_MSG_RESULT(static)
AC_MSG_ERROR([gmp.h isn't a DLL: use --enable-static --disable-shared]) ])
else
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include "gmp.h"
#if __GMP_LIBGMP_DLL
# error "Dead man"
error
#endif
]], [[]])],[AC_MSG_RESULT(static)],[
AC_MSG_RESULT(DLL)
AC_MSG_ERROR([gmp.h is a DLL: use --disable-static --enable-shared]) ])
fi
;;
esac
dnl Finally set up LibTool
AC_PROG_LIBTOOL
dnl
dnl For mpfr-longlong.h - TODO: should be replaced (see acinclude.m4).
dnl
GMP_C_ATTRIBUTE_MODE
dnl
dnl Setup GMP detection (continued)
dnl
AC_MSG_CHECKING(for recent GMP)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "gmp.h"
#if (__GNU_MP_VERSION*100+__GNU_MP_VERSION_MINOR*10 < 410)
# error "min GMP version is 4.1.0"
error
#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_SOURCE([[
#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
]])],[
AC_MSG_RESULT(yes)
AC_DEFINE([MPFR_HAVE_GMP_IMPL],1,[Use GMP Internal Files])
gmp_internal_file_check=yes
],[
AC_MSG_RESULT(no)
AC_FUNC_ALLOCA
])
dnl Check for valid BITS_PER_MP_LIMB and BYTES_PER_MP_LIMB
dnl This test doesn't need to link with libgmp (at least it shouldn't).
if test -n "$gmp_internal_file_check" ; then
AC_MSG_CHECKING(for valid BITS_PER_MP_LIMB and BYTES_PER_MP_LIMB)
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <limits.h>
#include "gmp.h"
#include "gmp-impl.h"
]], [[
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.])],
[AC_MSG_RESULT([can't test])])
fi
dnl We really need to link using libtool. But it is impossible with the current
dnl libtool.
dnl The practical problems appear only under MS Windows since the library name
dnl is libgmp-3 (due to libtool versionning). The best solution
dnl is to believe it works under MS-Windows.
if test "$dont_link_with_gmp" = yes ; then
LIBS="-lgmp $LIBS"
else
dnl Check if we can link with GMP
AC_CHECK_LIB(gmp, __gmpz_init, [LIBS="-lgmp $LIBS"],
[AC_MSG_ERROR(libgmp not found or uses a different ABI.
Please read the INSTALL file -- see "In case of problem".)])
dnl Check for corresponding 'gmp.h' and libgmp.a
AC_MSG_CHECKING(if gmp.h version and libgmp version are the same)
dnl We do not set LD_LIBRARY_PATH, as it is not possible to set it just
dnl before the test program is run, and we do not want to affect other
dnl programs (such as the compiler), because the behavior could be
dnl incorrect and even have security implications.
saved_LD_RUN_PATH="$LD_RUN_PATH"
LD_RUN_PATH="${LD_RUN_PATH:+$LD_RUN_PATH$PATH_SEPARATOR}$gmp_lib_path"
export LD_RUN_PATH
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <string.h>
#include "gmp.h"
]], [[
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);
printf ("(%s/%s) ", buffer, gmp_version);
return (strcmp (buffer, gmp_version) != 0) ? 1 : 0;
]])], [AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_WARN(['gmp.h' and 'libgmp' seems to have different versions or])
AC_MSG_WARN([we cannot run a program linked with GMP (if you cannot])
AC_MSG_WARN([see the version numbers above).])
AC_MSG_WARN([However since we can't use 'libtool' inside the configure,])
AC_MSG_WARN([we can't be sure. See 'config.log' for details.])
],AC_MSG_RESULT([can not test])
)
LD_RUN_PATH="$saved_LD_RUN_PATH"
dnl End of tests which need to link with GMP.
fi
dnl Remove also many MACROS (AC_DEFINE) which are unused by MPFR
dnl and polluate (and slow down because libtool has to parse them) the build.
if test -f confdefs.h; then
sed '/#define PACKAGE_/d' <confdefs.h >confdefs.tmp
sed '/#define HAVE_STRING/d' <confdefs.tmp >confdefs.h
sed '/#define HAVE_ALLOCA /d' <confdefs.h >confdefs.tmp
sed '/#define HAVE_DLFCN_H/d' <confdefs.tmp >confdefs.h
sed '/#define HAVE_MEM/d' <confdefs.h >confdefs.tmp
sed '/#define STDC_HEADERS/d' <confdefs.tmp >confdefs.h
sed '/#define HAVE_STRTOL/d' <confdefs.h >confdefs.tmp
sed '/#define HAVE_STDLIB_H/d' <confdefs.tmp >confdefs.h
sed '/#define HAVE_UNISTD_H/d' <confdefs.h >confdefs.tmp
sed '/#define HAVE_STDC_HEADERS/d' <confdefs.tmp >confdefs.h
sed '/#define HAVE_LONG_DOUBLE/d' <confdefs.h >confdefs.tmp
sed '/#define HAVE_SYS_STAT_H/d' <confdefs.tmp >confdefs.h
sed '/#define HAVE_SYS_TYPES_H/d' <confdefs.h >confdefs.tmp
sed '/#define PROTOTYPES/d' <confdefs.tmp >confdefs.h
sed '/#define __PROTOTYPES/d' <confdefs.h >confdefs.tmp
mv confdefs.tmp confdefs.h
fi
dnl Output
AC_CONFIG_FILES([Makefile tests/Makefile mparam.h:mparam_h.in])
AC_OUTPUT
dnl NEWS README AUTHORS Changelog
|