Blame synfig-core/m4/ax_boost_base.m4

Carlos Lopez aebe0e
# ===========================================================================
Carlos Lopez aebe0e
#       http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
Carlos Lopez aebe0e
# ===========================================================================
Diego Barrios Romero a8fd5f
#
Diego Barrios Romero a8fd5f
# SYNOPSIS
Diego Barrios Romero a8fd5f
#
Carlos Lopez aebe0e
#   AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
Diego Barrios Romero a8fd5f
#
Diego Barrios Romero a8fd5f
# DESCRIPTION
Diego Barrios Romero a8fd5f
#
Diego Barrios Romero a8fd5f
#   Test for the Boost C++ libraries of a particular version (or newer)
Diego Barrios Romero a8fd5f
#
Carlos Lopez aebe0e
#   If no path to the installed boost library is given the macro searchs
Carlos Lopez aebe0e
#   under /usr, /usr/local, /opt and /opt/local and evaluates the
Carlos Lopez aebe0e
#   $BOOST_ROOT environment variable. Further documentation is available at
Carlos Lopez aebe0e
#   <http: boost="" index.html="" randspringer.de="">.</http:>
Diego Barrios Romero a8fd5f
#
Diego Barrios Romero a8fd5f
#   This macro calls:
Diego Barrios Romero a8fd5f
#
Diego Barrios Romero a8fd5f
#     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
Diego Barrios Romero a8fd5f
#
Diego Barrios Romero a8fd5f
#   And sets:
Diego Barrios Romero a8fd5f
#
Diego Barrios Romero a8fd5f
#     HAVE_BOOST
Diego Barrios Romero a8fd5f
#
Carlos Lopez aebe0e
# LICENSE
Diego Barrios Romero a8fd5f
#
Carlos Lopez aebe0e
#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de></thomas@randspringer.de>
Carlos Lopez aebe0e
#   Copyright (c) 2009 Peter Adolphs
Diego Barrios Romero a8fd5f
#
Carlos Lopez aebe0e
#   Copying and distribution of this file, with or without modification, are
Carlos Lopez aebe0e
#   permitted in any medium without royalty provided the copyright notice
Carlos Lopez aebe0e
#   and this notice are preserved. This file is offered as-is, without any
Carlos Lopez aebe0e
#   warranty.
Carlos Lopez aebe0e
78d310
#serial 21
Diego Barrios Romero a8fd5f
Diego Barrios Romero a8fd5f
AC_DEFUN([AX_BOOST_BASE],
Diego Barrios Romero a8fd5f
[
Diego Barrios Romero a8fd5f
AC_ARG_WITH([boost],
Carlos Lopez aebe0e
  [AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
Carlos Lopez aebe0e
    [use Boost library from a standard location (ARG=yes),
Carlos Lopez aebe0e
     from the specified location (ARG=<path>),</path>
Carlos Lopez aebe0e
     or disable it (ARG=no)
Carlos Lopez aebe0e
     @<:@ARG=yes@:>@ ])],
Carlos Lopez aebe0e
    [
Diego Barrios Romero a8fd5f
    if test "$withval" = "no"; then
Carlos Lopez aebe0e
        want_boost="no"
Diego Barrios Romero a8fd5f
    elif test "$withval" = "yes"; then
Diego Barrios Romero a8fd5f
        want_boost="yes"
Diego Barrios Romero a8fd5f
        ac_boost_path=""
Diego Barrios Romero a8fd5f
    else
Carlos Lopez aebe0e
        want_boost="yes"
Diego Barrios Romero a8fd5f
        ac_boost_path="$withval"
Carlos Lopez aebe0e
    fi
Diego Barrios Romero a8fd5f
    ],
Diego Barrios Romero a8fd5f
    [want_boost="yes"])
Diego Barrios Romero a8fd5f
Carlos Lopez aebe0e
Carlos Lopez aebe0e
AC_ARG_WITH([boost-libdir],
Carlos Lopez aebe0e
        AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
Carlos Lopez aebe0e
        [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
Carlos Lopez aebe0e
        [
Carlos Lopez aebe0e
        if test -d "$withval"
Carlos Lopez aebe0e
        then
Carlos Lopez aebe0e
                ac_boost_lib_path="$withval"
Carlos Lopez aebe0e
        else
Carlos Lopez aebe0e
                AC_MSG_ERROR(--with-boost-libdir expected directory name)
Carlos Lopez aebe0e
        fi
Carlos Lopez aebe0e
        ],
Carlos Lopez aebe0e
        [ac_boost_lib_path=""]
Carlos Lopez aebe0e
)
Carlos Lopez aebe0e
Diego Barrios Romero a8fd5f
if test "x$want_boost" = "xyes"; then
Carlos Lopez aebe0e
    boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
Carlos Lopez aebe0e
    boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
Carlos Lopez aebe0e
    boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
Carlos Lopez aebe0e
    boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
Carlos Lopez aebe0e
    boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
Carlos Lopez aebe0e
    if test "x$boost_lib_version_req_sub_minor" = "x" ; then
Carlos Lopez aebe0e
        boost_lib_version_req_sub_minor="0"
Carlos Lopez aebe0e
        fi
Carlos Lopez aebe0e
    WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
Carlos Lopez aebe0e
    AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
Carlos Lopez aebe0e
    succeeded=no
Carlos Lopez aebe0e
Carlos Lopez aebe0e
    dnl On 64-bit systems check for system libraries in both lib64 and lib.
Carlos Lopez aebe0e
    dnl The former is specified by FHS, but e.g. Debian does not adhere to
Carlos Lopez aebe0e
    dnl this (as it rises problems for generic multi-arch support).
Carlos Lopez aebe0e
    dnl The last entry in the list is chosen by default when no libraries
Carlos Lopez aebe0e
    dnl are found, e.g. when only header-only libraries are installed!
Carlos Lopez aebe0e
    libsubdirs="lib"
Carlos Lopez aebe0e
    ax_arch=`uname -m`
78d310
    case $ax_arch in
78d310
      x86_64|ppc64|s390x|sparc64|aarch64)
Carlos Lopez aebe0e
        libsubdirs="lib64 lib lib64"
78d310
        ;;
78d310
    esac
Carlos Lopez aebe0e
Carlos Lopez aebe0e
    dnl first we check the system location for boost libraries
Carlos Lopez aebe0e
    dnl this location ist chosen if boost libraries are installed with the --layout=system option
Carlos Lopez aebe0e
    dnl or if you install boost with RPM
Carlos Lopez aebe0e
    if test "$ac_boost_path" != ""; then
Carlos Lopez aebe0e
        BOOST_CPPFLAGS="-I$ac_boost_path/include"
Carlos Lopez aebe0e
        for ac_boost_path_tmp in $libsubdirs; do
Carlos Lopez aebe0e
                if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
Carlos Lopez aebe0e
                        BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
Carlos Lopez aebe0e
                        break
Carlos Lopez aebe0e
                fi
Carlos Lopez aebe0e
        done
Carlos Lopez aebe0e
    elif test "$cross_compiling" != yes; then
Carlos Lopez aebe0e
        for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
Carlos Lopez aebe0e
            if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
Carlos Lopez aebe0e
                for libsubdir in $libsubdirs ; do
Carlos Lopez aebe0e
                    if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
Carlos Lopez aebe0e
                done
Carlos Lopez aebe0e
                BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
Carlos Lopez aebe0e
                BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
Carlos Lopez aebe0e
                break;
Carlos Lopez aebe0e
            fi
Carlos Lopez aebe0e
        done
Carlos Lopez aebe0e
    fi
Carlos Lopez aebe0e
Carlos Lopez aebe0e
    dnl overwrite ld flags if we have required special directory with
Carlos Lopez aebe0e
    dnl --with-boost-libdir parameter
Carlos Lopez aebe0e
    if test "$ac_boost_lib_path" != ""; then
Carlos Lopez aebe0e
       BOOST_LDFLAGS="-L$ac_boost_lib_path"
Carlos Lopez aebe0e
    fi
Carlos Lopez aebe0e
Carlos Lopez aebe0e
    CPPFLAGS_SAVED="$CPPFLAGS"
Carlos Lopez aebe0e
    CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
Carlos Lopez aebe0e
    export CPPFLAGS
Carlos Lopez aebe0e
Carlos Lopez aebe0e
    LDFLAGS_SAVED="$LDFLAGS"
Carlos Lopez aebe0e
    LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
Carlos Lopez aebe0e
    export LDFLAGS
Carlos Lopez aebe0e
Carlos Lopez aebe0e
    AC_REQUIRE([AC_PROG_CXX])
Carlos Lopez aebe0e
    AC_LANG_PUSH(C++)
Carlos Lopez aebe0e
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Carlos Lopez aebe0e
    @%:@include <boost version.hpp=""></boost>
Carlos Lopez aebe0e
    ]], [[
Carlos Lopez aebe0e
    #if BOOST_VERSION >= $WANT_BOOST_VERSION
Carlos Lopez aebe0e
    // Everything is okay
Carlos Lopez aebe0e
    #else
Carlos Lopez aebe0e
    #  error Boost version is too old
Carlos Lopez aebe0e
    #endif
Carlos Lopez aebe0e
    ]])],[
Diego Barrios Romero a8fd5f
        AC_MSG_RESULT(yes)
Carlos Lopez aebe0e
    succeeded=yes
Carlos Lopez aebe0e
    found_system=yes
Carlos Lopez aebe0e
        ],[
Carlos Lopez aebe0e
        ])
