[4d9c01] | 1 | # ===========================================================================
|
---|
| 2 | # http://www.nongnu.org/autoconf-archive/ax_boost_thread.html
|
---|
| 3 | # ===========================================================================
|
---|
| 4 | #
|
---|
| 5 | # SYNOPSIS
|
---|
| 6 | #
|
---|
| 7 | # AX_BOOST_THREAD
|
---|
| 8 | #
|
---|
| 9 | # DESCRIPTION
|
---|
| 10 | #
|
---|
| 11 | # Test for Thread library from the Boost C++ libraries. The macro requires
|
---|
| 12 | # a preceding call to AX_BOOST_BASE. Further documentation is available at
|
---|
| 13 | # <http://randspringer.de/boost/index.html>.
|
---|
| 14 | #
|
---|
| 15 | # This macro calls:
|
---|
| 16 | #
|
---|
| 17 | # AC_SUBST(BOOST_THREAD_LIB)
|
---|
| 18 | #
|
---|
| 19 | # And sets:
|
---|
| 20 | #
|
---|
| 21 | # HAVE_BOOST_THREAD
|
---|
| 22 | #
|
---|
| 23 | # LICENSE
|
---|
| 24 | #
|
---|
| 25 | # Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
|
---|
| 26 | # Copyright (c) 2009 Michael Tindal
|
---|
| 27 | #
|
---|
| 28 | # Copying and distribution of this file, with or without modification, are
|
---|
| 29 | # permitted in any medium without royalty provided the copyright notice
|
---|
| 30 | # and this notice are preserved. This file is offered as-is, without any
|
---|
| 31 | # warranty.
|
---|
| 32 |
|
---|
| 33 | #serial 14
|
---|
| 34 |
|
---|
| 35 | AC_DEFUN([AX_BOOST_THREAD],
|
---|
| 36 | [
|
---|
| 37 | AC_ARG_WITH([boost-thread],
|
---|
| 38 | AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@],
|
---|
| 39 | [use the Thread library from boost - it is possible to specify a certain library for the linker
|
---|
| 40 | e.g. --with-boost-thread=boost_thread-gcc-mt ]),
|
---|
| 41 | [
|
---|
| 42 | if test "$withval" = "no"; then
|
---|
| 43 | want_boost="no"
|
---|
| 44 | elif test "$withval" = "yes"; then
|
---|
| 45 | want_boost="yes"
|
---|
| 46 | ax_boost_user_thread_lib=""
|
---|
| 47 | else
|
---|
| 48 | want_boost="yes"
|
---|
| 49 | ax_boost_user_thread_lib="$withval"
|
---|
| 50 | fi
|
---|
| 51 | ],
|
---|
| 52 | [want_boost="yes"]
|
---|
| 53 | )
|
---|
| 54 |
|
---|
| 55 | if test "x$want_boost" = "xyes"; then
|
---|
| 56 | AC_REQUIRE([AC_PROG_CC])
|
---|
| 57 | AC_REQUIRE([AC_CANONICAL_BUILD])
|
---|
| 58 | CPPFLAGS_SAVED="$CPPFLAGS"
|
---|
| 59 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
---|
| 60 | export CPPFLAGS
|
---|
| 61 |
|
---|
| 62 | LDFLAGS_SAVED="$LDFLAGS"
|
---|
| 63 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
---|
| 64 | export LDFLAGS
|
---|
| 65 |
|
---|
| 66 | AC_CACHE_CHECK(whether the Boost::Thread library is available,
|
---|
| 67 | ax_cv_boost_thread,
|
---|
| 68 | [AC_LANG_PUSH([C++])
|
---|
| 69 | CXXFLAGS_SAVE=$CXXFLAGS
|
---|
| 70 |
|
---|
| 71 | if test "x$build_os" = "xsolaris" ; then
|
---|
| 72 | CXXFLAGS="-pthreads $CXXFLAGS"
|
---|
| 73 | elif test "x$build_os" = "xming32" ; then
|
---|
| 74 | CXXFLAGS="-mthreads $CXXFLAGS"
|
---|
| 75 | else
|
---|
| 76 | CXXFLAGS="-pthread $CXXFLAGS"
|
---|
| 77 | fi
|
---|
| 78 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/thread/thread.hpp>]],
|
---|
| 79 | [[boost::thread_group thrds;
|
---|
| 80 | return 0;]]),
|
---|
| 81 | ax_cv_boost_thread=yes, ax_cv_boost_thread=no)
|
---|
| 82 | CXXFLAGS=$CXXFLAGS_SAVE
|
---|
| 83 | AC_LANG_POP([C++])
|
---|
| 84 | ])
|
---|
| 85 | if test "x$ax_cv_boost_thread" = "xyes"; then
|
---|
| 86 | if test "x$build_os" = "xsolaris" ; then
|
---|
| 87 | BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
|
---|
| 88 | elif test "x$build_os" = "xming32" ; then
|
---|
| 89 | BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
|
---|
| 90 | else
|
---|
| 91 | BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
|
---|
| 92 | fi
|
---|
| 93 |
|
---|
| 94 | AC_SUBST(BOOST_CPPFLAGS)
|
---|
| 95 |
|
---|
| 96 | AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available])
|
---|
| 97 | BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
|
---|
| 98 |
|
---|
| 99 | LDFLAGS_SAVE=$LDFLAGS
|
---|
| 100 | case "x$build_os" in
|
---|
| 101 | *bsd* )
|
---|
| 102 | LDFLAGS="-pthread $LDFLAGS"
|
---|
| 103 | break;
|
---|
| 104 | ;;
|
---|
| 105 | esac
|
---|
| 106 | if test "x$ax_boost_user_thread_lib" = "x"; then
|
---|
| 107 | for libextension in `ls $BOOSTLIBDIR/libboost_thread*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.a*$;\1;'`; do
|
---|
| 108 | ax_lib=${libextension}
|
---|
| 109 | AC_CHECK_LIB($ax_lib, exit,
|
---|
| 110 | [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
|
---|
| 111 | [link_thread="no"])
|
---|
| 112 | done
|
---|
| 113 | if test "x$link_thread" != "xyes"; then
|
---|
| 114 | for libextension in `ls $BOOSTLIBDIR/boost_thread*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.dll.*$;\1;'` `ls $BOOSTLIBDIR/boost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.a*$;\1;'` ; do
|
---|
| 115 | ax_lib=${libextension}
|
---|
| 116 | AC_CHECK_LIB($ax_lib, exit,
|
---|
| 117 | [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
|
---|
| 118 | [link_thread="no"])
|
---|
| 119 | done
|
---|
| 120 | fi
|
---|
| 121 |
|
---|
| 122 | else
|
---|
| 123 | for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do
|
---|
| 124 | AC_CHECK_LIB($ax_lib, exit,
|
---|
| 125 | [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
|
---|
| 126 | [link_thread="no"])
|
---|
| 127 | done
|
---|
| 128 |
|
---|
| 129 | fi
|
---|
| 130 | if test "x$link_thread" = "xno"; then
|
---|
| 131 | AC_MSG_ERROR(Could not link against $ax_lib !)
|
---|
| 132 | else
|
---|
| 133 | case "x$build_os" in
|
---|
| 134 | *bsd* )
|
---|
| 135 | BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS"
|
---|
| 136 | break;
|
---|
| 137 | ;;
|
---|
| 138 | esac
|
---|
| 139 |
|
---|
| 140 | fi
|
---|
| 141 | fi
|
---|
| 142 |
|
---|
| 143 | CPPFLAGS="$CPPFLAGS_SAVED"
|
---|
| 144 | LDFLAGS="$LDFLAGS_SAVED"
|
---|
| 145 | fi
|
---|
| 146 | ])
|
---|