| 1 | dnl @synopsis AX_BOOST_THREAD |
|---|
| 2 | dnl |
|---|
| 3 | dnl Test for Thread library from the Boost C++ libraries. The macro |
|---|
| 4 | dnl requires a preceding call to AX_BOOST_BASE. Further documentation |
|---|
| 5 | dnl is available at <http://randspringer.de/boost/index.html>. |
|---|
| 6 | dnl |
|---|
| 7 | dnl This macro calls: |
|---|
| 8 | dnl |
|---|
| 9 | dnl AC_SUBST(BOOST_THREAD_LIB) |
|---|
| 10 | dnl |
|---|
| 11 | dnl And sets: |
|---|
| 12 | dnl |
|---|
| 13 | dnl HAVE_BOOST_THREAD |
|---|
| 14 | dnl |
|---|
| 15 | dnl @category InstalledPackages |
|---|
| 16 | dnl @category Cxx |
|---|
| 17 | dnl @author Thomas Porschberg <thomas@randspringer.de> |
|---|
| 18 | dnl @author Michael Tindal <mtindal@paradoxpoint.com> |
|---|
| 19 | dnl @version 2006-06-15 |
|---|
| 20 | dnl @license AllPermissive |
|---|
| 21 | |
|---|
| 22 | AC_DEFUN([AX_BOOST_THREAD], |
|---|
| 23 | [ |
|---|
| 24 | AC_ARG_WITH([boost-thread], |
|---|
| 25 | AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@], |
|---|
| 26 | [use the Thread library from boost - it is possible to specify a certain library for the linker |
|---|
| 27 | e.g. --with-boost-thread=boost_thread-gcc-mt ]), |
|---|
| 28 | [ |
|---|
| 29 | if test "$withval" = "no"; then |
|---|
| 30 | want_boost="no" |
|---|
| 31 | elif test "$withval" = "yes"; then |
|---|
| 32 | want_boost="yes" |
|---|
| 33 | ax_boost_user_thread_lib="" |
|---|
| 34 | else |
|---|
| 35 | want_boost="yes" |
|---|
| 36 | ax_boost_user_thread_lib="$withval" |
|---|
| 37 | fi |
|---|
| 38 | ], |
|---|
| 39 | [want_boost="yes"] |
|---|
| 40 | ) |
|---|
| 41 | |
|---|
| 42 | if test "x$want_boost" = "xyes"; then |
|---|
| 43 | AC_REQUIRE([AC_PROG_CC]) |
|---|
| 44 | CPPFLAGS_SAVED="$CPPFLAGS" |
|---|
| 45 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" |
|---|
| 46 | export CPPFLAGS |
|---|
| 47 | |
|---|
| 48 | LDFLAGS_SAVED="$LDFLAGS" |
|---|
| 49 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" |
|---|
| 50 | export LDFLAGS |
|---|
| 51 | |
|---|
| 52 | AC_CACHE_CHECK(whether the Boost::Thread library is available, |
|---|
| 53 | ax_cv_boost_thread, |
|---|
| 54 | [AC_LANG_PUSH([C++]) |
|---|
| 55 | CXXFLAGS_SAVE=$CXXFLAGS |
|---|
| 56 | |
|---|
| 57 | if test "x$build_os" = "xsolaris" ; then |
|---|
| 58 | CXXFLAGS="-pthreads $CXXFLAGS" |
|---|
| 59 | elif test "x$build_os" = "xming32" ; then |
|---|
| 60 | CXXFLAGS="-mthreads $CXXFLAGS" |
|---|
| 61 | else |
|---|
| 62 | CXXFLAGS="-pthread $CXXFLAGS" |
|---|
| 63 | fi |
|---|
| 64 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/thread/thread.hpp>]], |
|---|
| 65 | [[boost::thread_group thrds; |
|---|
| 66 | return 0;]]), |
|---|
| 67 | ax_cv_boost_thread=yes, ax_cv_boost_thread=no) |
|---|
| 68 | CXXFLAGS=$CXXFLAGS_SAVE |
|---|
| 69 | AC_LANG_POP([C++]) |
|---|
| 70 | ]) |
|---|
| 71 | if test "x$ax_cv_boost_thread" = "xyes"; then |
|---|
| 72 | if test "x$build_os" = "xsolaris" ; then |
|---|
| 73 | BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS" |
|---|
| 74 | elif test "x$build_os" = "xming32" ; then |
|---|
| 75 | BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS" |
|---|
| 76 | else |
|---|
| 77 | BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS" |
|---|
| 78 | fi |
|---|
| 79 | |
|---|
| 80 | AC_SUBST(BOOST_CPPFLAGS) |
|---|
| 81 | |
|---|
| 82 | AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Date_Time library is available]) |
|---|
| 83 | BN=boost_thread |
|---|
| 84 | |
|---|
| 85 | if test "x$ax_boost_user_thread_lib" = "x"; then |
|---|
| 86 | for ax_lib in $BN $BN-$CC $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \ |
|---|
| 87 | lib$BN lib$BN-$CC lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \ |
|---|
| 88 | $BN-mgw $BN-mgw $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do |
|---|
| 89 | AC_CHECK_LIB($ax_lib, main, [BOOST_THREAD_LIB="-l$ax_lib" AC_SUBST(BOOST_THREAD_LIB) link_thread="yes" break], |
|---|
| 90 | [link_thread="no"]) |
|---|
| 91 | done |
|---|
| 92 | else |
|---|
| 93 | for ax_lib in $ax_boost_user_thread_lib $BN-$ax_boost_user_thread_lib; do |
|---|
| 94 | AC_CHECK_LIB($ax_lib, main, |
|---|
| 95 | [BOOST_THREAD_LIB="-l$ax_lib" AC_SUBST(BOOST_THREAD_LIB) link_thread="yes" break], |
|---|
| 96 | [link_thread="no"]) |
|---|
| 97 | done |
|---|
| 98 | |
|---|
| 99 | fi |
|---|
| 100 | if test "x$link_thread" = "xno"; then |
|---|
| 101 | AC_MSG_ERROR(Could not link against $ax_lib !) |
|---|
| 102 | fi |
|---|
| 103 | fi |
|---|
| 104 | |
|---|
| 105 | CPPFLAGS="$CPPFLAGS_SAVED" |
|---|
| 106 | LDFLAGS="$LDFLAGS_SAVED" |
|---|
| 107 | fi |
|---|
| 108 | ]) |
|---|