-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
257 lines (248 loc) · 6.78 KB
/
configure.ac
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
AC_INIT([Fortran MPFR biding], 0.1,,[libfmpfr])
AC_CONFIG_SRCDIR(src/fmpfr_kinds.f90.in)
AC_CONFIG_FILES([
Makefile
src/fmpfr_kinds.f90
src/Makefile
test/Makefile
])
AM_INIT_AUTOMAKE([foreign])
AC_LANG_C
AC_PROG_CC
AC_PROG_FC
AC_CHECK_TOOL(AR, ar)
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_CHECK_HEADER(mpfr.h,,[AC_MSG_ERROR([Cannot find mpfr.h])])
AC_CHECK_LIB([mpfr],[mpfr_add],,[AC_MSG_ERROR([mpfr not usable])])
AC_CHECK_HEADER(gmp.h,,[AC_MSG_ERROR([Cannot find gmp.h])])
AC_CHECK_LIB([gmp],[__gmpz_init],,[AC_MSG_ERROR([gmp not usable])])
AC_MSG_CHECKING([for mp_limb_t])
mpfr_limb_t="c_long"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>
#include <mpfr.h>
#if !defined(__GMP_SHORT_LIMB)
#error
#endif
]])],[mpfr_limb_t=c_int])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>
#include <mpfr.h>
#if !defined(_LONG_LONG_LIMB)
#error
#endif
]])],[mpfr_limb_t=c_long_long])
AC_MSG_RESULT($mpfr_limb_t)
AC_SUBST(mpfr_limb_t)
AC_MSG_CHECKING([for mpfr_prec_t])
mpfr_prec_t="none"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>
#include <mpfr.h>
#if _MPFR_PREC_FORMAT != 2
#error
#endif
]])],[mpfr_prec_t=c_int])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>
#include <mpfr.h>
#if _MPFR_PREC_FORMAT != 3
#error
#endif
]])],[mpfr_prec_t=c_long])
if test "$mpfr_prec_t" == "none"; then
AC_MSG_ERROR("Cannot determine mpfr_prec_t")
else
AC_MSG_RESULT($mpfr_prec_t)
AC_SUBST(mpfr_prec_t)
fi
AC_MSG_CHECKING([for mpfr_exp_t])
mpfr_exp_t="none"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>
#include <mpfr.h>
#if _MPFR_EXP_FORMAT != 1
#error
#endif
]])],[mpfr_exp_t=c_short])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>
#include <mpfr.h>
#if _MPFR_EXP_FORMAT != 2
#error
#endif
]])],[mpfr_exp_t=c_int])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>
#include <mpfr.h>
#if _MPFR_EXP_FORMAT != 3
#error
#endif
]])],[mpfr_exp_t=c_long])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>
#include <mpfr.h>
#if _MPFR_EXP_FORMAT != 4
#error
#endif
]])],[mpfr_exp_t=c_long])
if test "$mpfr_exp_t" == "none"; then
AC_MSG_ERROR("Cannot determine mpfr_exp_t")
else
AC_MSG_RESULT($mpfr_exp_t)
AC_SUBST(mpfr_exp_t)
fi
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([long])
AC_FC_PP_SRCEXT([F90])
# AC_SUBST(ac_cv_fc_pp_srcext_F90)
if test "$ac_cv_fc_pp_srcext_F90" == "none"; then
fc_preprocessor_flag=""
else
fc_preprocessor_flag="$ac_cv_fc_pp_srcext_F90"
fi
AC_SUBST(fc_preprocessor_flag)
AC_FC_PP_DEFINE
fc_preflags="$ac_cv_fc_pp_define""SIZEOF_INT=$ac_cv_sizeof_int $ac_cv_fc_pp_define""SIZEOF_LONG=$ac_cv_sizeof_long"
AC_MSG_CHECKING([if __float128 is supported])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
__float128 foo (__float128 x)
{
__float128 a, b;
a = x/7.Q;
b = a + a *2.3e10Q;
}
]],[[foo(1.2Q)]])],
[
have_float128=yes
],[
have_float128=no
]
)
AC_MSG_RESULT([$have_float128])
mpfr_have_float128="no"
if test "$have_float128" = "yes"; then
AC_MSG_CHECKING([if mpfr has __float128 support])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#define MPFR_WANT_FLOAT128 1
#include <mpfr.h>
],
[
mpfr_t a;
__float128 x;
x = 3.7Q;
mpfr_set_float128 (a, x, MPFR_RNDN)
])],[mpfr_have_float128="yes"])
AC_MSG_RESULT([$mpfr_have_float128])
fi
AC_LANG_PUSH([Fortran])
AC_MSG_CHECKING([if derived-type I/O is supported])
AC_COMPILE_IFELSE([
module x
implicit none
type, public:: foo
character(len=2) :: c
end type foo
interface read(formatted)
module procedure read_formatted
end interface read(formatted)
contains
subroutine read_formatted (dtv, unit, iotype, vlist, iostat,
& iomsg)
class (foo), intent(inout) :: dtv
integer, intent(in) :: unit
character (len=*), intent(in) :: iotype
integer, intent(in) :: vlist(:)
integer, intent(out) :: iostat
character (len=*), intent(inout) :: iomsg
read (unit,'(A)',iostat=iostat,iomsg=iomsg) dtv%c
end subroutine read_formatted
end module x
program main
use x
implicit none
type(foo) :: a, b
open (10,file="testfile.dat",status="replace")
write (10,'(A)') '','aa bb'
rewind (10)
a%c = "x"
b%c = "y"
read (10,*) a, b
if (a%c .eq. "aa" .and. b%c .eq. "bb") then
close (10,status="delete")
else
close (10,status="keep")
end if
end program main
],
[derived_io=yes],[derived_io=no])
AC_MSG_RESULT([$derived_io])
if test "$derived_io" == "yes"; then
fc_preflags="$fc_preflags $ac_cv_fc_pp_define""USE_DERIVED_IO=1"
fi
AC_MSG_CHECKING([if the Fortran compiler supports finalization])
AC_COMPILE_IFELSE([
module x
type foo
integer :: a
contains
final :: cleanup
end type foo
contains
subroutine cleanup(self)
type(foo), intent(inout) :: self
self%a = 0
end subroutine cleanup
end module x
],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([Finalization not supported])])
AC_MSG_CHECKING([if the Fortran compiler supports -I])
save_FCFLAGS=$FCFLAGS
AC_COMPILE_IFELSE([
error stop
end
],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([-I not supported.])])
FCFLAGS=$save_FCFLAGS
AC_MSG_CHECKING([if Fortran supports ERROR STOP])
AC_COMPILE_IFELSE([
error stop
end
],[AC_MSG_RESULT([yes])],AC_MSG_ERROR([ERROR STOP required for testsuite for now]))
AC_MSG_CHECKING([if Fortran supports IEEE 128-bit])
AC_COMPILE_IFELSE([
integer, parameter :: qp = selected_real_kind(33,4000)
real(kind=qp) :: a
end
],[fortran_have_ieee128=yes],[fortran_have_ieee128=no])
AC_MSG_RESULT([$fortran_have_ieee128])
if test "$fortran_have_ieee128""$mpfr_have_float128" == yesyes; then
fc_preflags="$fc_preflags $ac_cv_fc_pp_define""USE_FLOAT128=1"
CFLAGS="$CFLAGS -DUSE_FLOAT128=1"
fi
AC_MSG_CHECKING([if c_long_double is useful])
AC_COMPILE_IFELSE([
module x
use iso_c_binding
interface inter
module procedure f_d, f_l
end interface inter
contains
subroutine f_d(arg)
real(kind=c_double) :: arg
end subroutine f_d
subroutine f_l(arg)
real(kind=c_long_double) :: arg
end subroutine f_l
end module x
],[fortran_use_c_long_double=yes],[fortarn_use_c_long_double=no])
AC_MSG_RESULT([$fortran_use_c_long_double])
if test x"$fortran_use_c_long_double" == xyes; then
fc_preflags="$fc_preflags $ac_cv_fc_pp_define""USE_LONG_DOUBLE=1"
CFLAGS="$CFLAGS -DUSE_LONG_DOUBLE=1"
fi
AC_SUBST(use_float128)
AC_LANG_POP([Fortran])
AC_ARG_WITH([default-precision],
[AS_HELP_STRING([--with-default-precision],
[default-precision (default is 113)])],
[default_precision=$withval],
[default_precision=113])
AC_SUBST(default_precision)
AC_MSG_CHECKING([flags to pass for Fortran files to be preprocessed])
AC_MSG_RESULT([$fc_preflags])
AC_SUBST(fc_preflags)
AC_MSG_NOTICE([Default preicision is $default_precision])
AC_OUTPUT
rm -f x.mod