From: Francis Dupont Date: Fri, 4 Sep 2015 08:42:21 +0000 (+0200) Subject: [4009] Fixed the libboost_system dependency for Boost < 1.56 X-Git-Tag: trac4060_base~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8175031f4b9e11edef8cf7cd8d5c1bb6eea69d93;p=thirdparty%2Fkea.git [4009] Fixed the libboost_system dependency for Boost < 1.56 --- diff --git a/configure.ac b/configure.ac index d4b6ada3c5..972398f35c 100644 --- a/configure.ac +++ b/configure.ac @@ -1244,17 +1244,19 @@ AC_SUBST(GTEST_SOURCE) # Use our 'coroutine' header from ext CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/coroutine" # -# Disable threads: Currently we don't use them. -CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_DISABLE_THREADS=1" -# -# Don't want boost system library -CPPFLAGS="$CPPFLAGS -DBOOST_ERROR_CODE_HEADER_ONLY" -# -# Avoid boost::system::throws multiple defines -CPPFLAGS="$CPPFLAGS -DBOOST_SYSTEM_NO_DEPRECATED" -# # Doesn't seem to be required? CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_HEADER_ONLY" +# +# Disable threads: Currently we don't use them. +CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_DISABLE_THREADS=1" + +# We tried to stay header only +if test "x${BOOST_LIBS}" = "x"; then + # Don't want boost system library + CPPFLAGS="$CPPFLAGS -DBOOST_ERROR_CODE_HEADER_ONLY" + # Avoid boost::system::throws multiple defines + CPPFLAGS="$CPPFLAGS -DBOOST_SYSTEM_NO_DEPRECATED" +fi # Check for functions that are not available on all platforms AC_CHECK_FUNCS([pselect]) @@ -1573,6 +1575,7 @@ cat >> config.report << END Boost: BOOST_VERSION: ${BOOST_VERSION} BOOST_INCLUDES: ${BOOST_INCLUDES} + BOOST_LIBS: ${BOOST_LIBS} ${CRYPTO_NAME}: CRYPTO_VERSION: ${CRYPTO_VERSION} diff --git a/m4macros/ax_boost_for_kea.m4 b/m4macros/ax_boost_for_kea.m4 index eae4139e12..aa7979e926 100644 --- a/m4macros/ax_boost_for_kea.m4 +++ b/m4macros/ax_boost_for_kea.m4 @@ -13,9 +13,13 @@ 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 Boost.Asio depends on Boost.System which can be header only with +dnl versions >= 1.56. On older versions libboost_system is required. +dnl dnl This macro calls: dnl dnl AC_SUBST(BOOST_INCLUDES) +dnl AC_SUBST(BOOST_LIBS) dnl dnl And possibly sets: dnl CPPFLAGS_BOOST_THREADCONF should be added to CPPFLAGS by caller @@ -30,6 +34,9 @@ AC_DEFUN([AX_BOOST_FOR_KEA], [ AC_LANG_SAVE AC_LANG([C++]) +# No library by default (and as goal) +BOOST_LIBS= + # # Configure Boost header path # @@ -56,7 +63,7 @@ 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 boost/asio.hpp boost/asio/ip/address.hpp],, +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 boost/asio.hpp boost/asio/ip/address.hpp boost/system/error_code.hpp],, AC_MSG_ERROR([Missing required header files.])) # clang can cause false positives with -Werror without -Qunused-arguments. @@ -125,9 +132,34 @@ void testfn(void) { BOOST_STATIC_ASSERT(true); } [AC_MSG_RESULT(no) BOOST_STATIC_ASSERT_WOULDFAIL=yes]) +# BOOST_ERROR_CODE_HEADER_ONLY in versions below Boost 1.56.0 can fail +# to find the error_code.cpp file. +AC_MSG_CHECKING([BOOST_ERROR_CODE_HEADER_ONLY works]) +CXXFLAGS_SAVED2="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -DBOOST_ERROR_CODE_HEADER_ONLY" +CPPFLAGS="$CPPFLAGS -DBOOST_SYSTEM_NO_DEPRECATED" +AC_TRY_COMPILE([ +#include +],, +[AC_MSG_RESULT(yes)], +[AC_MSG_RESULT(no) + AC_MSG_WARN([The Boost system library is required.]) + BOOST_LIBS="-lboost_system" + LIBS_SAVED="$LIBS" + LIBS="$BOOST_LIBS $LIBS" + CPPFLAGS="$CXXFLAGS_SAVED2" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include ], + [boost::system::error_code ec;])], + [AC_MSG_RESULT([checking for Boost system library... yes])], + [AC_MSG_RESULT([checking for Boost system library... no]) + AC_MSG_ERROR([Linking with ${BOOST_LIBS} is not enough: please make sure libboost_system is installed])]) + LIBS="$LIBS_SAVED"]) + CXXFLAGS="$CXXFLAGS_SAVED" AC_SUBST(BOOST_INCLUDES) +AC_SUBST(BOOST_LIBS) dnl Determine the Boost version, used mainly for config.report. AC_MSG_CHECKING([Boost version]) diff --git a/src/lib/asiolink/Makefile.am b/src/lib/asiolink/Makefile.am index 53f960f18b..cdc0b3df37 100644 --- a/src/lib/asiolink/Makefile.am +++ b/src/lib/asiolink/Makefile.am @@ -35,7 +35,8 @@ libkea_asiolink_la_SOURCES += udp_socket.h # KEA_CXXFLAGS) libkea_asiolink_la_CXXFLAGS = $(AM_CXXFLAGS) libkea_asiolink_la_CPPFLAGS = $(AM_CPPFLAGS) -libkea_asiolink_la_LIBADD = $(top_builddir)/src/lib/exceptions/libkea-exceptions.la +libkea_asiolink_la_LIBADD = $(top_builddir)/src/lib/exceptions/libkea-exceptions.la +libkea_asiolink_la_LIBADD += $(BOOST_LIBS) # IOAddress is sometimes used in user-library code libkea_asiolink_includedir = $(pkgincludedir)/asiolink diff --git a/src/lib/cc/Makefile.am b/src/lib/cc/Makefile.am index debe2ee8a6..b25460c072 100644 --- a/src/lib/cc/Makefile.am +++ b/src/lib/cc/Makefile.am @@ -9,6 +9,7 @@ libkea_cc_la_SOURCES = data.cc data.h libkea_cc_la_SOURCES += command_interpreter.cc command_interpreter.h libkea_cc_la_LIBADD = $(top_builddir)/src/lib/exceptions/libkea-exceptions.la +libkea_cc_la_LIBADD += $(BOOST_LIBS) libkea_cc_la_LDFLAGS = -no-undefined -version-info 1:0:0