]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4009] Fixed the libboost_system dependency for Boost < 1.56
authorFrancis Dupont <fdupont@isc.org>
Fri, 4 Sep 2015 08:42:21 +0000 (10:42 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 4 Sep 2015 08:42:21 +0000 (10:42 +0200)
configure.ac
m4macros/ax_boost_for_kea.m4
src/lib/asiolink/Makefile.am
src/lib/cc/Makefile.am

index d4b6ada3c57feab2adb11e216338f0fc40476d51..972398f35c4bd60acbd71c61344213d09b1c57ff 100644 (file)
@@ -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}
index eae4139e125b1e242964d65f9ce523615fd292c1..aa7979e9265d49e213d51d4a5335706f5955c136 100644 (file)
@@ -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 <boost/system/error_code.hpp>
+],,
+[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.hpp>],
+                   [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])
index 53f960f18b4889e391a774ae35b9b36ec7c62894..cdc0b3df37c82cf5bf372bfed969a4fb703cfc4f 100644 (file)
@@ -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
index debe2ee8a62acaf1ea6ec7f653f0c48428fd9742..b25460c0720ce451eb02944fb90ed31ee4614274 100644 (file)
@@ -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