PageRenderTime 41ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/m4/ax_boost_thread.m4

http://github.com/mozy/mordor
m4 | 149 lines | 104 code | 13 blank | 32 comment | 0 complexity | f6c41db1f191380670192b1416ec144e MD5 | raw file
Possible License(s): BSD-3-Clause
  1. # ===========================================================================
  2. # http://www.gnu.org/software/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. #serial 22
  33. AC_DEFUN([AX_BOOST_THREAD],
  34. [
  35. AC_ARG_WITH([boost-thread],
  36. AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@],
  37. [use the Thread library from boost - it is possible to specify a certain library for the linker
  38. e.g. --with-boost-thread=boost_thread-gcc-mt ]),
  39. [
  40. if test "$withval" = "no"; then
  41. want_boost="no"
  42. elif test "$withval" = "yes"; then
  43. want_boost="yes"
  44. ax_boost_user_thread_lib=""
  45. else
  46. want_boost="yes"
  47. ax_boost_user_thread_lib="$withval"
  48. fi
  49. ],
  50. [want_boost="yes"]
  51. )
  52. if test "x$want_boost" = "xyes"; then
  53. AC_REQUIRE([AC_PROG_CC])
  54. AC_REQUIRE([AC_CANONICAL_BUILD])
  55. CPPFLAGS_SAVED="$CPPFLAGS"
  56. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  57. export CPPFLAGS
  58. LDFLAGS_SAVED="$LDFLAGS"
  59. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  60. export LDFLAGS
  61. AC_CACHE_CHECK(whether the Boost::Thread library is available,
  62. ax_cv_boost_thread,
  63. [AC_LANG_PUSH([C++])
  64. CXXFLAGS_SAVE=$CXXFLAGS
  65. if test "x$build_os" = "xsolaris" ; then
  66. CXXFLAGS="-pthreads $CXXFLAGS"
  67. elif test "x$build_os" = "xming32" ; then
  68. CXXFLAGS="-mthreads $CXXFLAGS"
  69. else
  70. CXXFLAGS="-pthread $CXXFLAGS"
  71. fi
  72. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/thread/thread.hpp>]],
  73. [[boost::thread_group thrds;
  74. return 0;]])],
  75. ax_cv_boost_thread=yes, ax_cv_boost_thread=no)
  76. CXXFLAGS=$CXXFLAGS_SAVE
  77. AC_LANG_POP([C++])
  78. ])
  79. if test "x$ax_cv_boost_thread" = "xyes"; then
  80. if test "x$build_os" = "xsolaris" ; then
  81. BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
  82. elif test "x$build_os" = "xming32" ; then
  83. BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
  84. else
  85. BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
  86. fi
  87. AC_SUBST(BOOST_CPPFLAGS)
  88. AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available])
  89. BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
  90. LDFLAGS_SAVE=$LDFLAGS
  91. case "x$build_os" in
  92. *bsd* )
  93. LDFLAGS="-pthread $LDFLAGS"
  94. break;
  95. ;;
  96. esac
  97. if test "x$ax_boost_user_thread_lib" = "x"; then
  98. 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
  99. ax_lib=${libextension}
  100. AC_CHECK_LIB($ax_lib, exit,
  101. [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
  102. [link_thread="no"])
  103. done
  104. if test "x$link_thread" != "xyes"; then
  105. 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
  106. ax_lib=${libextension}
  107. AC_CHECK_LIB($ax_lib, exit,
  108. [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
  109. [link_thread="no"])
  110. done
  111. fi
  112. else
  113. for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do
  114. AC_CHECK_LIB($ax_lib, exit,
  115. [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
  116. [link_thread="no"])
  117. done
  118. fi
  119. if test "x$ax_lib" = "x"; then
  120. AC_MSG_ERROR(Could not find a version of the library!)
  121. fi
  122. if test "x$link_thread" = "xno"; then
  123. AC_MSG_ERROR(Could not link against $ax_lib !)
  124. else
  125. case "x$build_os" in
  126. *bsd* )
  127. BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS"
  128. break;
  129. ;;
  130. esac
  131. fi
  132. fi
  133. CPPFLAGS="$CPPFLAGS_SAVED"
  134. LDFLAGS="$LDFLAGS_SAVED"
  135. fi
  136. ])