32
28
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
29
# Copyright (c) 2009 Peter Adolphs
34
31
# Copying and distribution of this file, with or without modification, are
35
32
# permitted in any medium without royalty provided the copyright notice
36
# and this notice are preserved.
33
# and this notice are preserved. This file is offered as-is, without any
38
38
AC_DEFUN([AX_BOOST_BASE],
40
40
AC_ARG_WITH([boost],
41
AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
41
[AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
42
[use Boost library from a standard location (ARG=yes),
43
from the specified location (ARG=<path>),
44
or disable it (ARG=no)
43
47
if test "$withval" = "no"; then
45
49
elif test "$withval" = "yes"; then
50
54
ac_boost_path="$withval"
53
57
[want_boost="yes"])
56
60
AC_ARG_WITH([boost-libdir],
57
61
AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
58
[Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
62
[Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
62
66
ac_boost_lib_path="$withval"
70
74
if test "x$want_boost" = "xyes"; then
71
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
72
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
73
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
74
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
75
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
76
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
77
boost_lib_version_req_sub_minor="0"
79
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
80
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
83
dnl first we check the system location for boost libraries
84
dnl this location ist chosen if boost libraries are installed with the --layout=system option
85
dnl or if you install boost with RPM
86
if test "$ac_boost_path" != ""; then
87
BOOST_LDFLAGS="-L$ac_boost_path/lib"
88
BOOST_CPPFLAGS="-I$ac_boost_path/include"
90
for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
91
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
92
BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
93
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
75
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
76
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
77
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
78
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
79
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
80
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
81
boost_lib_version_req_sub_minor="0"
83
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
84
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
87
dnl On 64-bit systems check for system libraries in both lib64 and lib.
88
dnl The former is specified by FHS, but e.g. Debian does not adhere to
89
dnl this (as it rises problems for generic multi-arch support).
90
dnl The last entry in the list is chosen by default when no libraries
91
dnl are found, e.g. when only header-only libraries are installed!
94
if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = s390x -o $ax_arch = sparc64; then
95
libsubdirs="lib64 lib lib64"
98
dnl first we check the system location for boost libraries
99
dnl this location ist chosen if boost libraries are installed with the --layout=system option
100
dnl or if you install boost with RPM
101
if test "$ac_boost_path" != ""; then
102
BOOST_CPPFLAGS="-I$ac_boost_path/include"
103
for ac_boost_path_tmp in $libsubdirs; do
104
if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
105
BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
109
elif test "$cross_compiling" != yes; then
110
for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
111
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
112
for libsubdir in $libsubdirs ; do
113
if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
115
BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
116
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
99
122
dnl overwrite ld flags if we have required special directory with
100
123
dnl --with-boost-libdir parameter
102
125
BOOST_LDFLAGS="-L$ac_boost_lib_path"
105
CPPFLAGS_SAVED="$CPPFLAGS"
106
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
109
LDFLAGS_SAVED="$LDFLAGS"
110
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
114
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
115
@%:@include <boost/version.hpp>
117
#if BOOST_VERSION >= $WANT_BOOST_VERSION
118
// Everything is okay
120
# error Boost version is too old
128
CPPFLAGS_SAVED="$CPPFLAGS"
129
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
132
LDFLAGS_SAVED="$LDFLAGS"
133
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
136
AC_REQUIRE([AC_PROG_CXX])
138
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
139
@%:@include <boost/version.hpp>
141
#if BOOST_VERSION >= $WANT_BOOST_VERSION
142
// Everything is okay
144
# error Boost version is too old
123
147
AC_MSG_RESULT(yes)
132
dnl if we found no boost with system layout we search for boost libraries
133
dnl built and installed without the --layout=system option or for a staged(not installed) version
134
if test "x$succeeded" != "xyes"; then
136
if test "$ac_boost_path" != ""; then
137
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
138
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
139
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
140
V_CHECK=`expr $_version_tmp \> $_version`
141
if test "$V_CHECK" = "1" ; then
142
_version=$_version_tmp
144
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
145
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
149
for ac_boost_path in /usr /usr/local /opt /opt/local ; do
150
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
151
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
152
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
153
V_CHECK=`expr $_version_tmp \> $_version`
154
if test "$V_CHECK" = "1" ; then
155
_version=$_version_tmp
156
best_path=$ac_boost_path
162
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
163
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
164
if test "$ac_boost_lib_path" = ""
166
BOOST_LDFLAGS="-L$best_path/lib"
169
if test "x$BOOST_ROOT" != "x"; then
170
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
171
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
172
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
173
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
174
V_CHECK=`expr $stage_version_shorten \>\= $_version`
156
dnl if we found no boost with system layout we search for boost libraries
157
dnl built and installed without the --layout=system option or for a staged(not installed) version
158
if test "x$succeeded" != "xyes"; then
160
if test "$ac_boost_path" != ""; then
161
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
162
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
163
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
164
V_CHECK=`expr $_version_tmp \> $_version`
165
if test "$V_CHECK" = "1" ; then
166
_version=$_version_tmp
168
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
169
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
173
if test "$cross_compiling" != yes; then
174
for ac_boost_path in /usr /usr/local /opt /opt/local ; do
175
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
176
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
177
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
178
V_CHECK=`expr $_version_tmp \> $_version`
179
if test "$V_CHECK" = "1" ; then
180
_version=$_version_tmp
181
best_path=$ac_boost_path
187
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
188
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
189
if test "$ac_boost_lib_path" = ""; then
190
for libsubdir in $libsubdirs ; do
191
if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
193
BOOST_LDFLAGS="-L$best_path/$libsubdir"
197
if test "x$BOOST_ROOT" != "x"; then
198
for libsubdir in $libsubdirs ; do
199
if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
201
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
202
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
203
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
204
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
205
V_CHECK=`expr $stage_version_shorten \>\= $_version`
175
206
if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
176
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
177
BOOST_CPPFLAGS="-I$BOOST_ROOT"
178
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
184
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
186
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
190
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
191
@%:@include <boost/version.hpp>
193
#if BOOST_VERSION >= $WANT_BOOST_VERSION
194
// Everything is okay
196
# error Boost version is too old
207
if test "$succeeded" != "yes" ; then
208
if test "$_version" = "0" ; then
209
AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
211
AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
214
AC_SUBST(BOOST_CPPFLAGS)
215
AC_SUBST(BOOST_LDFLAGS)
216
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
219
CPPFLAGS="$CPPFLAGS_SAVED"
220
LDFLAGS="$LDFLAGS_SAVED"
207
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
208
BOOST_CPPFLAGS="-I$BOOST_ROOT"
209
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
215
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
217
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
221
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
222
@%:@include <boost/version.hpp>
224
#if BOOST_VERSION >= $WANT_BOOST_VERSION
225
// Everything is okay
227
# error Boost version is too old
238
if test "$succeeded" != "yes" ; then
239
if test "$_version" = "0" ; then
240
AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
242
AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
244
# execute ACTION-IF-NOT-FOUND (if present):
245
ifelse([$3], , :, [$3])
247
AC_SUBST(BOOST_CPPFLAGS)
248
AC_SUBST(BOOST_LDFLAGS)
249
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
250
# execute ACTION-IF-FOUND (if present):
251
ifelse([$2], , :, [$2])
254
CPPFLAGS="$CPPFLAGS_SAVED"
255
LDFLAGS="$LDFLAGS_SAVED"