Carlos Lopez aebe0e
    AC_LANG_POP([C++])
Carlos Lopez aebe0e
Carlos Lopez aebe0e
Carlos Lopez aebe0e
Carlos Lopez aebe0e
    dnl if we found no boost with system layout we search for boost libraries
Carlos Lopez aebe0e
    dnl built and installed without the --layout=system option or for a staged(not installed) version
Carlos Lopez aebe0e
    if test "x$succeeded" != "xyes"; then
Carlos Lopez aebe0e
        _version=0
Carlos Lopez aebe0e
        if test "$ac_boost_path" != ""; then
Carlos Lopez aebe0e
            if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
Carlos Lopez aebe0e
                for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
Carlos Lopez aebe0e
                    _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
Carlos Lopez aebe0e
                    V_CHECK=`expr $_version_tmp \> $_version`
Carlos Lopez aebe0e
                    if test "$V_CHECK" = "1" ; then
Carlos Lopez aebe0e
                        _version=$_version_tmp
Carlos Lopez aebe0e
                    fi
Carlos Lopez aebe0e
                    VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
Carlos Lopez aebe0e
                    BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
Carlos Lopez aebe0e
                done
Carlos Lopez aebe0e
            fi
Carlos Lopez aebe0e
        else
Carlos Lopez aebe0e
            if test "$cross_compiling" != yes; then
