1 dnl @synopsis AX_BOOST([MINIMUM-VERSION])
3 dnl Test for the Boost C++ libraries of a particular version (or newer)
5 dnl If no path to the installed boost library is given the macro
6 dnl searchs under /usr, /usr/local, and /opt, and evaluates the
7 dnl $BOOST_ROOT environment variable. Further documentation is
8 dnl available at <http://randspringer.de/boost/index.html>.
12 dnl AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
18 dnl @category InstalledPackages
20 dnl @author Thomas Porschberg <thomas@randspringer.de>
21 dnl @version 2006-06-15
22 dnl @license AllPermissive
24 AC_DEFUN([AX_BOOST_BASE],
27 AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify an alternate root directory for boost]),
29 if test "$withval" = "no"; then
31 elif test "$withval" = "yes"; then
36 ac_boost_path="$withval"
41 if test "x$want_boost" = "xyes"; then
42 boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
43 boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
44 boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
45 boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
46 boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
47 if test "x$boost_lib_version_req_sub_minor" = "x" ; then
48 boost_lib_version_req_sub_minor="0"
50 WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
51 AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
54 dnl first we check the system location for boost libraries
55 dnl this location ist chosen if boost libraries are installed with the --layout=system option
56 dnl or if you install boost with RPM
57 if test "$ac_boost_path" != ""; then
58 BOOST_LDFLAGS="-L$ac_boost_path/lib"
59 BOOST_CPPFLAGS="-I$ac_boost_path/include"
61 for ac_boost_path_tmp in /usr /usr/local /opt ; do
62 if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
63 BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
64 BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
70 CPPFLAGS_SAVED="$CPPFLAGS"
71 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
74 LDFLAGS_SAVED="$LDFLAGS"
75 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
79 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
80 @%:@include <boost/version.hpp>
82 #if BOOST_VERSION >= $WANT_BOOST_VERSION
85 # error Boost version is too old
97 dnl if we found no boost with system layout we search for boost libraries
98 dnl built and installed without the --layout=system option or for a staged(not installed) version
99 if test "x$succeeded" != "xyes"; then
101 if test "$ac_boost_path" != ""; then
102 BOOST_LDFLAGS="-L$ac_boost_path/lib"
103 if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
104 for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
105 _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
106 V_CHECK=`expr $_version_tmp \> $_version`
107 if test "$V_CHECK" = "1" ; then
108 _version=$_version_tmp
110 VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
111 BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
115 for ac_boost_path in /usr /usr/local /opt ; do
116 if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
117 for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
118 _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
119 V_CHECK=`expr $_version_tmp \> $_version`
120 if test "$V_CHECK" = "1" ; then
121 _version=$_version_tmp
122 best_path=$ac_boost_path
128 VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
129 BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
130 BOOST_LDFLAGS="-L$best_path/lib"
132 if test "x$BOOST_ROOT" != "x"; then
133 if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
134 version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
135 stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
136 stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
137 V_CHECK=`expr $stage_version_shorten \>\= $_version`
138 if test "$V_CHECK" = "1" ; then
139 AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
140 BOOST_CPPFLAGS="-I$BOOST_ROOT"
141 BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
147 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
149 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
153 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
154 @%:@include <boost/version.hpp>
156 #if BOOST_VERSION >= $WANT_BOOST_VERSION
157 // Everything is okay
159 # error Boost version is too old
170 if test "$succeeded" != "yes" ; then
171 if test "$_version" = "0" ; then
172 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.]])
174 AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
177 AC_SUBST(BOOST_CPPFLAGS)
178 AC_SUBST(BOOST_LDFLAGS)
179 AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
182 CPPFLAGS="$CPPFLAGS_SAVED"
183 LDFLAGS="$LDFLAGS_SAVED"