-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
332 lines (283 loc) · 11.7 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
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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([FXPF_v1_asilomar], [1], [[email protected]])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.6 no-define dist-zip dist-bzip2])
###############################################################################
# Checks for programs.
###############################################################################
AC_PROG_CC
AC_PROG_CXX
AM_PROG_LIBTOOL
#------------------------------------------------------------------------------
# withs...
#------------------------------------------------------------------------------
SO_LIB_PATH=""
AC_ARG_WITH(gmp-include,
[ --with-gmp-include=DIR GMP include directory ],
[if test "x$withval" != "xyes" -a "x$withval" != "x"
then
AM_CPPFLAGS="$AM_CPPFLAGS -I$withval"
fi])
AC_ARG_WITH(gmp-lib,
[ --with-gmp-lib=DIR GMP lib directory ],
[if test "x$withval" != "xyes" -a "x$withval" != "x"
then
AM_LDFLAGS="$AM_LDFLAGS -L$withval"
SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval"
fi
])
AC_ARG_WITH(gmp,
[ --with-gmp=DIR GMP install directory ],
[if test "x$withval" != "xyes" -a "x$withval" != "x"
then
AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include"
AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval/lib"
fi
])
AC_ARG_WITH(mpfr-include,
[ --with-mpfr-include=DIR MPFR include directory ],
[if test "x$withval" != "xyes" -a "x$withval" != "x"
then
AM_CPPFLAGS="$AM_CPPFLAGS -I$withval"
fi])
AC_ARG_WITH(mpfr-lib,
[ --with-mpfr-lib=DIR MPFR lib directory ],
[if test "x$withval" != "xyes" -a "x$withval" != "x"
then
AM_LDFLAGS="$AM_LDFLAGS -L$withval"
SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval"
fi
])
AC_ARG_WITH(mpfr,
[ --with-mpfr=DIR MPFR install directory ],
[if test "x$withval" != "xyes" -a "x$withval" != "x"
then
AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include"
AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval/lib"
fi
])
AC_ARG_WITH(mpfi-include,
[ --with-mpfi-include=DIR MPFI include directory ],
[if test "x$withval" != "xyes" -a "x$withval" != "x"
then
AM_CPPFLAGS="$AM_CPPFLAGS -I$withval"
fi])
AC_ARG_WITH(mpfi-lib,
[ --with-mpfi-lib=DIR MPFI lib directory ],
[if test "x$withval" != "xyes" -a "x$withval" != "x"
then
AM_LDFLAGS="$AM_LDFLAGS -L$withval"
SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval"
fi
])
AC_ARG_WITH(mpfi,
[ --with-mpfi=DIR MPFI install directory ],
[if test "x$withval" != "xyes" -a "x$withval" != "x"
then
AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include"
AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval/lib"
fi
])
#------------------------------------------------------------------------------
# Save user flags and set flags given by configure for the rest of the tests
#------------------------------------------------------------------------------
USER_CFLAGS="$CFLAGS -std=c99"
USER_CPPFLAGS="$CPPFLAGS"
USER_LDFLAGS="$LDFLAGS"
CFLAGS="$AM_CFLAGS $USER_CFLAGS"
CPPFLAGS="$AM_CPPFLAGS $USER_CPPFLAGS"
LDFLAGS="$AM_LDFLAGS $USER_LDFLAGS"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$SO_LIB_PATH"
###############################################################################
# Checks for header files.
###############################################################################
AC_CHECK_HEADER_STDBOOL
AC_CHECK_HEADERS([stding.h float.h sys/time.h])
#------------------------------------------------------------------------------
#Check for any of blas.h, cblas.h or blaswrap.h header files
#------------------------------------------------------------------------------
BLAS_FLAG="no"
#Check for BLAS headers
ADD_LBLAS="yes"
AC_CHECK_HEADERS([blas.h], [ADD_LBLAS="yes" BLAS_FLAG="yes" AC_DEFINE([BLAS_HEADER], [1], [Define to 1 if blas.h found])], [ADD_LBLAS="no"],
[[#ifdef HAVE_F2C_H
# include <f2c.h>
#endif
]])
if test "x${ADD_LBLAS}" = "xyes"
then
AC_MSG_NOTICE([blas.h is successfully found.])
fi
#Check for CBLAS headers
ADD_LCBLAS="yes"
AC_CHECK_HEADERS([cblas.h], [ADD_LCBLAS="yes" BLAS_FLAG="yes" AC_DEFINE([CBLAS_HEADER], [1], [Define to 1 if cblas.h found])], [ADD_LCBLAS="no"],
[[#ifdef HAVE_F2C_H
# include <f2c.h>
#endif
]])
if test "x${ADD_LCBLAS}" = "xyes"
then
AC_MSG_NOTICE([cblas.h is successfully found.])
fi
#Check for BLASWRAP headers
ADD_LBLASWRAP="yes"
AC_CHECK_HEADERS([blaswrap.h], [ADD_LBLASWRAP="yes" BLAS_FLAG="yes"], [ADD_LBLASWRAP="no"],
[[#ifdef HAVE_F2C_H
# include <f2c.h>
#endif
]])
if test "x${ADD_LBLASWRAP}" = "xyes"
then
AC_MSG_NOTICE([blaswrap.h is successfully found.])
fi
if test "x${BLAS_FLAG}"="xyes"
then
AC_MSG_NOTICE([At least one blas header file was found is successfully found.])
else
AC_MSG_ERROR([No blas header file found.])
fi
#------------------------------------------------------------------------------
#Checking for any of clapack.h lapack.h lapacke.h header files
#------------------------------------------------------------------------------
ADD_FLAG="no"
#Check for clapack.h headers
ADD_LCLAPACK="yes"
AC_CHECK_HEADERS([clapack.h], [ADD_LCLAPACK="yes" ADD_FLAG="yes" AC_DEFINE([CLAPACK_HEADER], [1], [Define to 1 if clapack.h found])], [ADD_LCLAPACK="no"],
[[#ifdef HAVE_BLAS_H
# include <f2c.h>
# include <blas.h>
#endif
]])
if test "x${ADD_LCLAPACK}" = "xyes"
then
AC_MSG_NOTICE([clapack.h is successfully found.])
fi
#Check for lapacke.h headers
ADD_LLAPACKE="yes"
AC_CHECK_HEADERS([lapacke.h], [ADD_LLAPACKE="yes" ADD_FLAG="yes" AC_DEFINE([LAPACKE_HEADER], [1], [Define to 1 if lapacke.h found])], [ADD_LLAPACKE="no"],
[[#ifdef HAVE_BLAS_H
# include <f2c.h>
# include <blas.h>
#endif
]])
if test "x${ADD_LLAPACKE}" = "xyes"
then
AC_MSG_NOTICE([ADD_LLAPACKE is successfully found.])
fi
#Check for lapack.h headers
ADD_LLAPACK="yes"
AC_CHECK_HEADERS([lapack.h], [ADD_LLAPACK="yes" ADD_FLAG="yes" AC_DEFINE([LAPACK_HEADER], [1], [Define to 1 if lapack.h found])], [ADD_LLAPACK="no"],
[[#ifdef HAVE_BLAS_H
# include <f2c.h>
# include <blas.h>
#endif
]])
if test "x${ADD_FLAG}"="xyes"
then
AC_MSG_NOTICE([At least one lapack header file found.])
else
AC_MSG_ERROR([No clapack header file found.])
fi
###############################################################################
# Checks for libraries.
###############################################################################
AC_CHECK_LIB([gmp], [__gmpz_init], [true], AC_MSG_ERROR([libgmp unusable]))
AC_CHECK_LIB([gmp], [__gmpz_fac_ui], [true], AC_MSG_ERROR([libgmp version too old]))
AC_CHECK_LIB([gmp], [__gmpz_bin_uiui], [true], AC_MSG_ERROR([libgmp version too old]))
AC_CHECK_LIB([gmp], [__gmpz_export], [], AC_MSG_ERROR([libgmp version too old])) # This one adds -lgmp in case of success
AC_CHECK_LIB([mpfr], [mpfr_init], [true], AC_MSG_ERROR([libmpfr unusable]))
AC_CHECK_LIB([m], [pow], [], AC_MSG_ERROR([libm is unusable]))
AC_CHECK_LIB([wcpg], [WCPG_ABCD], [], AC_MSG_ERROR([WCPGlib is unusable]))
AC_CHECK_LIB([mpfr], [mpfr_erfc], [], AC_MSG_ERROR([libmpfr version too old])) # This one adds -lmpfr in case of success
AC_CHECK_LIB([mpfi], [mpfi_init], [], AC_MSG_ERROR([libmpfi unusable]))
FLAG="no"
AC_CHECK_LIB([blas],[dgemv],[FLAG="yes" BLAS_LIBS="-lblas"], AC_MSG_WARN([Missing blas but maybe cblas is installed]))
AC_CHECK_LIB([blas],[cblas_dgemv],[FLAG="yes" BLAS_LIBS="-lblas"])
if test "x${FLAG}" != "xyes"
then
AC_MSG_ERROR([Missing (c)blas, function dgemv not found])
fi
FLAG="no"
AC_CHECK_LIB([lapacke],[LAPACKE_zgetri],[LAPACK_LIBS="-llapacke" FLAG="yes"], AC_MSG_WARN([Missing lapacke but maybe lapack is installed]))
AC_CHECK_LIB([lapack],[zgetri_],[FLAG="yes" LAPACK_LIBS="-llapack"], AC_MSG_WARN([Missing lapack]))
if test "x${FLAG}" != "xyes"
then
AC_MSG_ERROR([Missing clapack/lapacke, function zgetri_/LAPACKE_zgetri not found])
fi
FLAG="no"
AC_CHECK_LIB([lapacke],[LAPACKE_dgeevx],[FLAG="yes" LAPACK_LIBS="-llapacke"], AC_MSG_WARN([Missing lapacke but maybe lapack is installed]))
AC_CHECK_LIB([lapack],[dgeevx_],[FLAG="yes" LAPACK_LIBS="-llapack"], AC_MSG_WARN([Missing lapack]))
if test "x${FLAG}" != "xyes"
then
AC_MSG_ERROR([Missing clapack/lapacke, function dgeevx_/LAPACKE_dgeevx not found])
fi
FLAG="no"
AC_CHECK_LIB([lapacke],[LAPACKE_zgetrf],[FLAG="yes" LAPACK_LIBS="-llapacke"], AC_MSG_WARN([Missing lapacke but maybe lapack is installed]))
AC_CHECK_LIB([lapack],[zgetrf_],[FLAG="yes" LAPACK_LIBS="-llapack"], AC_MSG_WARN([Missing lapack]))
if test "x${FLAG}" != "xyes"
then
AC_MSG_ERROR([Missing clapack/lapacke, function zgetrf_/LAPACKE_zgetrf not found])
fi
# Check that dynamic libraries are available at runtime
AC_MSG_CHECKING([if libgmp is found at runtime])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]],
[[mpz_t a; mpz_init(a); mpz_clear(a); return 0;]])],
[AC_MSG_RESULT(yes)],
[AC_MSG_WARN([libgmp is found at compile time but not at run time. Checking /etc/ld.so.conf and running ldconfig could fix the problem.])])
AC_MSG_CHECKING([if libmpfr is found at runtime])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <mpfr.h>]],
[[mpfr_t a; mpfr_init2(a, 53); mpfr_clear(a); return 0;]])],
[AC_MSG_RESULT(yes)],
[AC_MSG_WARN([libmpfr is found at compile time but not at run time. Checking /etc/ld.so.conf and running ldconfig could fix the problem.])])
AC_MSG_CHECKING([if libmpfi is found at runtime])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <mpfi.h>]],
[[mpfi_t a; mpfi_init(a); mpfi_clear(a); return 0;]])],
[AC_MSG_RESULT(yes)],
[AC_MSG_ERROR([libmpfi is found at compile time but not at run time. Checking /etc/ld.so.conf and running ldconfig could fix the problem.])])
#Check for -Wl,-export-dynamic etc.
CFLAGS="$AM_CFLAGS -fPIC $USER_CFLAGS"
AC_MSG_CHECKING([for -fPIC support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[
AC_MSG_RESULT(yes)
AM_CFLAGS="$AM_CFLAGS -fPIC"
],
[
AC_MSG_RESULT(no)
CFLAGS="$AM_CFLAGS $USER_CFLAGS"
])
###############################################################################
# Checks for typedefs, structures, and compiler characteristics.
###############################################################################
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_C_INLINE
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_SIZE_T
###############################################################################
# Checks for library functions.
###############################################################################
AC_CHECK_FUNCS([gettimeofday])
AC_CHECK_FUNCS([sqrt])
AC_CHECK_FUNCS([ceil])
AC_FUNC_MALLOC
AC_FUNC_REALLOC
#return to user flags
CPPFLAGS="$USER_CPPFLAGS"
CFLAGS="$USER_CFLAGS"
LDFLAGS="$USER_LDFLAGS"
AC_SUBST(AM_CPPFLAGS)
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_LDFLAGS)
AC_SUBST(BLAS_LIBS)
AC_SUBST(LAPACK_LIBS)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT