Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
5.6KB

  1. # ===========================================================================
  2. # https://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 31
  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 -
  38. it is possible to specify a certain library for the linker
  39. e.g. --with-boost-thread=boost_thread-gcc-mt ]),
  40. [
  41. if test "$withval" = "yes"; then
  42. want_boost="yes"
  43. ax_boost_user_thread_lib=""
  44. else
  45. want_boost="yes"
  46. ax_boost_user_thread_lib="$withval"
  47. fi
  48. ],
  49. [want_boost="yes"]
  50. )
  51. if test "x$want_boost" = "xyes"; then
  52. AC_REQUIRE([AC_PROG_CC])
  53. AC_REQUIRE([AC_CANONICAL_BUILD])
  54. CPPFLAGS_SAVED="$CPPFLAGS"
  55. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  56. export CPPFLAGS
  57. LDFLAGS_SAVED="$LDFLAGS"
  58. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  59. export LDFLAGS
  60. AC_CACHE_CHECK(whether the Boost::Thread library is available,
  61. ax_cv_boost_thread,
  62. [AC_LANG_PUSH([C++])
  63. CXXFLAGS_SAVE=$CXXFLAGS
  64. if test "x$host_os" = "xsolaris" ; then
  65. CXXFLAGS="-pthreads $CXXFLAGS"
  66. elif test "x$host_os" = "xmingw32" ; then
  67. CXXFLAGS="-mthreads $CXXFLAGS"
  68. else
  69. CXXFLAGS="-pthread $CXXFLAGS"
  70. fi
  71. AC_COMPILE_IFELSE([
  72. AC_LANG_PROGRAM(
  73. [[@%:@include <boost/thread/thread.hpp>]],
  74. [[boost::thread_group thrds;
  75. return 0;]])],
  76. ax_cv_boost_thread=yes, ax_cv_boost_thread=no)
  77. CXXFLAGS=$CXXFLAGS_SAVE
  78. AC_LANG_POP([C++])
  79. ])
  80. if test "x$ax_cv_boost_thread" = "xyes"; then
  81. if test "x$host_os" = "xsolaris" ; then
  82. BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
  83. elif test "x$host_os" = "xmingw32" ; then
  84. BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
  85. else
  86. BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
  87. fi
  88. AC_SUBST(BOOST_CPPFLAGS)
  89. AC_DEFINE(HAVE_BOOST_THREAD,,
  90. [define if the Boost::Thread library is available])
  91. BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
  92. LDFLAGS_SAVE=$LDFLAGS
  93. case "x$host_os" in
  94. *bsd* )
  95. LDFLAGS="-pthread $LDFLAGS"
  96. break;
  97. ;;
  98. esac
  99. if test "x$ax_boost_user_thread_lib" = "x"; then
  100. for libextension in `ls -r $BOOSTLIBDIR/libboost_thread* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'`; do
  101. ax_lib=${libextension}
  102. AC_CHECK_LIB($ax_lib, exit,
  103. [link_thread="yes"; break],
  104. [link_thread="no"])
  105. done
  106. if test "x$link_thread" != "xyes"; then
  107. for libextension in `ls -r $BOOSTLIBDIR/boost_thread* 2>/dev/null | sed 's,.*/,,' | sed 's,\..*,,'`; do
  108. ax_lib=${libextension}
  109. AC_CHECK_LIB($ax_lib, exit,
  110. [link_thread="yes"; break],
  111. [link_thread="no"])
  112. done
  113. fi
  114. else
  115. for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do
  116. AC_CHECK_LIB($ax_lib, exit,
  117. [link_thread="yes"; break],
  118. [link_thread="no"])
  119. done
  120. fi
  121. if test "x$ax_lib" = "x"; then
  122. AC_MSG_ERROR(Could not find a version of the library!)
  123. fi
  124. if test "x$link_thread" = "xno"; then
  125. AC_MSG_ERROR(Could not link against $ax_lib !)
  126. else
  127. BOOST_THREAD_LIB="-l$ax_lib"
  128. case "x$host_os" in
  129. *bsd* )
  130. BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS"
  131. break;
  132. ;;
  133. xsolaris )
  134. BOOST_THREAD_LIB="$BOOST_THREAD_LIB -lpthread"
  135. break;
  136. ;;
  137. xmingw32 )
  138. break;
  139. ;;
  140. * )
  141. BOOST_THREAD_LIB="$BOOST_THREAD_LIB -lpthread"
  142. break;
  143. ;;
  144. esac
  145. AC_SUBST(BOOST_THREAD_LIB)
  146. fi
  147. fi
  148. CPPFLAGS="$CPPFLAGS_SAVED"
  149. LDFLAGS="$LDFLAGS_SAVED"
  150. fi
  151. ])