ax_boost_for_bind10.m4 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. dnl @synopsis AX_BOOST_FOR_BIND10
  2. dnl
  3. dnl Test for the Boost C++ header files intended to be used within BIND 10
  4. dnl
  5. dnl If no path to the installed boost header files is given via the
  6. dnl --with-boost-include option, the macro searchs under
  7. dnl /usr/local /usr/pkg /opt /opt/local directories.
  8. dnl If it cannot detect any workable path for Boost, this macro treats it
  9. dnl as a fatal error (so it cannot be called if the availability of Boost
  10. dnl is optional).
  11. dnl
  12. dnl This macro also tries to identify some known portability issues, and
  13. dnl sets corresponding variables so the caller can react to (or ignore,
  14. dnl depending on other configuration) specific issues appropriately.
  15. dnl
  16. dnl This macro calls:
  17. dnl
  18. dnl AC_SUBST(BOOST_INCLUDES)
  19. dnl
  20. dnl And possibly sets:
  21. dnl CPPFLAGS_BOOST_THREADCONF should be added to CPPFLAGS by caller
  22. dnl BOOST_OFFSET_PTR_WOULDFAIL set to yes if offset_ptr would cause build
  23. dnl error; otherwise set to no
  24. dnl
  25. AC_DEFUN([AX_BOOST_FOR_BIND10], [
  26. AC_LANG_SAVE
  27. AC_LANG([C++])
  28. #
  29. # Configure Boost header path
  30. #
  31. # If explicitly specified, use it.
  32. AC_ARG_WITH([boost-include],
  33. AC_HELP_STRING([--with-boost-include=PATH],
  34. [specify exact directory for Boost headers]),
  35. [boost_include_path="$withval"])
  36. # If not specified, try some common paths.
  37. if test -z "$with_boost_include"; then
  38. boostdirs="/usr/local /usr/pkg /opt /opt/local"
  39. for d in $boostdirs
  40. do
  41. if test -f $d/include/boost/shared_ptr.hpp; then
  42. boost_include_path=$d/include
  43. break
  44. fi
  45. done
  46. fi
  47. # Check the path with some specific headers.
  48. CPPFLAGS_SAVED="$CPPFLAGS"
  49. if test "${boost_include_path}" ; then
  50. BOOST_INCLUDES="-I${boost_include_path}"
  51. CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES"
  52. fi
  53. AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/foreach.hpp boost/interprocess/sync/interprocess_upgradable_mutex.hpp boost/date_time/posix_time/posix_time_types.hpp boost/bind.hpp boost/function.hpp],,
  54. AC_MSG_ERROR([Missing required header files.]))
  55. # Detect whether Boost tries to use threads by default, and, if not,
  56. # make it sure explicitly. In some systems the automatic detection
  57. # may depend on preceding header files, and if inconsistency happens
  58. # it could lead to a critical disruption.
  59. AC_MSG_CHECKING([whether Boost tries to use threads])
  60. AC_TRY_COMPILE([
  61. #include <boost/config.hpp>
  62. #ifdef BOOST_HAS_THREADS
  63. #error "boost will use threads"
  64. #endif],,
  65. [AC_MSG_RESULT(no)
  66. CPPFLAGS_BOOST_THREADCONF="-DBOOST_DISABLE_THREADS=1"],
  67. [AC_MSG_RESULT(yes)])
  68. # Boost offset_ptr is known to not compile on some platforms, depending on
  69. # boost version, its local configuration, and compiler. Detect it.
  70. AC_MSG_CHECKING([Boost offset_ptr compiles])
  71. AC_TRY_COMPILE([
  72. #include <boost/interprocess/offset_ptr.hpp>
  73. ],,
  74. [AC_MSG_RESULT(yes)
  75. BOOST_OFFSET_PTR_WOULDFAIL=no],
  76. [AC_MSG_RESULT(no)
  77. BOOST_OFFSET_PTR_WOULDFAIL=yes])
  78. AC_SUBST(BOOST_INCLUDES)
  79. CPPFLAGS="$CPPFLAGS_SAVED"
  80. AC_LANG_RESTORE
  81. ])dnl AX_BOOST_FOR_BIND10