2013-05-28 01:55:01 +02:00
|
|
|
# ===========================================================================
|
2019-09-21 03:29:16 +02:00
|
|
|
# https://www.gnu.org/software/autoconf-archive/ax_boost_thread.html
|
2013-05-28 01:55:01 +02:00
|
|
|
# ===========================================================================
|
|
|
|
#
|
|
|
|
# SYNOPSIS
|
|
|
|
#
|
|
|
|
# AX_BOOST_THREAD
|
|
|
|
#
|
|
|
|
# DESCRIPTION
|
|
|
|
#
|
|
|
|
# Test for Thread library from the Boost C++ libraries. The macro requires
|
|
|
|
# a preceding call to AX_BOOST_BASE. Further documentation is available at
|
|
|
|
# <http://randspringer.de/boost/index.html>.
|
|
|
|
#
|
|
|
|
# This macro calls:
|
|
|
|
#
|
|
|
|
# AC_SUBST(BOOST_THREAD_LIB)
|
|
|
|
#
|
|
|
|
# And sets:
|
|
|
|
#
|
|
|
|
# HAVE_BOOST_THREAD
|
|
|
|
#
|
|
|
|
# LICENSE
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
|
|
|
|
# Copyright (c) 2009 Michael Tindal
|
|
|
|
#
|
|
|
|
# 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. This file is offered as-is, without any
|
|
|
|
# warranty.
|
|
|
|
|
2020-08-24 15:27:19 +02:00
|
|
|
#serial 33
|
2013-05-28 01:55:01 +02:00
|
|
|
|
|
|
|
AC_DEFUN([AX_BOOST_THREAD],
|
|
|
|
[
|
2019-09-21 03:29:16 +02:00
|
|
|
AC_ARG_WITH([boost-thread],
|
|
|
|
AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@],
|
|
|
|
[use the Thread library from boost -
|
|
|
|
it is possible to specify a certain library for the linker
|
|
|
|
e.g. --with-boost-thread=boost_thread-gcc-mt ]),
|
2013-05-28 01:55:01 +02:00
|
|
|
[
|
2019-09-21 03:29:16 +02:00
|
|
|
if test "$withval" = "yes"; then
|
2013-05-28 01:55:01 +02:00
|
|
|
want_boost="yes"
|
|
|
|
ax_boost_user_thread_lib=""
|
|
|
|
else
|
2019-09-21 03:29:16 +02:00
|
|
|
want_boost="yes"
|
|
|
|
ax_boost_user_thread_lib="$withval"
|
|
|
|
fi
|
2013-05-28 01:55:01 +02:00
|
|
|
],
|
|
|
|
[want_boost="yes"]
|
2019-09-21 03:29:16 +02:00
|
|
|
)
|
2013-05-28 01:55:01 +02:00
|
|
|
|
2019-09-21 03:29:16 +02:00
|
|
|
if test "x$want_boost" = "xyes"; then
|
2013-05-28 01:55:01 +02:00
|
|
|
AC_REQUIRE([AC_PROG_CC])
|
|
|
|
AC_REQUIRE([AC_CANONICAL_BUILD])
|
2019-09-21 03:29:16 +02:00
|
|
|
CPPFLAGS_SAVED="$CPPFLAGS"
|
|
|
|
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
|
|
|
export CPPFLAGS
|
2013-05-28 01:55:01 +02:00
|
|
|
|
2019-09-21 03:29:16 +02:00
|
|
|
LDFLAGS_SAVED="$LDFLAGS"
|
|
|
|
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
|
|
|
export LDFLAGS
|
2013-05-28 01:55:01 +02:00
|
|
|
|
|
|
|
AC_CACHE_CHECK(whether the Boost::Thread library is available,
|
2019-09-21 03:29:16 +02:00
|
|
|
ax_cv_boost_thread,
|
2013-05-28 01:55:01 +02:00
|
|
|
[AC_LANG_PUSH([C++])
|
2019-09-21 03:29:16 +02:00
|
|
|
CXXFLAGS_SAVE=$CXXFLAGS
|
2013-05-28 01:55:01 +02:00
|
|
|
|
2020-08-24 15:27:19 +02:00
|
|
|
case "x$host_os" in
|
|
|
|
xsolaris )
|
|
|
|
CXXFLAGS="-pthreads $CXXFLAGS"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
xmingw32 )
|
|
|
|
CXXFLAGS="-mthreads $CXXFLAGS"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
*android* )
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
CXXFLAGS="-pthread $CXXFLAGS"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2019-09-21 03:29:16 +02:00
|
|
|
AC_COMPILE_IFELSE([
|
|
|
|
AC_LANG_PROGRAM(
|
|
|
|
[[@%:@include <boost/thread/thread.hpp>]],
|
|
|
|
[[boost::thread_group thrds;
|
|
|
|
return 0;]])],
|
|
|
|
ax_cv_boost_thread=yes, ax_cv_boost_thread=no)
|
|
|
|
CXXFLAGS=$CXXFLAGS_SAVE
|
2013-05-28 01:55:01 +02:00
|
|
|
AC_LANG_POP([C++])
|
2019-09-21 03:29:16 +02:00
|
|
|
])
|
|
|
|
if test "x$ax_cv_boost_thread" = "xyes"; then
|
2020-08-24 15:27:19 +02:00
|
|
|
case "x$host_os" in
|
|
|
|
xsolaris )
|
|
|
|
BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
xmingw32 )
|
|
|
|
BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
*android* )
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
esac
|
2013-05-28 01:55:01 +02:00
|
|
|
|
2019-09-21 03:29:16 +02:00
|
|
|
AC_SUBST(BOOST_CPPFLAGS)
|
2013-05-28 01:55:01 +02:00
|
|
|
|
2019-09-21 03:29:16 +02:00
|
|
|
AC_DEFINE(HAVE_BOOST_THREAD,,
|
|
|
|
[define if the Boost::Thread library is available])
|
2013-05-28 01:55:01 +02:00
|
|
|
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
|
|
|
|
|
2019-09-21 03:29:16 +02:00
|
|
|
LDFLAGS_SAVE=$LDFLAGS
|
2013-11-15 13:01:23 +01:00
|
|
|
case "x$host_os" in
|
|
|
|
*bsd* )
|
|
|
|
LDFLAGS="-pthread $LDFLAGS"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
esac
|
2013-05-28 01:55:01 +02:00
|
|
|
if test "x$ax_boost_user_thread_lib" = "x"; then
|
2013-11-15 13:01:23 +01:00
|
|
|
for libextension in `ls -r $BOOSTLIBDIR/libboost_thread* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'`; do
|
2013-05-28 01:55:01 +02:00
|
|
|
ax_lib=${libextension}
|
2019-09-21 03:29:16 +02:00
|
|
|
AC_CHECK_LIB($ax_lib, exit,
|
|
|
|
[link_thread="yes"; break],
|
2013-05-28 01:55:01 +02:00
|
|
|
[link_thread="no"])
|
2019-09-21 03:29:16 +02:00
|
|
|
done
|
2013-05-28 01:55:01 +02:00
|
|
|
if test "x$link_thread" != "xyes"; then
|
2013-11-15 13:01:23 +01:00
|
|
|
for libextension in `ls -r $BOOSTLIBDIR/boost_thread* 2>/dev/null | sed 's,.*/,,' | sed 's,\..*,,'`; do
|
2013-05-28 01:55:01 +02:00
|
|
|
ax_lib=${libextension}
|
2019-09-21 03:29:16 +02:00
|
|
|
AC_CHECK_LIB($ax_lib, exit,
|
|
|
|
[link_thread="yes"; break],
|
2013-05-28 01:55:01 +02:00
|
|
|
[link_thread="no"])
|
2019-09-21 03:29:16 +02:00
|
|
|
done
|
2013-05-28 01:55:01 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do
|
2019-09-21 03:29:16 +02:00
|
|
|
AC_CHECK_LIB($ax_lib, exit,
|
|
|
|
[link_thread="yes"; break],
|
2013-05-28 01:55:01 +02:00
|
|
|
[link_thread="no"])
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
|
|
|
if test "x$ax_lib" = "x"; then
|
2019-09-21 03:29:16 +02:00
|
|
|
AC_MSG_ERROR(Could not find a version of the Boost::Thread library!)
|
2013-05-28 01:55:01 +02:00
|
|
|
fi
|
2019-09-21 03:29:16 +02:00
|
|
|
if test "x$link_thread" = "xno"; then
|
|
|
|
AC_MSG_ERROR(Could not link against $ax_lib !)
|
|
|
|
else
|
|
|
|
BOOST_THREAD_LIB="-l$ax_lib"
|
|
|
|
case "x$host_os" in
|
|
|
|
*bsd* )
|
|
|
|
BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
xsolaris )
|
|
|
|
BOOST_THREAD_LIB="$BOOST_THREAD_LIB -lpthread"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
xmingw32 )
|
|
|
|
break;
|
|
|
|
;;
|
2020-08-24 15:27:19 +02:00
|
|
|
*android* )
|
|
|
|
break;
|
|
|
|
;;
|
2019-09-21 03:29:16 +02:00
|
|
|
* )
|
|
|
|
BOOST_THREAD_LIB="$BOOST_THREAD_LIB -lpthread"
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
AC_SUBST(BOOST_THREAD_LIB)
|
|
|
|
fi
|
|
|
|
fi
|
2013-05-28 01:55:01 +02:00
|
|
|
|
2019-09-21 03:29:16 +02:00
|
|
|
CPPFLAGS="$CPPFLAGS_SAVED"
|
|
|
|
LDFLAGS="$LDFLAGS_SAVED"
|
|
|
|
fi
|
2013-05-28 01:55:01 +02:00
|
|
|
])
|