Blame build/ax_boost_base.m4

Packit 908522
##### http://autoconf-archive.cryp.to/ax_boost_base.html
Packit 908522
#
Packit 908522
# SYNOPSIS
Packit 908522
#
Packit 908522
#   AX_BOOST_BASE([MINIMUM-VERSION])
Packit 908522
#
Packit 908522
# DESCRIPTION
Packit 908522
#
Packit 908522
#   Test for the Boost C++ libraries of a particular version (or newer)
Packit 908522
#
Packit 908522
#   If no path to the installed boost library is given the macro
Packit 908522
#   searchs under /usr, /usr/local, and /opt, and evaluates the
Packit 908522
#   $BOOST_ROOT environment variable. Further documentation is
Packit 908522
#   available at <http://randspringer.de/boost/index.html>.
Packit 908522
#
Packit 908522
#   This macro calls:
Packit 908522
#
Packit 908522
#     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
Packit 908522
#
Packit 908522
#   And sets:
Packit 908522
#
Packit 908522
#     HAVE_BOOST
Packit 908522
#
Packit 908522
# LAST MODIFICATION
Packit 908522
#
Packit 908522
#   2006-12-28
Packit 908522
#
Packit 908522
# COPYLEFT
Packit 908522
#
Packit 908522
#   Copyright (c) 2006 Thomas Porschberg <thomas@randspringer.de>
Packit 908522
#
Packit 908522
#   Copying and distribution of this file, with or without
Packit 908522
#   modification, are permitted in any medium without royalty provided
Packit 908522
#   the copyright notice and this notice are preserved.
Packit 908522
Packit 908522
AC_DEFUN([AX_BOOST_BASE],
Packit 908522
[
Packit 908522
AC_ARG_WITH([boost],
Packit 908522
	AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is No) - it is possible to specify the root directory for boost (optional)]),
Packit 908522
	[
Packit 908522
    if test "$withval" = "no"; then
Packit 908522
		want_boost="no"
Packit 908522
    elif test "$withval" = "yes"; then
Packit 908522
        want_boost="yes"
Packit 908522
        ac_boost_path=""
Packit 908522
    else
Packit 908522
	    want_boost="yes"
Packit 908522
        ac_boost_path="$withval"
Packit 908522
	fi
Packit 908522
    ],
Packit 908522
    [want_boost="yes"])
Packit 908522
Packit 908522
if test "x$want_boost" = "xyes"; then
Packit 908522
	boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
Packit 908522
	boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
Packit 908522
	boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
Packit 908522
	boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
Packit 908522
	boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
Packit 908522
	if test "x$boost_lib_version_req_sub_minor" = "x" ; then
Packit 908522
		boost_lib_version_req_sub_minor="0"
Packit 908522
    	fi
Packit 908522
	WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
Packit 908522
	AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
Packit 908522
	succeeded=no
Packit 908522
Packit 908522
	dnl first we check the system location for boost libraries
Packit 908522
	dnl this location ist chosen if boost libraries are installed with the --layout=system option
Packit 908522
	dnl or if you install boost with RPM
Packit 908522
	if test "$ac_boost_path" != ""; then
Packit 908522
		BOOST_LDFLAGS="-L$ac_boost_path/lib"
Packit 908522
		BOOST_CPPFLAGS="-I$ac_boost_path/include"
Packit 908522
	else
Packit 908522
		for ac_boost_path_tmp in /usr /usr/local /opt ; do
Packit 908522
			if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
Packit 908522
				BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
Packit 908522
				BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
Packit 908522
				break;
Packit 908522
			fi
Packit 908522
		done
Packit 908522
	fi
Packit 908522
Packit 908522
	CPPFLAGS_SAVED="$CPPFLAGS"
Packit 908522
	CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
Packit 908522
	export CPPFLAGS
Packit 908522
Packit 908522
	LDFLAGS_SAVED="$LDFLAGS"
Packit 908522
	LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
Packit 908522
	export LDFLAGS
Packit 908522
Packit 908522
	AC_LANG_PUSH(C++)
Packit 908522
     	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Packit 908522
	@%:@include <boost/version.hpp>
