2014-08-12 13:09:33 +02:00
|
|
|
dnl @synopsis AX_BOOST_FOR_KEA
|
2012-12-27 17:54:42 -08:00
|
|
|
dnl
|
|
|
|
dnl Test for the Boost C++ header files intended to be used within BIND 10
|
|
|
|
dnl
|
|
|
|
dnl If no path to the installed boost header files is given via the
|
|
|
|
dnl --with-boost-include option, the macro searchs under
|
|
|
|
dnl /usr/local /usr/pkg /opt /opt/local directories.
|
|
|
|
dnl If it cannot detect any workable path for Boost, this macro treats it
|
|
|
|
dnl as a fatal error (so it cannot be called if the availability of Boost
|
|
|
|
dnl is optional).
|
|
|
|
dnl
|
|
|
|
dnl This macro also tries to identify some known portability issues, and
|
|
|
|
dnl sets corresponding variables so the caller can react to (or ignore,
|
|
|
|
dnl depending on other configuration) specific issues appropriately.
|
|
|
|
dnl
|
|
|
|
dnl This macro calls:
|
|
|
|
dnl
|
|
|
|
dnl AC_SUBST(BOOST_INCLUDES)
|
|
|
|
dnl
|
|
|
|
dnl And possibly sets:
|
|
|
|
dnl CPPFLAGS_BOOST_THREADCONF should be added to CPPFLAGS by caller
|
2012-12-27 18:14:36 -08:00
|
|
|
dnl BOOST_OFFSET_PTR_WOULDFAIL set to "yes" if offset_ptr would cause build
|
|
|
|
dnl error; otherwise set to "no"
|
|
|
|
dnl BOOST_NUMERIC_CAST_WOULDFAIL set to "yes" if numeric_cast would cause
|
|
|
|
dnl build error; otherwise set to "no"
|
2013-07-08 08:19:31 +05:30
|
|
|
dnl BOOST_STATIC_ASSERT_WOULDFAIL set to "yes" if BOOST_STATIC_ASSERT would
|
|
|
|
dnl cause build error; otherwise set to "no"
|
2013-08-13 17:20:47 +05:30
|
|
|
|
2014-08-12 13:09:33 +02:00
|
|
|
AC_DEFUN([AX_BOOST_FOR_KEA], [
|
2012-12-27 17:54:42 -08:00
|
|
|
AC_LANG_SAVE
|
|
|
|
AC_LANG([C++])
|
|
|
|
|
|
|
|
#
|
|
|
|
# Configure Boost header path
|
|
|
|
#
|
|
|
|
# If explicitly specified, use it.
|
|
|
|
AC_ARG_WITH([boost-include],
|
|
|
|
AC_HELP_STRING([--with-boost-include=PATH],
|
|
|
|
[specify exact directory for Boost headers]),
|
|
|
|
[boost_include_path="$withval"])
|
|
|
|
# If not specified, try some common paths.
|
|
|
|
if test -z "$with_boost_include"; then
|
|
|
|
boostdirs="/usr/local /usr/pkg /opt /opt/local"
|
|
|
|
for d in $boostdirs
|
|
|
|
do
|
|
|
|
if test -f $d/include/boost/shared_ptr.hpp; then
|
|
|
|
boost_include_path=$d/include
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check the path with some specific headers.
|
|
|
|
CPPFLAGS_SAVED="$CPPFLAGS"
|
|
|
|
if test "${boost_include_path}" ; then
|
|
|
|
BOOST_INCLUDES="-I${boost_include_path}"
|
|
|
|
CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES"
|
|
|
|
fi
|
|
|
|
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],,
|
|
|
|
AC_MSG_ERROR([Missing required header files.]))
|
|
|
|
|
2013-10-28 00:12:12 -07:00
|
|
|
# clang can cause false positives with -Werror without -Qunused-arguments.
|
|
|
|
# it can be triggered if used with ccache.
|
|
|
|
AC_CHECK_DECL([__clang__], [CLANG_CXXFLAGS="-Qunused-arguments"], [])
|
|
|
|
|
2012-12-27 17:54:42 -08:00
|
|
|
# Detect whether Boost tries to use threads by default, and, if not,
|
|
|
|
# make it sure explicitly. In some systems the automatic detection
|
|
|
|
# may depend on preceding header files, and if inconsistency happens
|
|
|
|
# it could lead to a critical disruption.
|
|
|
|
AC_MSG_CHECKING([whether Boost tries to use threads])
|
|
|
|
AC_TRY_COMPILE([
|
|
|
|
#include <boost/config.hpp>
|
|
|
|
#ifdef BOOST_HAS_THREADS
|
|
|
|
#error "boost will use threads"
|
|
|
|
#endif],,
|
|
|
|
[AC_MSG_RESULT(no)
|
|
|
|
CPPFLAGS_BOOST_THREADCONF="-DBOOST_DISABLE_THREADS=1"],
|
|
|
|
[AC_MSG_RESULT(yes)])
|
|
|
|
|
|
|
|
# Boost offset_ptr is known to not compile on some platforms, depending on
|
|
|
|
# boost version, its local configuration, and compiler. Detect it.
|
2013-08-16 09:59:55 +02:00
|
|
|
CXXFLAGS_SAVED="$CXXFLAGS"
|
2013-10-28 00:12:12 -07:00
|
|
|
CXXFLAGS="$CXXFLAGS $CLANG_CXXFLAGS -Werror"
|
2012-12-27 17:54:42 -08:00
|
|
|
AC_MSG_CHECKING([Boost offset_ptr compiles])
|
|
|
|
AC_TRY_COMPILE([
|
|
|
|
#include <boost/interprocess/offset_ptr.hpp>
|
|
|
|
],,
|
|
|
|
[AC_MSG_RESULT(yes)
|
|
|
|
BOOST_OFFSET_PTR_WOULDFAIL=no],
|
|
|
|
[AC_MSG_RESULT(no)
|
|
|
|
BOOST_OFFSET_PTR_WOULDFAIL=yes])
|
2013-08-16 09:59:55 +02:00
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
2012-12-27 17:54:42 -08:00
|
|
|
|
2012-12-27 18:14:36 -08:00
|
|
|
# Detect build failure case known to happen with Boost installed via
|
|
|
|
# FreeBSD ports
|
2012-12-27 18:36:49 -08:00
|
|
|
if test "X$GXX" = "Xyes"; then
|
|
|
|
CXXFLAGS_SAVED="$CXXFLAGS"
|
2013-10-28 00:12:12 -07:00
|
|
|
CXXFLAGS="$CXXFLAGS $CLANG_CXXFLAGS -Werror"
|
2012-12-27 18:36:49 -08:00
|
|
|
|
|
|
|
AC_MSG_CHECKING([Boost numeric_cast compiles with -Werror])
|
|
|
|
AC_TRY_COMPILE([
|
|
|
|
#include <boost/numeric/conversion/cast.hpp>
|
|
|
|
],[
|
|
|
|
return (boost::numeric_cast<short>(0));
|
|
|
|
],[AC_MSG_RESULT(yes)
|
|
|
|
BOOST_NUMERIC_CAST_WOULDFAIL=no],
|
|
|
|
[AC_MSG_RESULT(no)
|
|
|
|
BOOST_NUMERIC_CAST_WOULDFAIL=yes])
|
|
|
|
|
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
|
|
|
else
|
2013-03-13 14:24:31 -07:00
|
|
|
# This doesn't matter for non-g++
|
2013-04-10 14:31:07 -07:00
|
|
|
BOOST_NUMERIC_CAST_WOULDFAIL=no
|
2013-03-13 14:24:31 -07:00
|
|
|
fi
|
|
|
|
|
2013-07-08 08:19:31 +05:30
|
|
|
# BOOST_STATIC_ASSERT in versions below Boost 1.54.0 is known to result
|
|
|
|
# in warnings with GCC 4.8. Detect it.
|
|
|
|
AC_MSG_CHECKING([BOOST_STATIC_ASSERT compiles])
|
|
|
|
AC_TRY_COMPILE([
|
|
|
|
#include <boost/static_assert.hpp>
|
|
|
|
void testfn(void) { BOOST_STATIC_ASSERT(true); }
|
|
|
|
],,
|
|
|
|
[AC_MSG_RESULT(yes)
|
|
|
|
BOOST_STATIC_ASSERT_WOULDFAIL=no],
|
|
|
|
[AC_MSG_RESULT(no)
|
|
|
|
BOOST_STATIC_ASSERT_WOULDFAIL=yes])
|
|
|
|
|
2013-03-13 14:24:31 -07:00
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
2012-12-27 18:14:36 -08:00
|
|
|
|
2012-12-27 17:54:42 -08:00
|
|
|
AC_SUBST(BOOST_INCLUDES)
|
|
|
|
|
2013-09-10 11:33:32 +02:00
|
|
|
dnl Determine the Boost version, used mainly for config.report.
|
|
|
|
AC_MSG_CHECKING([Boost version])
|
|
|
|
cat > conftest.cpp << EOF
|
2013-09-16 15:29:58 +02:00
|
|
|
#include <boost/version.hpp>
|
2013-09-10 11:33:32 +02:00
|
|
|
AUTOCONF_BOOST_LIB_VERSION=BOOST_LIB_VERSION
|
|
|
|
EOF
|
|
|
|
|
2013-09-16 15:29:58 +02:00
|
|
|
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`
|
2013-09-10 11:33:32 +02:00
|
|
|
if test -z "$BOOST_VERSION"; then
|
|
|
|
BOOST_VERSION="unknown"
|
|
|
|
fi
|
|
|
|
$RM -f conftest.cpp
|
|
|
|
AC_MSG_RESULT([$BOOST_VERSION])
|
|
|
|
|
2012-12-27 17:54:42 -08:00
|
|
|
CPPFLAGS="$CPPFLAGS_SAVED"
|
|
|
|
AC_LANG_RESTORE
|
2014-08-12 13:09:33 +02:00
|
|
|
])dnl AX_BOOST_FOR_KEA
|