dnl @synopsis AX_CHECK_BOOST_HEADERS([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl dnl Test for the headers only for the Boost C++ libraries of a dnl particular version (or newer) dnl dnl If no path to the installed boost library is given the macro dnl searchs under /usr, /usr/local, and /opt, and evaluates the dnl $BOOST_ROOT environment variable. dnl dnl This macro calls: dnl dnl AC_SUBST(BOOST_CPPFLAGS) dnl dnl And sets: dnl dnl HAVE_BOOST dnl dnl @category InstalledPackages dnl @author ax_boost.m4 by Thomas Porschberg dnl @author Mark Holder (chopped ax_boost.m4 to produce this cropped version for headers only). dnl @version 2006-01-02 dnl @license AllPermissive AC_DEFUN([AX_CHECK_BOOST_HEADERS], [ AC_ARG_WITH( [boost], AC_HELP_STRING( [--with-boost=DIR], [Specify the root directory for boost library (if not specified BOOST_ROOT is used)] ), [ if test "$withval" = "no"; then AC_MSG_ERROR([The Boost library is a prerequisite. The --with-boost option should be used to specify the parent of the include directory where boost was installed.]) elif test "$withval" = "yes"; then want_boost="yes" ac_boost_path="" else want_boost="yes" ac_boost_path="$withval" fi ], [want_boost="yes"] ) ac_arg_boost_path="$ac_boost_path" AC_REQUIRE([AC_CANONICAL_BUILD])dnl #AC_CANONICAL_BUILD if test "x$want_boost" = "xyes"; then boost_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" ; then boost_lib_version_req_sub_minor="0" fi WANT_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 boost headers version >= $boost_lib_version_req) succeeded=no dnl first we check the system location for boost libraries dnl this location ist chosen if boost libraries are installed with the --layout=system option dnl or if you install boost with RPM if test "$ac_boost_path" != ""; then BOOST_CPPFLAGS="-I$ac_boost_path/include" else for ac_boost_path_tmp in /usr /usr/local /opt ; do if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" break; fi done fi CPPFLAGS_SAVED="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" export CPPFLAGS AC_TRY_COMPILE( [ @%:@include ], [ #if BOOST_VERSION >= $WANT_BOOST_VERSION // Everything is okay #else # error Boost version is too old #endif ], [ AC_MSG_RESULT(yes) succeeded=yes found_system=yes ifelse([$2], , :, [$2]) ], [ ]) dnl if we found no boost with system layout we search for boost libraries dnl built and installed without the --layout=system option or for a staged(not installed) version if test "x$succeeded" != "xyes"; then _version=0 if test "$ac_boost_path" != ""; then if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then for 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_tmp fi VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" done fi else for ac_boost_path in /usr /usr/local /opt ; do if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then for 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_tmp best_path=$ac_boost_path fi done fi done VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" if test "x$BOOST_ROOT" != "x"; then if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT"; then version_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" ; then AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) BOOST_CPPFLAGS="-I$BOOST_ROOT" fi _version=$stage_version fi fi fi CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" export CPPFLAGS AC_TRY_COMPILE( [ @%:@include ], [ #if BOOST_VERSION >= $WANT_BOOST_VERSION // Everything is okay #else # error Boost version is too old #endif ], [ AC_MSG_RESULT(yes ($_version)) succeeded=yes ifelse([$2], , :, [$2]) ], [ AC_MSG_RESULT(no ($_version)) ifelse([$3], , :, [$3]) ]) fi if test "$succeeded" != "yes" ; then if test "$_version" = "0" ; then if test -z "$ac_arg_boost_path" then 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 .]]) else AC_MSG_ERROR([Could not use the boost include headers in $ac_arg_boost_path/include. Check the arg to --with-boost and check your version number looking in ]) fi else AC_MSG_ERROR([Your boost libraries seems to old (version $_version). Version $boost_lib_version_req_shorten or greater is required]) fi else AC_SUBST(BOOST_CPPFLAGS) AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) fi CPPFLAGS="$CPPFLAGS_SAVED" LDFLAGS="$LDFLAGS_SAVED" fi AC_PROVIDE([$0]) ])