-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathconfigure.ac
194 lines (170 loc) · 6.58 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
# RQuantLib configure.in by Dirk Eddelbuettel <[email protected]>
#
# Using pieces borrowed from RPgSQL, GNU Gretl, GNU R and QuantLib
# Greatly simplified thanks to quantlib-config
# Another contribution by Kurt Hornik gratefully acknowledged
# require at least autoconf 2.69
AC_PREREQ([2.69])
# Process this file with autoconf to produce a configure script.
# Would like to extract R package version from R DESCRIPTION file
AC_INIT([RQuantlib],[0.4.24],[[email protected]])
# Set CXX and CXXFLAGS based on the R configuration (with thanks to KH)
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
AC_MSG_ERROR([Could not determine R_HOME.])
fi
CXX=`${R_HOME}/bin/R CMD config CXX`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
# We are using C++
AC_LANG(C++)
AC_REQUIRE_CPP
AC_PROG_CXX
#if test "${GXX}" = yes; then
# gxx_version=`${CXX} -v 2>&1 | grep "^.*g.. version" | \\
# sed -e 's/^.*g.. version *//'`
# case ${gxx_version} in
# 4.6.*|4.7.*|4.8.*|4.9.*|5.*|6.*|7.*|8.*|9.*|10.*|11.*|12.*|13.*|14.*|15.*|16.*|17.*)
# gxx_newer_than_45="-fpermissive"
# ;;
# esac
#fi
AC_DEFUN([AC_PROG_R], [AC_CHECK_PROG(R,R,yes)])
AC_PROG_R
## We no longer need to set LDFLAGS for Rcpp 0.11.0 or later,
## and hence no longer need to check for Rscipt
##
## ## look for Rscript, but use the one found via R_HOME to allow for multiple installations
## AC_DEFUN(AC_PROG_RSCRIPT, [AC_CHECK_PROG(RSCRIPT,Rscript,yes)])
## AC_PROG_RSCRIPT
## #AC_MSG_CHECKING([for Rscript])
## if test x"${RSCRIPT}" == x"yes" ; then
## # AC_MSG_RESULT([yes])
## ## Rcpp compile flag providing header directory containing Rcpp.h
## #rcpp_cxxflags=`${R_HOME}/bin/Rscript -e 'Rcpp:::CxxFlags()'`
## ## link flag providing libary as well as path to library, and optionally rpath
## rcpp_ldflags=`${R_HOME}/bin/Rscript -e 'Rcpp:::LdFlags()'`
## ## now use all these
## #AC_SUBST([CXXFLAGS],["${CXXFLAGS} $rcpp_cxxflags"])
## AC_SUBST([LDFLAGS],["${LDFLAGS} $rcpp_ldflags"])
## else
## # AC_MSG_RESULT([no])
## echo "
## Your installation does not appear to have Rscript installed.
##
## Please make sure that you have a working and complete R installation.
## "
## exit 1
## fi
# borrowed from a check for gnome in GNU gretl: define a check for quantlib-config
AC_DEFUN([AC_PROG_QUANTLIB], [AC_CHECK_PROG(QUANTLIB,quantlib-config,yes)])
AC_PROG_QUANTLIB
if test x"${QUANTLIB}" = x"yes" ; then
# use quantlib-config for QL settings
pkg_cxxflags=`quantlib-config --cflags`
pkg_libs=`quantlib-config --libs`
pkg_version=`quantlib-config --version`
##echo "Seeing ${pkg_cxxflags} ${pkg_libs} ${pkg_version}"
# also test for quantlib version using result from quantlib-config --version
case ${pkg_version} in
0.*|1.0*|1.1*|1.20.*|1.21.*|1.22.*|1.23.*|1.24.*)
AC_MSG_WARN([RQuantLib requires QuantLib (>= 1.25).])
AC_MSG_ERROR([Please upgrade to a current version.])
;;
1.25.*|1.26*|1.27*|1.28*|1.29*|1.30.*|1.31.*|1.32.*|1.33.*|1.34.*)
echo "checking for suitable QuantLib version... version ${pkg_version} is not the most recent one. Consider upgrading."
;;
1.*)
echo "checking for suitable QuantLib version... yes (${pkg_version})"
;;
esac
# now use all these
AC_SUBST([PKG_CXXFLAGS],["${PKG_CXXFLAGS} ${pkg_cxxflags} ${gxx_newer_than_45}"])
AC_SUBST([PKG_LIBS],["${PKG_LIBS} $pkg_libs"])
elif test "`uname`" = "Darwin" ; then
# this is a non-CRAN code patch as CRAN does have QuantLib locally installed
quantlib="https://github.com/autobrew/bundler/releases/download/quantlib-1.31.1/quantlib-1.31.1-universal.tar.xz"
quantlibdir="$PWD/.deps"
mkdir -p $quantlibdir
echo "downloading $quantlib"
curl -sSL "$quantlib" -o quantlib.tar.xz
tar xf quantlib.tar.xz --strip 1 -C "$quantlibdir"
rm quantlib.tar.xz
# compiler flag needed on macOS 14, see PR #190
pkg_cxxflags="-I${quantlibdir}/include -Wno-enum-constexpr-conversion"
pkg_libs="-L${quantlibdir}/lib -lQuantLib"
# Same as above
AC_SUBST([PKG_CXXFLAGS],["${PKG_CXXFLAGS} $pkg_cxxflags"])
AC_SUBST([PKG_LIBS],["${PKG_LIBS} $pkg_libs"])
# Boost test needs CXXFLAGS set to find Boost headers in macOS tar.xz
CXXFLAGS="$CXXFLAGS $pkg_cxxflags"
LDFLAGS="$LDFLAGS $pkg_libs"
else
AC_MSG_ERROR([Please install QuantLib before trying to build RQuantLib.])
fi
## check for boost, this segment as well as segment below are
## from QuantLib's configure.ac
##
##
## Help the compiler find external software
AC_ARG_WITH([boost-include],
AS_HELP_STRING([--with-boost-include=INCLUDE_PATH],[Supply the location of Boost header files]),
[ql_boost_include_path=$withval],
[ql_boost_include_path=""])
if test [ -n "$ql_boost_include_path" ] ; then
AC_SUBST([PKG_CXXFLAGS],["${PKG_CXXFLAGS} -I${ql_boost_include_path}"])
fi
AC_ARG_WITH([boost-lib],
AS_HELP_STRING([--with-boost-lib=LIB_PATH],[Supply the location of Boost libraries]),
[ql_boost_lib_path=$withval],
[ql_boost_lib_path=""])
if test [ -n "$ql_boost_lib_path" ] ; then
AC_SUBST([PKG_LIBS],["${PKG_LIBS} -L${ql_boost_lib_path}"])
fi
##
## Check for Boost components
# 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_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@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 minimal Boost version])
AC_REQUIRE([QL_CHECK_BOOST_DEVEL])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/version.hpp>]], [[@%:@if BOOST_VERSION < 106500
@%:@error too old
@%:@endif]])],[AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
AC_MSG_ERROR([outdated Boost installation])
])
])
# QL_CHECK_BOOST
# ------------------------
# Boost-related tests
AC_DEFUN([QL_CHECK_BOOST],
[AC_REQUIRE([QL_CHECK_BOOST_DEVEL])
AC_REQUIRE([QL_CHECK_BOOST_VERSION])
])
QL_CHECK_BOOST
AC_SUBST(PKG_CXXFLAGS)
AC_SUBST(PKG_LIBS)
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT
echo "
${PACKAGE_NAME} $PACKAGE_VERSION (using QuantLib ${pkg_version})
======================================
cxxflags: ${PKG_CXXFLAGS}
libs: ${PKG_LIBS}
"
### Local Variables: ***
### mode: autoconf ***
### autoconf-indentation: 4 ***
### End: ***