ax_boost_include.m4 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. dnl @synopsis AX_BOOST_INCLUDE
  2. dnl
  3. dnl Test for the Boost C++ header files
  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
  9. dnl This macro calls:
  10. dnl
  11. dnl AC_SUBST(BOOST_CPPFLAGS)
  12. dnl
  13. AC_DEFUN([AX_BOOST_INCLUDE], [
  14. AC_LANG_SAVE
  15. AC_LANG([C++])
  16. #
  17. # Configure Boost header path
  18. #
  19. # If explicitly specified, use it.
  20. AC_ARG_WITH([boost-include],
  21. AS_HELP_STRING([--with-boost-include=PATH],
  22. [specify exact directory for Boost headers]),
  23. [boost_include_path="$withval"])
  24. # If not specified, try some common paths.
  25. if test -z "$with_boost_include"; then
  26. boostdirs="/usr/local /usr/pkg /opt /opt/local"
  27. for d in $boostdirs
  28. do
  29. if test -f $d/include/boost/shared_ptr.hpp; then
  30. boost_include_path=$d/include
  31. break
  32. fi
  33. done
  34. fi
  35. CPPFLAGS_SAVED="$CPPFLAGS"
  36. if test "${boost_include_path}" ; then
  37. BOOST_CPPFLAGS="-I${boost_include_path}"
  38. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  39. fi
  40. # Make sure some commonly used headers are available
  41. AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/bind.hpp boost/function.hpp],,
  42. AC_MSG_ERROR([Missing required Boost header files.]))
  43. # Detect whether Boost tries to use threads by default, and, if not,
  44. # make it sure explicitly. In some systems the automatic detection
  45. # may depend on preceding header files, and if inconsistency happens
  46. # it could lead to a critical disruption.
  47. AC_MSG_CHECKING([whether Boost tries to use threads])
  48. AC_TRY_COMPILE([
  49. #include <boost/config.hpp>
  50. #ifdef BOOST_HAS_THREADS
  51. #error "boost will use threads"
  52. #endif],,
  53. [AC_MSG_RESULT(no)
  54. CPPFLAGS_BOOST_THREADCONF="-DBOOST_DISABLE_THREADS=1"],
  55. [AC_MSG_RESULT(yes)])
  56. CPPFLAGS="$CPPFLAGS_SAVED $CPPFLAGS_BOOST_THREADCONF"
  57. AC_SUBST(BOOST_CPPFLAGS)
  58. AC_LANG_RESTORE
  59. ])dnl AX_BOOST_INCLUDE