Carlos Lopez aebe0e
                for ac_boost_path in /usr /usr/local /opt /opt/local ; do
Carlos Lopez aebe0e
                    if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
Carlos Lopez aebe0e
                        for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
Carlos Lopez aebe0e
                            _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
Carlos Lopez aebe0e
                            V_CHECK=`expr $_version_tmp \> $_version`
Carlos Lopez aebe0e
                            if test "$V_CHECK" = "1" ; then
Carlos Lopez aebe0e
                                _version=$_version_tmp
Carlos Lopez aebe0e
                                best_path=$ac_boost_path
Carlos Lopez aebe0e
                            fi
Carlos Lopez aebe0e
                        done
Carlos Lopez aebe0e
                    fi
Carlos Lopez aebe0e
                done
Carlos Lopez aebe0e
Carlos Lopez aebe0e
                VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
Carlos Lopez aebe0e
                BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
Carlos Lopez aebe0e
                if test "$ac_boost_lib_path" = ""; then
Carlos Lopez aebe0e
                    for libsubdir in $libsubdirs ; do
Carlos Lopez aebe0e
                        if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
Carlos Lopez aebe0e
                    done
Carlos Lopez aebe0e
                    BOOST_LDFLAGS="-L$best_path/$libsubdir"
Carlos Lopez aebe0e
                fi
