1
# ===========================================================================
2
# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
3
# ===========================================================================
7
# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
11
# Test for the Boost C++ libraries of a particular version (or newer)
13
# If no path to the installed boost library is given the macro searchs
14
# under /usr, /usr/local, /opt and /opt/local and evaluates the
15
# $BOOST_ROOT environment variable. Further documentation is available at
16
# <http://randspringer.de/boost/index.html>.
20
# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
28
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
29
# Copyright (c) 2009 Peter Adolphs
31
# Copying and distribution of this file, with or without modification, are
32
# permitted in any medium without royalty provided the copyright notice
33
# and this notice are preserved. This file is offered as-is, without any
38
AC_DEFUN([AX_BOOST_BASE],
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)
47
if test "$withval" = "no"; then
49
elif test "$withval" = "yes"; then
54
ac_boost_path="$withval"
60
AC_ARG_WITH([boost-libdir],
61
AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
62
[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.]),
66
ac_boost_lib_path="$withval"
68
AC_MSG_ERROR(--with-boost-libdir expected directory name)
71
[ac_boost_lib_path=""]
74
if test "x$want_boost" = "xyes"; then
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 x86_64 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!
93
if test `uname -m` = x86_64; then
94
libsubdirs="lib64 lib lib64"
97
dnl first we check the system location for boost libraries
98
dnl this location ist chosen if boost libraries are installed with the --layout=system option
99
dnl or if you install boost with RPM
100
if test "$ac_boost_path" != ""; then
101
BOOST_CPPFLAGS="-I$ac_boost_path/include"
102
for ac_boost_path_tmp in $libsubdirs; do
103
if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
104
BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
108
elif test "$cross_compiling" != yes; then
109
for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
110
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
111
for libsubdir in $libsubdirs ; do
112
if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
114
BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
115
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
121
dnl overwrite ld flags if we have required special directory with
122
dnl --with-boost-libdir parameter
123
if test "$ac_boost_lib_path" != ""; then
124
BOOST_LDFLAGS="-L$ac_boost_lib_path"
127
CPPFLAGS_SAVED="$CPPFLAGS"
128
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
131
LDFLAGS_SAVED="$LDFLAGS"
132
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
135
AC_REQUIRE([AC_PROG_CXX])
137
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
138
@%:@include <boost/version.hpp>
140
#if BOOST_VERSION >= $WANT_BOOST_VERSION
141
// Everything is okay
143
# error Boost version is too old
155
dnl if we found no boost with system layout we search for boost libraries
156
dnl built and installed without the --layout=system option or for a staged(not installed) version
157
if test "x$succeeded" != "xyes"; then
159
if test "$ac_boost_path" != ""; then
160
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
161
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
162
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
163
V_CHECK=`expr $_version_tmp \> $_version`
164
if test "$V_CHECK" = "1" ; then
165
_version=$_version_tmp
167
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
168
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
172
if test "$cross_compiling" != yes; then
173
for ac_boost_path in /usr /usr/local /opt /opt/local ; do
174
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
175
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
176
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
177
V_CHECK=`expr $_version_tmp \> $_version`
178
if test "$V_CHECK" = "1" ; then
179
_version=$_version_tmp
180
best_path=$ac_boost_path
186
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
187
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
188
if test "$ac_boost_lib_path" = ""; then
189
for libsubdir in $libsubdirs ; do
190
if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
192
BOOST_LDFLAGS="-L$best_path/$libsubdir"
196
if test "x$BOOST_ROOT" != "x"; then
197
for libsubdir in $libsubdirs ; do
198
if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
200
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
201
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
202
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
203
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
204
V_CHECK=`expr $stage_version_shorten \>\= $_version`
205
if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
206
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
207
BOOST_CPPFLAGS="-I$BOOST_ROOT"
208
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
214
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
216
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
220
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
221
@%:@include <boost/version.hpp>
223
#if BOOST_VERSION >= $WANT_BOOST_VERSION
224
// Everything is okay
226
# error Boost version is too old
237
if test "$succeeded" != "yes" ; then
238
if test "$_version" = "0" ; then
239
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.]])
241
AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
243
# execute ACTION-IF-NOT-FOUND (if present):
244
ifelse([$3], , :, [$3])
246
AC_SUBST(BOOST_CPPFLAGS)
247
AC_SUBST(BOOST_LDFLAGS)
248
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
249
# execute ACTION-IF-FOUND (if present):
250
ifelse([$2], , :, [$2])
253
CPPFLAGS="$CPPFLAGS_SAVED"
254
LDFLAGS="$LDFLAGS_SAVED"