1
# ===========================================================================
2
# http://autoconf-archive.cryp.to/ax_boost_base.html
3
# ===========================================================================
7
# AX_BOOST_BASE([MINIMUM-VERSION])
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>
30
# Copying and distribution of this file, with or without modification, are
31
# permitted in any medium without royalty provided the copyright notice
32
# and this notice are preserved.
34
AC_DEFUN([AX_BOOST_BASE],
37
AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
39
if test "$withval" = "no"; then
41
elif test "$withval" = "yes"; then
46
ac_boost_path="$withval"
52
AC_ARG_WITH([boost-libdir],
53
AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
54
[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.]),
58
ac_boost_lib_path="$withval"
60
AC_MSG_ERROR(--with-boost-libdir expected directory name)
63
[ac_boost_lib_path=""]
66
if test "x$want_boost" = "xyes"; then
67
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
68
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
69
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
70
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
71
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
72
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
73
boost_lib_version_req_sub_minor="0"
75
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
76
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
79
dnl first we check the system location for boost libraries
80
dnl this location ist chosen if boost libraries are installed with the --layout=system option
81
dnl or if you install boost with RPM
82
if test "$ac_boost_path" != ""; then
83
BOOST_LDFLAGS="-L$ac_boost_path/lib"
84
BOOST_CPPFLAGS="-I$ac_boost_path/include"
86
for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
87
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
88
BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
89
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
95
dnl overwrite ld flags if we have required special directory with
96
dnl --with-boost-libdir parameter
97
if test "$ac_boost_lib_path" != ""; then
98
BOOST_LDFLAGS="-L$ac_boost_lib_path"
101
CPPFLAGS_SAVED="$CPPFLAGS"
102
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
105
LDFLAGS_SAVED="$LDFLAGS"
106
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
110
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
111
@%:@include <boost/version.hpp>
113
#if BOOST_VERSION >= $WANT_BOOST_VERSION
114
// Everything is okay
116
# error Boost version is too old
128
dnl if we found no boost with system layout we search for boost libraries
129
dnl built and installed without the --layout=system option or for a staged(not installed) version
130
if test "x$succeeded" != "xyes"; then
132
if test "$ac_boost_path" != ""; then
133
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
134
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
135
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
136
V_CHECK=`expr $_version_tmp \> $_version`
137
if test "$V_CHECK" = "1" ; then
138
_version=$_version_tmp
140
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
141
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
145
for ac_boost_path in /usr /usr/local /opt /opt/local ; do
146
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
147
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
148
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
149
V_CHECK=`expr $_version_tmp \> $_version`
150
if test "$V_CHECK" = "1" ; then
151
_version=$_version_tmp
152
best_path=$ac_boost_path
158
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
159
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
160
if test "$ac_boost_lib_path" = ""
162
BOOST_LDFLAGS="-L$best_path/lib"
165
if test "x$BOOST_ROOT" != "x"; then
166
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
167
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
168
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
169
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
170
V_CHECK=`expr $stage_version_shorten \>\= $_version`
171
if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
172
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
173
BOOST_CPPFLAGS="-I$BOOST_ROOT"
174
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
180
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
182
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
186
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
187
@%:@include <boost/version.hpp>
189
#if BOOST_VERSION >= $WANT_BOOST_VERSION
190
// Everything is okay
192
# error Boost version is too old
203
if test "$succeeded" != "yes" ; then
204
if test "$_version" = "0" ; then
205
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.]])
207
AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
210
AC_SUBST(BOOST_CPPFLAGS)
211
AC_SUBST(BOOST_LDFLAGS)
212
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
215
CPPFLAGS="$CPPFLAGS_SAVED"
216
LDFLAGS="$LDFLAGS_SAVED"