Carlos Lopez aebe0e
            fi
Carlos Lopez aebe0e
Carlos Lopez aebe0e
            if test "x$BOOST_ROOT" != "x"; then
Carlos Lopez aebe0e
                for libsubdir in $libsubdirs ; do
Carlos Lopez aebe0e
                    if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
Carlos Lopez aebe0e
                done
Carlos Lopez aebe0e
                if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
Carlos Lopez aebe0e
                    version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
Carlos Lopez aebe0e
                    stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
Carlos Lopez aebe0e
                        stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
Carlos Lopez aebe0e
                    V_CHECK=`expr $stage_version_shorten \>\= $_version`
Carlos Lopez aebe0e
                    if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
Carlos Lopez aebe0e
                        AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
Carlos Lopez aebe0e
                        BOOST_CPPFLAGS="-I$BOOST_ROOT"
Carlos Lopez aebe0e
                        BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
Carlos Lopez aebe0e
                    fi
Carlos Lopez aebe0e
                fi
Carlos Lopez aebe0e
            fi
Carlos Lopez aebe0e
        fi
Carlos Lopez aebe0e
Carlos Lopez aebe0e
        CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
Carlos Lopez aebe0e
        export CPPFLAGS
Carlos Lopez aebe0e
        LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
Carlos Lopez aebe0e
        export LDFLAGS
Carlos Lopez aebe0e
Carlos Lopez aebe0e
        AC_LANG_PUSH(C++)
Carlos Lopez aebe0e
            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Carlos Lopez aebe0e
        @%:@include <boost version.hpp=""></boost>
Carlos Lopez aebe0e
        ]], [[
Carlos Lopez aebe0e
        #if BOOST_VERSION >= $WANT_BOOST_VERSION
Carlos Lopez aebe0e
        // Everything is okay
Carlos Lopez aebe0e
        #else
Carlos Lopez aebe0e
        #  error Boost version is too old
Carlos Lopez aebe0e
        #endif
Carlos Lopez aebe0e
        ]])],[
Carlos Lopez aebe0e
            AC_MSG_RESULT(yes)
Carlos Lopez aebe0e
        succeeded=yes
Carlos Lopez aebe0e
        found_system=yes
Carlos Lopez aebe0e
            ],[
Carlos Lopez aebe0e
            ])
Carlos Lopez aebe0e
        AC_LANG_POP([C++])
Carlos Lopez aebe0e
    fi
Carlos Lopez aebe0e
Carlos Lopez aebe0e
    if test "$succeeded" != "yes" ; then
Carlos Lopez aebe0e
        if test "$_version" = "0" ; then
Carlos Lopez aebe0e
            AC_MSG_NOTICE([[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.]])</boost>
Carlos Lopez aebe0e
        else
Carlos Lopez aebe0e
            AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
Carlos Lopez aebe0e
        fi
Carlos Lopez aebe0e
        # execute ACTION-IF-NOT-FOUND (if present):
Carlos Lopez aebe0e
        ifelse([$3], , :, [$3])
Carlos Lopez aebe0e
    else
Carlos Lopez aebe0e
        AC_SUBST(BOOST_CPPFLAGS)
Carlos Lopez aebe0e
        AC_SUBST(BOOST_LDFLAGS)
Carlos Lopez aebe0e
        AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
Carlos Lopez aebe0e
        # execute ACTION-IF-FOUND (if present):
Carlos Lopez aebe0e
        ifelse([$2], , :, [$2])
Carlos Lopez aebe0e
    fi
Carlos Lopez aebe0e
Carlos Lopez aebe0e
    CPPFLAGS="$CPPFLAGS_SAVED"
Carlos Lopez aebe0e
    LDFLAGS="$LDFLAGS_SAVED"
Diego Barrios Romero a8fd5f
fi
Diego Barrios Romero a8fd5f
Diego Barrios Romero a8fd5f
])