1 ##### http://autoconf-archive.cryp.to/ax_boost_thread.html
9 # Test for Thread library from the Boost C++ libraries. The macro
10 # requires a preceding call to AX_BOOST_BASE. Further documentation
11 # is available at <http://randspringer.de/boost/index.html>.
15 # AC_SUBST(BOOST_THREAD_LIB)
27 # Copyright (c) 2006 Thomas Porschberg <thomas@randspringer.de>
28 # Copyright (c) 2006 Michael Tindal <mtindal@paradoxpoint.com>
30 # Copying and distribution of this file, with or without
31 # modification, are permitted in any medium without royalty provided
32 # the copyright notice and this notice are preserved.
34 AC_DEFUN([AX_BOOST_THREAD],
36 AC_ARG_WITH([boost-thread],
37 AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@],
38 [use the Thread library from boost - it is possible to specify a certain library for the linker
39 e.g. --with-boost-thread=boost_thread-gcc-mt ]),
41 if test "$withval" = "no"; then
43 elif test "$withval" = "yes"; then
45 ax_boost_user_thread_lib=""
48 ax_boost_user_thread_lib="$withval"
54 if test "x$want_boost" = "xyes"; then
55 AC_REQUIRE([AC_PROG_CC])
56 AC_REQUIRE([AC_CANONICAL_BUILD])
57 CPPFLAGS_SAVED="$CPPFLAGS"
58 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
61 LDFLAGS_SAVED="$LDFLAGS"
62 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
65 AC_CACHE_CHECK(whether the Boost::Thread library is available,
68 CXXFLAGS_SAVE=$CXXFLAGS
70 if test "x$build_os" = "xsolaris" ; then
71 CXXFLAGS="-pthreads $CXXFLAGS"
72 elif test "x$build_os" = "xming32" ; then
73 CXXFLAGS="-mthreads $CXXFLAGS"
75 CXXFLAGS="-pthread $CXXFLAGS"
77 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/thread/thread.hpp>]],
78 [[boost::thread_group thrds;
80 ax_cv_boost_thread=yes, ax_cv_boost_thread=no)
81 CXXFLAGS=$CXXFLAGS_SAVE
84 if test "x$ax_cv_boost_thread" = "xyes"; then
85 if test "x$build_os" = "xsolaris" ; then
86 BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
87 elif test "x$build_os" = "xming32" ; then
88 BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
90 BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
93 AC_SUBST(BOOST_CPPFLAGS)
95 AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available])
101 LDFLAGS="-pthread $LDFLAGS"
105 if test "x$ax_boost_user_thread_lib" = "x"; then
106 for ax_lib in $BN $BN-$CC $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \
107 lib$BN lib$BN-$CC lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \
108 $BN-mgw $BN-mgw $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do
109 AC_CHECK_LIB($ax_lib, main, [BOOST_THREAD_LIB="-l$ax_lib" AC_SUBST(BOOST_THREAD_LIB) link_thread="yes" break],
113 for ax_lib in $ax_boost_user_thread_lib $BN-$ax_boost_user_thread_lib; do
114 AC_CHECK_LIB($ax_lib, main,
115 [BOOST_THREAD_LIB="-l$ax_lib" AC_SUBST(BOOST_THREAD_LIB) link_thread="yes" break],
120 if test "x$link_thread" = "xno"; then
121 AC_MSG_ERROR(Could not link against $ax_lib !)
125 BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS"
133 CPPFLAGS="$CPPFLAGS_SAVED"
134 LDFLAGS="$LDFLAGS_SAVED"