-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
234 lines (195 loc) · 7.27 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
## This file is part of qfratio
##
## This is for a configure script to generate src/config.h
## which defines necessary macros for Eigen and GSL.
##
## Run autoreconf to (re-)generate configure and src/config.h.in
## (or autoconf to generate configure and autoheader to generate config.h.in)
##
## GSL-related parts in this file were taken from configure.ac in
## GSL version 2.8.
## The original line numbers are specified at the top of each chunk.
##
## Copyright (C) 2023-2024 Junya Watanabe
## (C) ND Free Software Foundation, Inc. (for GSL-originated part)
## Licensed under the GNU GPL (>=3). See LISENSE.md
AC_INIT([qfratio], [1.1.1.9000], [https://github.com/watanabe-j/qfratio/issues])
AC_CONFIG_SRCDIR([R/qfratio-package.R])
## config.guess and config.sub necessary for AC_CANONICAL_HOST below
## These are in tools/ as recommended in 'Writing R Extensions'
## Run src/scripts/get_config_aux.sh to download the latest versions
AC_CONFIG_AUX_DIR(tools)
#####
## Use the same C compiler used in R, from 'Writing R Extensions'
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "could not determine R_HOME"
exit 1
fi
CC=`"${R_HOME}/bin/R" CMD config CC`
CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS`
dnl #####
dnl ## Use the same C++ compiler used in R, from 'Writing R Extensions'
dnl ## This is unnecessary because configure only concerns C
dnl CXX=`"${R_HOME}/bin/R" CMD config CXX`
dnl if test -z "$CXX"; then
dnl AC_MSG_ERROR([No C++ compiler is available])
dnl fi
dnl CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
dnl CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
dnl dnl AC_LANG(C++)
#####
## Get host system type for HAVE_EXTENDED_PRECISION_REGISTERS
AC_CANONICAL_HOST
AC_LANG(C)
AC_PROG_CC
dnl AC_PROG_CPP
AC_SUBST(CFLAGS)
AC_SUBST(LIBM)
#####
## Check availability of inline;
## HAVE_INLINE required to define gsl_poly_eval()
## From lines 136-166 in configure.ac from GSL
if test "$ac_cv_c_inline" != no ; then
dnl Check for "extern inline", using a modified version of the test
dnl for AC_C_INLINE from acspecific.mt
dnl
AC_CACHE_CHECK([for GNU-style extern inline], ac_cv_c_extern_inline,
[ac_cv_c_extern_inline=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern $ac_cv_c_inline double foo(double x);
extern $ac_cv_c_inline double foo(double x) { return x + 1.0 ; } ;
double foo (double x) { return x + 1.0 ; };]], [[ foo(1.0) ]])],[ac_cv_c_extern_inline="yes"],[])
])
if test "$ac_cv_c_extern_inline" != no ; then
AC_DEFINE(HAVE_INLINE,[1],[Define if you have inline])
else
AC_CACHE_CHECK([for C99-style inline], ac_cv_c_c99inline,
[ac_cv_c_c99inline=no
dnl next line is a necessary condition
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern inline void* foo() { foo(); return &foo ; };]],
[[ return foo() != 0 ]])],[ac_cv_c_c99inline="yes"],[])
dnl but not sufficient, extern must work but inline on its own should not
if test "$ac_cv_c_c99inline" != no ; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[inline void* foo() { foo(); return &foo ; };]],
[[ return foo() != 0 ]])],[],ac_cv_c_c99inline="no")
fi
])
if test "$ac_cv_c_c99inline" != no ; then
AC_DEFINE(HAVE_INLINE,[1],[Define if you have inline])
AC_DEFINE(HAVE_C99_INLINE,[1],[Define if you have inline with C99 behavior])
fi
fi
fi
#####
## Use libm; necessary to compile the check code for
## IEEE comparisons (with exp()) below
## From lines 217-221 in configure.ac from GSL
dnl Use alternate libm if specified by user
if test "x$LIBS" = "x" ; then
AC_CHECK_LIB(m, cos)
fi
#####
## Check for HAVE_DECL_ISFINITE, HAVE_DECL_FINITE, and HAVE_DECL_ISNAN;
## HAVE_DECL_ISFINITE, HAVE_DECL_FINITE or HAVE_IEEE_COMPARISONS required
## to define gsl_finite();
## HAVE_DECL_ISNAN or HAVE_IEEE_COMPARISONS required to define gsl_isnan()
## From lines 237-242 in configure.ac from GSL
AC_CHECK_DECLS(isfinite,,,[#include <math.h>])
AC_CHECK_DECLS(finite,,,[#include <math.h>
#if HAVE_IEEEFP_H
#include <ieeefp.h>
#endif])
AC_CHECK_DECLS(isnan,,,[#include <math.h>])
#####
## HAVE_EXTENDED_PRECISION_REGISTERS influences the definition of
## GSL_COERCE_DBL(), which is used in gsl_sf_multiply_e()
## From lines 270-301 in configure.ac from GSL
AC_CACHE_CHECK([for extended floating point registers],ac_cv_c_extended_fp,
[case "$host" in
*sparc*-*-*)
ac_cv_c_extended_fp=no
;;
*powerpc*-*-*)
ac_cv_c_extended_fp=no
;;
*hppa*-*-*)
ac_cv_c_extended_fp=no
;;
*alpha*-*-*)
ac_cv_c_extended_fp=no
;;
*68k*-*-*)
ac_cv_c_extended_fp=yes
;;
*86-*-*)
ac_cv_c_extended_fp=yes
;;
x86_64-*-*)
ac_cv_c_extended_fp=yes
;;
*)
ac_cv_c_extended_fp=unknown
;;
esac
])
if test $ac_cv_c_extended_fp != "no" ; then
AC_DEFINE(HAVE_EXTENDED_PRECISION_REGISTERS,1,[Defined on architectures with excess floating-point precision])
fi
#####
## Check for HAVE_IEEE_COMPARISONS; see above for where this is used
## From lines 442-459 in configure.ac from GSL
dnl Check IEEE comparisons, whether "x != x" is true for NaNs
dnl
AC_CACHE_CHECK([for IEEE comparisons], ac_cv_c_ieee_comparisons,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <math.h>
int main (void)
{
int status; double inf, nan;
inf = exp(1.0e10);
nan = inf / inf ;
status = (nan == nan);
return status;
}]])],[ac_cv_c_ieee_comparisons="yes"],[ac_cv_c_ieee_comparisons="no"],[ac_cv_c_ieee_comparisons="yes"])
])
if test "$ac_cv_c_ieee_comparisons" != no ; then
AC_DEFINE(HAVE_IEEE_COMPARISONS,1,[Define this if IEEE comparisons work correctly (e.g. NaN != NaN)])
fi
dnl #####
dnl ## To handle inline functions in some compilers
dnl ## From lines 481 in configure.ac from GSL
AH_TEMPLATE([HIDE_INLINE_STATIC],[Define if you need to hide the static definitions of inline functions])
dnl #####
dnl ## To define GSL_COERCE_DBL() in config.h
dnl ## From lines 508-526 in configure.ac from GSL
AH_BOTTOM([/* Define a rounding function which moves extended precision values
out of registers and rounds them to double-precision. This should
be used *sparingly*, in places where it is necessary to keep
double-precision rounding for critical expressions while running in
extended precision. For example, the following code should ensure
exact equality, even when extended precision registers are in use,
double q = GSL_COERCE_DBL(3.0/7.0) ;
if (q == GSL_COERCE_DBL(3.0/7.0)) { ... } ;
It carries a penalty even when the program is running in double
precision mode unless you compile a separate version of the
library with HAVE_EXTENDED_PRECISION_REGISTERS turned off. */
#if HAVE_EXTENDED_PRECISION_REGISTERS
#define GSL_COERCE_DBL(x) (gsl_coerce_double(x))
#else
#define GSL_COERCE_DBL(x) (x)
#endif])
dnl #####
dnl ## To define RETURN_IF_NULL() in config.h
dnl ## From lines 588-589 in configure.ac from GSL
AH_BOTTOM([#define RETURN_IF_NULL(x) if (!x) { return ; }
])
dnl #####
dnl ## To add user-defined methods in Eigen classes in config.h
AH_TOP([// To add user-defined methods in Eigen classes
#ifndef EIGEN_ARRAYBASE_PLUGIN
#define EIGEN_ARRAYBASE_PLUGIN "ArrayBaseAddons.h"
#endif
])
AC_CONFIG_HEADERS([src/config.h])
AC_OUTPUT