ax_boost_for_kea.m4 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. dnl @synopsis AX_BOOST_FOR_KEA
  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 BOOST_NUMERIC_CAST_WOULDFAIL set to "yes" if numeric_cast would cause
  25. dnl build error; otherwise set to "no"
  26. dnl BOOST_STATIC_ASSERT_WOULDFAIL set to "yes" if BOOST_STATIC_ASSERT would
  27. dnl cause build error; otherwise set to "no"
  28. AC_DEFUN([AX_BOOST_FOR_KEA], [
  29. AC_LANG_SAVE
  30. AC_LANG([C++])
  31. #
  32. # Configure Boost header path
  33. #
  34. # If explicitly specified, use it.
  35. AC_ARG_WITH([boost-include],
  36. AC_HELP_STRING([--with-boost-include=PATH],
  37. [specify exact directory for Boost headers]),
  38. [boost_include_path="$withval"])
  39. # If not specified, try some common paths.
  40. if test -z "$with_boost_include"; then
  41. boostdirs="/usr/local /usr/pkg /opt /opt/local"
  42. for d in $boostdirs
  43. do
  44. if test -f $d/include/boost/shared_ptr.hpp; then
  45. boost_include_path=$d/include
  46. break
  47. fi
  48. done
  49. fi
  50. # Check the path with some specific headers.
  51. CPPFLAGS_SAVED="$CPPFLAGS"
  52. if test "${boost_include_path}" ; then
  53. BOOST_INCLUDES="-I${boost_include_path}"
  54. CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES"
  55. fi
  56. 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],,
  57. AC_MSG_ERROR([Missing required header files.]))
  58. # clang can cause false positives with -Werror without -Qunused-arguments.
  59. # it can be triggered if used with ccache.
  60. AC_CHECK_DECL([__clang__], [CLANG_CXXFLAGS="-Qunused-arguments"], [])
  61. # Detect whether Boost tries to use threads by default, and, if not,
  62. # make it sure explicitly. In some systems the automatic detection
  63. # may depend on preceding header files, and if inconsistency happens
  64. # it could lead to a critical disruption.
  65. AC_MSG_CHECKING([whether Boost tries to use threads])
  66. AC_TRY_COMPILE([
  67. #include <boost/config.hpp>
  68. #ifdef BOOST_HAS_THREADS
  69. #error "boost will use threads"
  70. #endif],,
  71. [AC_MSG_RESULT(no)
  72. CPPFLAGS_BOOST_THREADCONF="-DBOOST_DISABLE_THREADS=1"],
  73. [AC_MSG_RESULT(yes)])
  74. # Boost offset_ptr is known to not compile on some platforms, depending on
  75. # boost version, its local configuration, and compiler. Detect it.
  76. CXXFLAGS_SAVED="$CXXFLAGS"
  77. CXXFLAGS="$CXXFLAGS $CLANG_CXXFLAGS -Werror"
  78. AC_MSG_CHECKING([Boost offset_ptr compiles])
  79. AC_TRY_COMPILE([
  80. #include <boost/interprocess/offset_ptr.hpp>
  81. ],,
  82. [AC_MSG_RESULT(yes)
  83. BOOST_OFFSET_PTR_WOULDFAIL=no],
  84. [AC_MSG_RESULT(no)
  85. BOOST_OFFSET_PTR_WOULDFAIL=yes])
  86. CXXFLAGS="$CXXFLAGS_SAVED"
  87. # Detect build failure case known to happen with Boost installed via
  88. # FreeBSD ports
  89. if test "X$GXX" = "Xyes"; then
  90. CXXFLAGS_SAVED="$CXXFLAGS"
  91. CXXFLAGS="$CXXFLAGS $CLANG_CXXFLAGS -Werror"
  92. AC_MSG_CHECKING([Boost numeric_cast compiles with -Werror])
  93. AC_TRY_COMPILE([
  94. #include <boost/numeric/conversion/cast.hpp>
  95. ],[
  96. return (boost::numeric_cast<short>(0));
  97. ],[AC_MSG_RESULT(yes)
  98. BOOST_NUMERIC_CAST_WOULDFAIL=no],
  99. [AC_MSG_RESULT(no)
  100. BOOST_NUMERIC_CAST_WOULDFAIL=yes])
  101. CXXFLAGS="$CXXFLAGS_SAVED"
  102. else
  103. # This doesn't matter for non-g++
  104. BOOST_NUMERIC_CAST_WOULDFAIL=no
  105. fi
  106. # BOOST_STATIC_ASSERT in versions below Boost 1.54.0 is known to result
  107. # in warnings with GCC 4.8. Detect it.
  108. AC_MSG_CHECKING([BOOST_STATIC_ASSERT compiles])
  109. AC_TRY_COMPILE([
  110. #include <boost/static_assert.hpp>
  111. void testfn(void) { BOOST_STATIC_ASSERT(true); }
  112. ],,
  113. [AC_MSG_RESULT(yes)
  114. BOOST_STATIC_ASSERT_WOULDFAIL=no],
  115. [AC_MSG_RESULT(no)
  116. BOOST_STATIC_ASSERT_WOULDFAIL=yes])
  117. CXXFLAGS="$CXXFLAGS_SAVED"
  118. AC_SUBST(BOOST_INCLUDES)
  119. dnl Determine the Boost version, used mainly for config.report.
  120. AC_MSG_CHECKING([Boost version])
  121. cat > conftest.cpp << EOF
  122. #include <boost/version.hpp>
  123. AUTOCONF_BOOST_LIB_VERSION=BOOST_LIB_VERSION
  124. EOF
  125. BOOST_VERSION=`$CPP $CPPFLAGS conftest.cpp | grep '^AUTOCONF_BOOST_LIB_VERSION=' | $SED -e 's/^AUTOCONF_BOOST_LIB_VERSION=//' -e 's/_/./g' -e 's/"//g' 2> /dev/null`
  126. if test -z "$BOOST_VERSION"; then
  127. BOOST_VERSION="unknown"
  128. fi
  129. $RM -f conftest.cpp
  130. AC_MSG_RESULT([$BOOST_VERSION])
  131. CPPFLAGS="$CPPFLAGS_SAVED"
  132. AC_LANG_RESTORE
  133. ])dnl AX_BOOST_FOR_KEA