forked from lballabio/QuantLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acinclude.m4
321 lines (296 loc) · 10.6 KB
/
acinclude.m4
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
# QL_CHECK_LONG_LONG
# ----------------------------------------------
# Check whether long long is supported.
AC_DEFUN([QL_CHECK_LONG_LONG],
[AC_MSG_CHECKING([long long support])
AC_TRY_COMPILE(
[],
[long long i;
unsigned long long j;
],
[AC_MSG_RESULT([yes])
AC_DEFINE([QL_HAVE_LONG_LONG],[],
[Define this if your compiler supports the long long type.])
],
[AC_MSG_RESULT([no])
])
])
# QL_CHECK_ASINH
# ----------------------------------------------
# Check whether the asinh function is defined in cmath.
# It defines QL_HAVE_ASINH if found.
AC_DEFUN([QL_CHECK_ASINH],
[AC_MSG_CHECKING([for asinh])
AC_TRY_COMPILE(
[@%:@include<cmath>],
[double x = asinh(0.0);],
[AC_MSG_RESULT([yes])
AC_DEFINE([QL_HAVE_ASINH],[],
[Define this if your compiler defines asinh in <cmath>.])
],
[AC_MSG_RESULT([no])
])
])
# QL_CHECK_BOOST_DEVEL
# --------------------
# Check whether the Boost headers are available
AC_DEFUN([QL_CHECK_BOOST_DEVEL],
[AC_MSG_CHECKING([for Boost development files])
AC_TRY_COMPILE(
[@%:@include <boost/version.hpp>
@%:@include <boost/shared_ptr.hpp>
@%:@include <boost/assert.hpp>
@%:@include <boost/current_function.hpp>],
[],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Boost development files not found])
])
])
# QL_CHECK_BOOST_VERSION
# ----------------------
# Check whether the Boost installation is up to date
AC_DEFUN([QL_CHECK_BOOST_VERSION],
[AC_MSG_CHECKING([for Boost version >= 1.43])
AC_REQUIRE([QL_CHECK_BOOST_DEVEL])
AC_TRY_COMPILE(
[@%:@include <boost/version.hpp>],
[@%:@if BOOST_VERSION < 104300
@%:@error too old
@%:@endif],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([outdated Boost installation])
])
])
# QL_CHECK_BOOST_VERSION_1_58_OR_HIGHER
# ----------------------
# Check whether the Boost installation is version 1.58
AC_DEFUN([QL_CHECK_BOOST_VERSION_1_58_OR_HIGHER],
[AC_MSG_CHECKING([for Boost version >= 1.58])
AC_REQUIRE([QL_CHECK_BOOST_DEVEL])
AC_TRY_COMPILE(
[@%:@include <boost/version.hpp>],
[@%:@if BOOST_VERSION < 105800
@%:@error too old
@%:@endif],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Boost version 1.58 or higher is required for the thread-safe observer pattern])
])
])
# QL_CHECK_BOOST_VERSION_1_59_OR_HIGHER
# ----------------------
# Check whether the Boost installation is version 1.59
AC_DEFUN([QL_CHECK_BOOST_VERSION_1_59_OR_HIGHER],
[AC_MSG_CHECKING([for Boost version >= 1.59])
AC_REQUIRE([QL_CHECK_BOOST_DEVEL])
AC_TRY_COMPILE(
[@%:@include <boost/version.hpp>],
[@%:@if BOOST_VERSION < 105900
@%:@error too old
@%:@endif],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Boost version 1.59 or higher is required for the parallel unit test runner.])
])
])
# QL_CHECK_BOOST_UBLAS
# --------------------
# Check whether the Boost headers are available
AC_DEFUN([QL_CHECK_BOOST_UBLAS],
[AC_MSG_CHECKING([for Boost::uBLAS support])
AC_TRY_COMPILE(
[@%:@include <boost/numeric/ublas/vector_proxy.hpp>
@%:@include <boost/numeric/ublas/triangular.hpp>
@%:@include <boost/numeric/ublas/lu.hpp>],
[],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_WARN([Some functionality will be disabled.])
AC_DEFINE([QL_NO_UBLAS_SUPPORT],[],
[Define this if your compiler does not support Boost::uBLAS.])
])
])
# QL_CHECK_BOOST_UNIT_TEST
# ------------------------
# Check whether the Boost unit-test framework is available
AC_DEFUN([QL_CHECK_BOOST_UNIT_TEST],
[AC_MSG_CHECKING([for Boost unit-test framework])
AC_REQUIRE([AC_PROG_CC])
ql_original_LIBS=$LIBS
ql_original_CXXFLAGS=$CXXFLAGS
CC_BASENAME=`basename $CC`
CC_VERSION=`echo "__GNUC__ __GNUC_MINOR__" | $CC -E -x c - | tail -n 1 | $SED -e "s/ //"`
for boost_lib in boost_unit_test_framework-$CC_BASENAME$CC_VERSION \
boost_unit_test_framework-$CC_BASENAME \
boost_unit_test_framework \
boost_unit_test_framework-mt-$CC_BASENAME$CC_VERSION \
boost_unit_test_framework-$CC_BASENAME$CC_VERSION-mt \
boost_unit_test_framework-x$CC_BASENAME$CC_VERSION-mt \
boost_unit_test_framework-mt-$CC_BASENAME \
boost_unit_test_framework-$CC_BASENAME-mt \
boost_unit_test_framework-mt ; do
LIBS="$ql_original_LIBS -l$boost_lib"
# 1.33.1 or 1.34 static
CXXFLAGS="$ql_original_CXXFLAGS"
boost_unit_found=no
AC_LINK_IFELSE([AC_LANG_SOURCE(
[@%:@include <boost/test/unit_test.hpp>
using namespace boost::unit_test_framework;
test_suite*
init_unit_test_suite(int argc, char** argv)
{
return (test_suite*) 0;
}
])],
[boost_unit_found=$boost_lib
boost_defines=""
break],
[])
# 1.34 shared
CXXFLAGS="$ql_original_CXXFLAGS -DBOOST_TEST_MAIN -DBOOST_TEST_DYN_LINK"
boost_unit_found=no
AC_LINK_IFELSE([AC_LANG_SOURCE(
[@%:@include <boost/test/unit_test.hpp>
using namespace boost::unit_test_framework;
test_suite*
init_unit_test_suite(int argc, char** argv)
{
return (test_suite*) 0;
}
])],
[boost_unit_found=$boost_lib
boost_defines="-DBOOST_TEST_DYN_LINK"
break],
[])
done
LIBS="$ql_original_LIBS"
CXXFLAGS="$ql_original_CXXFLAGS"
if test "$boost_unit_found" = no ; then
AC_MSG_RESULT([no])
AC_SUBST([BOOST_UNIT_TEST_LIB],[""])
AC_SUBST([BOOST_UNIT_TEST_MAIN_CXXFLAGS],[""])
AC_MSG_WARN([Boost unit-test framework not found.])
AC_MSG_WARN([The test suite will be disabled.])
else
AC_MSG_RESULT([yes])
AC_SUBST([BOOST_UNIT_TEST_LIB],[$boost_lib])
AC_SUBST([BOOST_UNIT_TEST_MAIN_CXXFLAGS],[$boost_defines])
fi
])
# QL_CHECK_BOOST_TEST_THREAD_SIGNALS2_SYSTEM
# ------------------------
# Check whether the Boost thread and system is available
AC_DEFUN([QL_CHECK_BOOST_TEST_THREAD_SIGNALS2_SYSTEM],
[AC_MSG_CHECKING([whether Boost thread, signals2 and system are available])
AC_REQUIRE([AC_PROG_CC])
ql_original_LIBS=$LIBS
ql_original_CXXFLAGS=$CXXFLAGS
CC_BASENAME=`basename $CC`
CC_VERSION=`echo "__GNUC__ __GNUC_MINOR__" | $CC -E -x c - | tail -n 1 | $SED -e "s/ //"`
for boost_thread_lib in "-lboost_thread-$CC_BASENAME$CC_VERSION -lboost_system-$CC_BASENAME$CC_VERSION" \
"-lboost_thread-$CC_BASENAME -lboost_system-$CC_BASENAME" \
"-lboost_thread -lboost_system" \
"-lboost_thread-mt-$CC_BASENAME$CC_VERSION -lboost_system-mt-$CC_BASENAME$CC_VERSION" \
"-lboost_thread-$CC_BASENAME$CC_VERSION-mt -lboost_system-$CC_BASENAME$CC_VERSION-mt" \
"-lboost_thread-x$CC_BASENAME$CC_VERSION-mt -lboost_system-x$CC_BASENAME$CC_VERSION-mt" \
"-lboost_thread-mt-$CC_BASENAME -lboost_system-mt-$CC_BASENAME" \
"-lboost_thread-$CC_BASENAME-mt -lboost_system-$CC_BASENAME-mt" \
"-lboost_thread-mt -lboost_system-mt"; do
LIBS="$ql_original_LIBS $boost_thread_lib"
CXXFLAGS="$ql_original_CXXFLAGS -pthread"
boost_thread_found=no
AC_LINK_IFELSE([AC_LANG_SOURCE(
[@%:@include <boost/thread/locks.hpp>
@%:@include <boost/thread/recursive_mutex.hpp>
@%:@include <boost/signals2/signal.hpp>
#ifndef BOOST_THREAD_PLATFORM_PTHREAD
#error only pthread is supported on this plattform
#endif
int main() {
boost::recursive_mutex m;
boost::lock_guard<boost::recursive_mutex> lock(m);
boost::signals2::signal<void()> sig;
return 0;
}
])],
[boost_thread_found=$boost_thread_lib
break],
[])
done
LIBS="$ql_original_LIBS"
CXXFLAGS="$ql_original_CXXFLAGS"
if test "$boost_thread_found" = no ; then
AC_MSG_RESULT([no])
AC_SUBST([BOOST_THREAD_LIB],[""])
AC_MSG_ERROR([Boost thread, signals2 and system libraries not found.
These libraries are required by the thread-safe observer pattern
or by the parallel unit test runner.])
else
AC_MSG_RESULT([yes])
AC_SUBST([BOOST_THREAD_LIB],[$boost_thread_lib])
AC_SUBST([CXXFLAGS],["${CXXFLAGS} -pthread"])
fi
])
# QL_CHECK_BOOST_TEST_INTERPROCESS
# ------------------------
# Check whether the Boost interprocess is available
AC_DEFUN([QL_CHECK_BOOST_TEST_INTERPROCESS],
[AC_MSG_CHECKING([whether Boost interprocess is available])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([QL_CHECK_BOOST_TEST_THREAD_SIGNALS2_SYSTEM])
ql_original_LIBS=$LIBS
for boost_interprocess_lib in "" "-lrt"; do
LIBS="$ql_original_LIBS $boost_thread_lib $boost_interprocess_lib"
boost_interprocess_found=no
AC_LINK_IFELSE([AC_LANG_SOURCE(
[@%:@include <boost/interprocess/ipc/message_queue.hpp>
using namespace boost::interprocess;
int main() {
message_queue mq(open_or_create,"message_queue",100,100);
message_queue::remove("message_queue");
return 0;
}
])],
[boost_interprocess_found=$boost_interprocess_lib
break],
[])
done
LIBS="$ql_original_LIBS"
if test "$boost_interprocess_found" = no ; then
AC_MSG_RESULT([no])
AC_SUBST([BOOST_INTERPROCESS_LIB],[""])
AC_MSG_ERROR([The boost library interprocess does not work on this system
but is required to use the parallel unit test runner.])
else
AC_MSG_RESULT([yes])
AC_SUBST([BOOST_INTERPROCESS_LIB],[$boost_interprocess_lib])
fi
])
# QL_CHECK_BOOST_TEST_STREAM
# --------------------------
# Check whether Boost unit-test stream accepts std::fixed
AC_DEFUN([QL_CHECK_BOOST_TEST_STREAM],
[AC_MSG_CHECKING([whether Boost unit-test streams work])
AC_REQUIRE([AC_PROG_CC])
AC_TRY_COMPILE(
[@%:@include <boost/test/unit_test.hpp>
@%:@include <iomanip>],
[BOOST_ERROR("foo " << std::fixed << 42.0);],
[AC_MSG_RESULT([yes])
AC_SUBST(BOOST_UNIT_TEST_DEFINE,[-DQL_WORKING_BOOST_STREAMS])],
[AC_MSG_RESULT([no])
AC_SUBST(BOOST_UNIT_TEST_DEFINE,[""])
])
])
# QL_CHECK_BOOST
# ------------------------
# Boost-related tests
AC_DEFUN([QL_CHECK_BOOST],
[AC_REQUIRE([QL_CHECK_BOOST_DEVEL])
AC_REQUIRE([QL_CHECK_BOOST_VERSION])
AC_REQUIRE([QL_CHECK_BOOST_UBLAS])
AC_REQUIRE([QL_CHECK_BOOST_UNIT_TEST])
AC_REQUIRE([QL_CHECK_BOOST_TEST_STREAM])
])