Rev 30 | Blame | Compare with Previous | Last modification | View Log | RSS feed
##### http://autoconf-archive.cryp.to/ax_boost_base.html## SYNOPSIS## AX_BOOST_BASE([MINIMUM-VERSION])## DESCRIPTION## Test for the Boost C++ libraries of a particular version (or newer)## If no path to the installed boost library is given the macro# searchs under /usr, /usr/local, /opt and /opt/local and evaluates# the $BOOST_ROOT environment variable. Further documentation is# available at <http://randspringer.de/boost/index.html>.## This macro calls:## AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)## And sets:## HAVE_BOOST## LAST MODIFICATION## 2007-07-28## COPYLEFT## Copyright (c) 2007 Thomas Porschberg <thomas@randspringer.de>## Copying and distribution of this file, with or without# modification, are permitted in any medium without royalty provided# the copyright notice and this notice are preserved.AC_DEFUN([AX_BOOST_BASE],[AC_ARG_WITH([boost],AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),[if test "$withval" = "no"; thenwant_boost="no"elif test "$withval" = "yes"; thenwant_boost="yes"ac_boost_path=""elsewant_boost="yes"ac_boost_path="$withval"fi],[want_boost="yes"])if test "x$want_boost" = "xyes"; thenboost_lib_version_req=ifelse([$1], ,1.20.0,$1)boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`if test "x$boost_lib_version_req_sub_minor" = "x" ; thenboost_lib_version_req_sub_minor="0"fiWANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)succeeded=nodnl first we check the system location for boost librariesdnl this location ist chosen if boost libraries are installed with the --layout=system optiondnl or if you install boost with RPMif test "$ac_boost_path" != ""; thenBOOST_LDFLAGS="-L$ac_boost_path/lib"BOOST_CPPFLAGS="-I$ac_boost_path/include"elsefor ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; doif test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; thenBOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"break;fidonefiCPPFLAGS_SAVED="$CPPFLAGS"CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"export CPPFLAGSLDFLAGS_SAVED="$LDFLAGS"LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"export LDFLAGSAC_LANG_PUSH(C++)AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/version.hpp>]], [[#if BOOST_VERSION >= $WANT_BOOST_VERSION// Everything is okay#else# error Boost version is too old#endif]])],[AC_MSG_RESULT(yes)succeeded=yesfound_system=yes],[])AC_LANG_POP([C++])dnl if we found no boost with system layout we search for boost librariesdnl built and installed without the --layout=system option or for a staged(not installed) versionif test "x$succeeded" != "xyes"; then_version=0if test "$ac_boost_path" != ""; thenBOOST_LDFLAGS="-L$ac_boost_path/lib"if test -d "$ac_boost_path" && test -r "$ac_boost_path"; thenfor i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`V_CHECK=`expr $_version_tmp \> $_version`if test "$V_CHECK" = "1" ; then_version=$_version_tmpfiVERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"donefielsefor ac_boost_path in /usr /usr/local /opt /opt/local ; doif test -d "$ac_boost_path" && test -r "$ac_boost_path"; thenfor i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`V_CHECK=`expr $_version_tmp \> $_version`if test "$V_CHECK" = "1" ; then_version=$_version_tmpbest_path=$ac_boost_pathfidonefidoneVERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"BOOST_LDFLAGS="-L$best_path/lib"if test "x$BOOST_ROOT" != "x"; thenif test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; thenversion_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`V_CHECK=`expr $stage_version_shorten \>\= $_version`if test "$V_CHECK" = "1" ; thenAC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)BOOST_CPPFLAGS="-I$BOOST_ROOT"BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"fifififiCPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"export CPPFLAGSLDFLAGS="$LDFLAGS $BOOST_LDFLAGS"export LDFLAGSAC_LANG_PUSH(C++)AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/version.hpp>]], [[#if BOOST_VERSION >= $WANT_BOOST_VERSION// Everything is okay#else# error Boost version is too old#endif]])],[AC_MSG_RESULT(yes)succeeded=yesfound_system=yes],[])AC_LANG_POP([C++])fiif test "$succeeded" != "yes" ; thenif test "$_version" = "0" ; thenAC_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.]])elseAC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])fielseAC_SUBST(BOOST_CPPFLAGS)AC_SUBST(BOOST_LDFLAGS)AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])fiCPPFLAGS="$CPPFLAGS_SAVED"LDFLAGS="$LDFLAGS_SAVED"fi])