From de5dc5fd94a5fe321791d44e88d209a4972264ba Mon Sep 17 00:00:00 2001
From: Hubert Figuiere <hub@figuiere.net>
Date: Sun, 5 Feb 2017 02:52:37 +0000
Subject: [PATCH] Bug 13839 - Detect boost::asio

Patch by Adam Majer <amajer@suse.de>

git-svn-id: svn+ssh://svn.abisource.com/svnroot/abiword/trunk@35397 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
---
 .../collab/backends/service/xp/AsyncWorker.h   |  7 ++++++-
 .../backends/service/xp/RealmConnection.h      |  6 +++++-
 .../collab/backends/service/xp/RealmProtocol.h |  6 +++++-
 .../collab/backends/service/xp/tls_tunnel.h    |  6 +++++-
 .../collab/backends/tcp/xp/IOServerHandler.h   |  6 +++++-
 plugins/collab/plugin.m4                       | 18 +++++++++++-------
 6 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/plugins/collab/backends/service/xp/AsyncWorker.h b/plugins/collab/backends/service/xp/AsyncWorker.h
index ab0437c29f..2e527f9254 100644
--- a/plugins/collab/backends/service/xp/AsyncWorker.h
+++ b/plugins/collab/backends/service/xp/AsyncWorker.h
@@ -19,7 +19,12 @@
 #ifndef __ASYNC_WORKER__
 #define __ASYNC_WORKER__
 
-#include <asio.hpp>
+#if defined(HAVE_BOOST_ASIO_HPP)
+# include <boost/asio.hpp>
+#else
+# include <asio.hpp>
+#endif
+
 #include <boost/bind.hpp>
 #include <boost/function.hpp>
 #include <boost/noncopyable.hpp>
diff --git a/plugins/collab/backends/service/xp/RealmConnection.h b/plugins/collab/backends/service/xp/RealmConnection.h
index 7dc715548c..214b12316b 100644
--- a/plugins/collab/backends/service/xp/RealmConnection.h
+++ b/plugins/collab/backends/service/xp/RealmConnection.h
@@ -21,7 +21,11 @@
 
 #include <boost/shared_ptr.hpp>
 #include <boost/enable_shared_from_this.hpp>
-#include <asio.hpp>
+#if defined(HAVE_BOOST_ASIO_HPP)
+# include <boost/asio.hpp>
+#else
+# include <asio.hpp>
+#endif
 #include <vector>
 #include <string>
 #include "ut_types.h"
diff --git a/plugins/collab/backends/service/xp/RealmProtocol.h b/plugins/collab/backends/service/xp/RealmProtocol.h
index 772ad891dd..03fa536dea 100644
--- a/plugins/collab/backends/service/xp/RealmProtocol.h
+++ b/plugins/collab/backends/service/xp/RealmProtocol.h
@@ -9,7 +9,11 @@
 #include <stdint.h>
 #endif
 #include <boost/shared_ptr.hpp>
-#include <asio.hpp>
+#if defined(HAVE_BOOST_ASIO_HPP)
+# include <boost/asio.hpp>
+#else
+# include <asio.hpp>
+#endif
 
 namespace realm {
 
diff --git a/plugins/collab/backends/service/xp/tls_tunnel.h b/plugins/collab/backends/service/xp/tls_tunnel.h
index ea07151c70..a78f7815c3 100644
--- a/plugins/collab/backends/service/xp/tls_tunnel.h
+++ b/plugins/collab/backends/service/xp/tls_tunnel.h
@@ -33,7 +33,11 @@
 #include <boost/function.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/enable_shared_from_this.hpp>
-#include <asio.hpp>
+#if defined(HAVE_BOOST_ASIO_HPP)
+# include <boost/asio.hpp>
+#else
+# include <asio.hpp>
+#endif
 #include <string>
 #include <vector>
 #ifdef _MSC_VER
diff --git a/plugins/collab/backends/tcp/xp/IOServerHandler.h b/plugins/collab/backends/tcp/xp/IOServerHandler.h
index 7a561f4a1c..8a2b931319 100644
--- a/plugins/collab/backends/tcp/xp/IOServerHandler.h
+++ b/plugins/collab/backends/tcp/xp/IOServerHandler.h
@@ -23,7 +23,11 @@
 
 #include <boost/bind.hpp>
 #include <boost/function.hpp>
-#include <asio.hpp>
+#if defined(HAVE_BOOST_ASIO_HPP)
+# include <boost/asio.hpp>
+#else
+# include <asio.hpp>
+#endif
 
 #include <sync/xp/Synchronizer.h>
 #include "Session.h"
diff --git a/plugins/collab/plugin.m4 b/plugins/collab/plugin.m4
index 98028b99ff..7cfe3a1388 100644
--- a/plugins/collab/plugin.m4
+++ b/plugins/collab/plugin.m4
@@ -70,20 +70,22 @@ AC_ARG_ENABLE([collab-backend-tcp],
 	enable_collab_backend_tcp=$enableval
 	if test "$enable_collab_backend_tcp" != "no"; then
 		AC_LANG_PUSH(C++)
-		AC_CHECK_HEADERS([asio.hpp], [], 
+		AC_CHECK_HEADERS([asio.hpp], [],
+			[AC_CHECK_HEADERS([boost/asio.hpp], [AC_DEFINE([HAVE_BOOST_ASIO_HPP])],
 		[
 			AC_MSG_ERROR([collab plugin: asio is required for the collab plugin TCP backend, see http://think-async.com/])
-		])
+		])])
 		AC_LANG_POP
 		collab_deps="yes"
 	fi
 ], [
 	AC_LANG_PUSH(C++)
-	AC_CHECK_HEADERS([asio.hpp], 
+	AC_CHECK_HEADERS([asio.hpp],
+		[AC_CHECK_HEADERS([boost/asio.hpp], [AC_DEFINE([HAVE_BOOST_ASIO_HPP])],
 	[
 		enable_collab_backend_tcp="yes"
 		collab_deps="yes"
-	])
+	])])
 	AC_LANG_POP
 ])
 AC_MSG_CHECKING([for collab tcp backend])
@@ -112,10 +114,11 @@ AC_ARG_ENABLE([collab-backend-service],
 	enable_collab_backend_service=$enableval
 	if test "$enable_collab_backend_service" != "no"; then
 		AC_LANG_PUSH(C++)
-		AC_CHECK_HEADERS([asio.hpp], [], 
+		AC_CHECK_HEADERS([asio.hpp], [],
+		[AC_CHECK_HEADERS([boost/asio.hpp], [AC_DEFINE([HAVE_BOOST_ASIO_HPP])],	
 		[
 			AC_MSG_ERROR([collab plugin: asio is required for the the abicollab.net backend, see http://think-async.com/])
-		])
+		])])
 		AC_LANG_POP
 		PKG_CHECK_EXISTS([ $collab_service_req ], [], [
 			AC_MSG_ERROR([collab plugin: missing dependencies])
@@ -125,13 +128,14 @@ AC_ARG_ENABLE([collab-backend-service],
 ], [
 	AC_LANG_PUSH(C++)
 	AC_CHECK_HEADERS([asio.hpp],
+		[AC_CHECK_HEADERS([boost/asio.hpp], [AC_DEFINE([HAVE_BOOST_ASIO_HPP])],
 	[
 		PKG_CHECK_EXISTS([ $collab_service_req ], [
 			enable_collab_backend_service="yes"
 			collab_deps="yes"
 		], [
 			enable_collab_backend_service="no"
-		])
+		])])
 	], [
 		enable_collab_backend_service="no"
         ])
