build: Conditional check for C++11 and add ability to use system's boost instead of bundled version

1. C++11 is enabled by default and can be disabled with
--without-c++11 (or --with-c++11=no)

2. Use of system's boost libraries can be requested with
--with-system-boost.  By default, the bundled version of boost is used
when necessary.

Refs #1065 (http://redmine.named-data.net/issues/1065)

Change-Id: I823b67c62764c80476aedf41335dd69e7687f47b
diff --git a/configure.ac b/configure.ac
index f04b30b..91f535e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,54 +52,28 @@
 AC_CHECK_HEADERS([time.h], :, AC_MSG_ERROR([*** time.h not found. Check 'config.log' for more details.]))
 AC_CHECK_HEADERS([sys/time.h], :, AC_MSG_ERROR([*** sys/time.h not found. Check 'config.log' for more details.]))
 AC_CHECK_FUNCS([gettimeofday], :, AC_MSG_ERROR([*** gettimeofday not found. processEvents requires it. Check 'config.log' for more details.]))
-AX_CXX_COMPILE_STDCXX_11(, optional)
 AC_C_INLINE
 
-AC_MSG_CHECKING([for std::shared_ptr])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-    [[#include <memory>]]
-    [[std::shared_ptr<int> have_shared_ptr;]])
-], [
-    AC_MSG_RESULT([yes])
-    AC_DEFINE_UNQUOTED([HAVE_STD_SHARED_PTR], 1, [1 if have the `std::shared_ptr' class.])
-], [
-    AC_MSG_RESULT([no])
-    AC_DEFINE_UNQUOTED([HAVE_STD_SHARED_PTR], 0, [1 if have the `std::shared_ptr' class.])
-])
-AC_MSG_CHECKING([for boost::shared_ptr])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-    [[#include <boost/shared_ptr.hpp>]]
-    [[boost::shared_ptr<int> have_shared_ptr;]])
-], [
-    AC_MSG_RESULT([yes])
-    AC_DEFINE_UNQUOTED([HAVE_BOOST_SHARED_PTR], 1, [1 if have the `boost::shared_ptr' class.])
-], [
-    AC_MSG_RESULT([no])
-    AC_DEFINE_UNQUOTED([HAVE_BOOST_SHARED_PTR], 0, [1 if have the `boost::shared_ptr' class.])
-])
+# Unless --without-c++11 specified, try to enable C++11
+AX_CXX_COMPILE_STDCXX_11(, optional)
 
-AC_MSG_CHECKING([for std::function])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-    [[#include <functional>]]
-    [[std::function<int> have_function();]])
-], [
-    AC_MSG_RESULT([yes])
-    AC_DEFINE_UNQUOTED([HAVE_STD_FUNCTION], 1, [1 if have the `std::function' class.])
-], [
-    AC_MSG_RESULT([no])
-    AC_DEFINE_UNQUOTED([HAVE_STD_FUNCTION], 0, [1 if have the `std::function' class.])
-])
-AC_MSG_CHECKING([for boost::function])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-    [[#include <boost/function.hpp>]]
-    [[boost::function<int> have_function();]])
-], [
-    AC_MSG_RESULT([yes])
-    AC_DEFINE_UNQUOTED([HAVE_BOOST_FUNCTION], 1, [1 if have the `boost::function' class.])
-], [
-    AC_MSG_RESULT([no])
-    AC_DEFINE_UNQUOTED([HAVE_BOOST_FUNCTION], 0, [1 if have the `boost::function' class.])
-])
+AC_ARG_WITH([system-boost],
+  AS_HELP_STRING(
+      [--with-system-boost],
+      [use system-installed boost libraries. If not specified, use the bundled version when necessary.]
+  ),
+  [want_system_boost="yes"],
+  [want_system_boost="no"]
+)
+
+AX_BOOST_BASE([1.42.0],
+  [
+    if test "$want_system_boost" == "yes" ; then
+      AC_DEFINE(USE_SYSTEM_BOOST,[1],[use system-installed boost libraries])
+    fi
+  ],
+  []
+)
 
 AC_MSG_CHECKING([for gmtime support])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(