Packit 908522
	]], [[
Packit 908522
	#if BOOST_VERSION >= $WANT_BOOST_VERSION
Packit 908522
	// Everything is okay
Packit 908522
	#else
Packit 908522
	#  error Boost version is too old
Packit 908522
	#endif
Packit 908522
	]])],[
Packit 908522
        AC_MSG_RESULT(yes)
Packit 908522
	succeeded=yes
Packit 908522
	found_system=yes
Packit 908522
       	],[
Packit 908522
       	])
Packit 908522
	AC_LANG_POP([C++])
Packit 908522
Packit 908522
Packit 908522
Packit 908522
	dnl if we found no boost with system layout we search for boost libraries
Packit 908522
	dnl built and installed without the --layout=system option or for a staged(not installed) version
Packit 908522
	if test "x$succeeded" != "xyes"; then
Packit 908522
		_version=0
Packit 908522
		if test "$ac_boost_path" != ""; then
Packit 908522
               		BOOST_LDFLAGS="-L$ac_boost_path/lib"
Packit 908522
			if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
Packit 908522
				for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
Packit 908522
					_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
Packit 908522
					V_CHECK=`expr $_version_tmp \> $_version`
Packit 908522
					if test "$V_CHECK" = "1" ; then
Packit 908522
						_version=$_version_tmp
Packit 908522
					fi
Packit 908522
					VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
Packit 908522
					BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
Packit 908522
				done
Packit 908522
			fi
Packit 908522
		else
Packit 908522
			for ac_boost_path in /usr /usr/local /opt ; do
Packit 908522
				if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
Packit 908522
					for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
Packit 908522
						_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
Packit 908522
						V_CHECK=`expr $_version_tmp \> $_version`
Packit 908522
						if test "$V_CHECK" = "1" ; then
Packit 908522
							_version=$_version_tmp
Packit 908522
	               					best_path=$ac_boost_path
Packit 908522
						fi
Packit 908522
					done
Packit 908522
				fi
Packit 908522
			done
Packit 908522
Packit 908522
			VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
Packit 908522
			BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
Packit 908522
			BOOST_LDFLAGS="-L$best_path/lib"
Packit 908522
Packit 908522
	    		if test "x$BOOST_ROOT" != "x"; then
Packit 908522
				if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
Packit 908522
					version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
Packit 908522
					stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
Packit 908522
			        	stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
Packit 908522
					V_CHECK=`expr $stage_version_shorten \>\= $_version`
Packit 908522
				        if test "$V_CHECK" = "1" ; then
Packit 908522
						AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
Packit 908522
						BOOST_CPPFLAGS="-I$BOOST_ROOT"
Packit 908522
						BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
Packit 908522
					fi
Packit 908522
				fi
Packit 908522
	    		fi
Packit 908522
		fi
Packit 908522
Packit 908522
		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
Packit 908522
		export CPPFLAGS
Packit 908522
		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
Packit 908522
		export LDFLAGS
Packit 908522
Packit 908522
		AC_LANG_PUSH(C++)
Packit 908522
	     	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Packit 908522
		@%:@include <boost/version.hpp>
Packit 908522
		]], [[
Packit 908522
		#if BOOST_VERSION >= $WANT_BOOST_VERSION
Packit 908522
		// Everything is okay
Packit 908522
		#else
Packit 908522
		#  error Boost version is too old
Packit 908522
		#endif
Packit 908522
		]])],[
Packit 908522
        	AC_MSG_RESULT(yes)
Packit 908522
		succeeded=yes
Packit 908522
		found_system=yes
Packit 908522
       		],[
Packit 908522
	       	])
Packit 908522
		AC_LANG_POP([C++])
Packit 908522
	fi
Packit 908522
Packit 908522
	if test "$succeeded" != "yes" ; then
Packit 908522
		if test "$_version" = "0" ; then
Packit 908522
			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.]])
Packit 908522
		else
Packit 908522
			AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
Packit 908522
		fi
Packit 908522
	else
Packit 908522
		AC_SUBST(BOOST_CPPFLAGS)
Packit 908522
		AC_SUBST(BOOST_LDFLAGS)
Packit 908522
		AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
Packit 908522
	fi
Packit 908522
Packit 908522
        CPPFLAGS="$CPPFLAGS_SAVED"
Packit 908522
       	LDFLAGS="$LDFLAGS_SAVED"
Packit 908522
fi
Packit 908522
Packit 908522
])