Enabled compiling python egg with SSL and libevent.

Review: https://reviews.apache.org/r/35967


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/14cf8d1c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/14cf8d1c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/14cf8d1c

Branch: refs/heads/master
Commit: 14cf8d1ca17bd5a7a2062bb7b610d4749e793f8b
Parents: b417ad7
Author: Artem Harutyunyan <[email protected]>
Authored: Sun Jun 28 15:57:26 2015 -0700
Committer: Benjamin Hindman <[email protected]>
Committed: Sun Jun 28 16:03:43 2015 -0700

----------------------------------------------------------------------
 configure.ac                        | 135 +++++++++++++++++++++++++++++++
 src/python/native/ext_modules.py.in |  23 ++++--
 2 files changed, 151 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/14cf8d1c/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 55c07a2..9290958 100644
--- a/configure.ac
+++ b/configure.ac
@@ -246,6 +246,30 @@ AC_ARG_WITH([network-isolator],
                            [builds the network isolator]),
             [], [with_network_isolator=no])
 
+AC_ARG_ENABLE([libevent],
+              AS_HELP_STRING([--enable-libevent],
+                             [use libevent instead of libev default: no]),
+              [enable_libevent=yes], [])
+
+AC_ARG_ENABLE([ssl],
+              AS_HELP_STRING([--enable-ssl],
+                             [use ssl for libprocess communication
+                             default: no]),
+              [enable_ssl=yes], [])
+
+AC_ARG_WITH([libevent],
+            AS_HELP_STRING([--with-libevent=@<:@=DIR@:>@],
+                           [specify where to locate the libevent library]),
+            [], [])
+
+AC_ARG_WITH([ssl],
+            AS_HELP_STRING([--with-ssl=@<:@=DIR@:>@],
+                           [specify where to locate the ssl library]),
+            [], [])
+
+# TODO(hartem): consolidate all of the ENABLE and _WITH statements
+# above in separate sections for better readability.
+
 AC_ARG_VAR([JAVA_HOME], [location of Java Development Kit (JDK)])
 
 AC_ARG_VAR([JAVA_CPPFLAGS], [preprocessor flags for JNI])
@@ -1419,6 +1443,117 @@ AM_CONDITIONAL([WITHOUT_PYTHON_DEPS],
 AM_CONDITIONAL([GIT_REPO], [test -d ${srcdir}"/.git"])
 
 
+# Check if libevent prefix path was provided, and if so, add it to
+# the CPPFLAGS and LDFLAGS with respective /include and /lib path
+# suffixes.
+if test -z "`echo $with_libevent`" &&
+   test "$OS_NAME" = "darwin" &&
+   test -n "`command -v brew`" &&
+   test -n "`brew list --versions libevent`"; then
+  with_libevent=`brew --prefix libevent`
+fi
+
+if test -n "`echo $with_libevent`"; then
+  CPPFLAGS="-I${with_libevent}/include $CPPFLAGS"
+  LDFLAGS="-L${with_libevent}/lib $LDFLAGS"
+fi
+
+if test "x$enable_libevent" = "xyes"; then
+  AC_CHECK_HEADERS([event2/event.h],
+                   [AC_CHECK_LIB([event],
+                                 [event_base_new],
+                                 [],
+                                 [AC_MSG_ERROR([cannot find libevent
+-------------------------------------------------------------------
+libevent is required for libprocess to build.
+-------------------------------------------------------------------
+                                 ])])],
+                   [AC_MSG_ERROR([cannot find libevent headers
+-------------------------------------------------------------------
+libevent is required for libprocess to build.
+-------------------------------------------------------------------
+  ])])
+
+  AC_CHECK_HEADERS([event2/thread.h],
+                   [AC_CHECK_LIB([event_pthreads],
+                                 [evthread_use_pthreads],
+                                 [],
+                                 [AC_MSG_ERROR([cannot find libevent_pthreads
+-------------------------------------------------------------------
+libevent_pthreads is required for libprocess to build.
+-------------------------------------------------------------------
+                                 ])])],
+                   [AC_MSG_ERROR([cannot find libevent_pthreads headers
+-------------------------------------------------------------------
+libevent_pthreads is required for libprocess to build.
+-------------------------------------------------------------------
+  ])])
+fi
+
+AM_CONDITIONAL([ENABLE_LIBEVENT], [test x"$enable_libevent" = "xyes"])
+
+
+# Check if libssl prefix path was provided, and if so, add it to
+# the CPPFLAGS and LDFLAGS with respective /include and /lib path
+# suffixes.
+if test -z "`echo $with_ssl`" &&
+   test "$OS_NAME" = "darwin" &&
+   test -n "`command -v brew`" &&
+   test -n "`brew list --versions openssl`"; then
+  with_ssl=`brew --prefix openssl`
+fi
+
+if test -n "`echo $with_ssl`"; then
+  CPPFLAGS="-I${with_ssl}/include $CPPFLAGS"
+  LDFLAGS="-L${with_ssl}/lib $LDFLAGS"
+fi
+
+if test "x$enable_ssl" = "xyes"; then
+  AC_CHECK_HEADERS([openssl/ssl.h],
+                   [AC_CHECK_LIB([ssl],
+                                 [SSL_CTX_new],
+                                 [],
+                                 [AC_MSG_ERROR([cannot find libssl
+-------------------------------------------------------------------
+libssl is required for an SSL-enabled build.
+-------------------------------------------------------------------
+                                 ])])],
+                   [AC_MSG_ERROR([cannot find libssl headers
+-------------------------------------------------------------------
+libssl is required for an SSL-enabled build.
+-------------------------------------------------------------------
+  ])])
+
+  AC_CHECK_LIB([crypto], [RAND_poll], [], [AC_MSG_ERROR([cannot find libcrypto
+-------------------------------------------------------------------
+libcrypto is required for an SSL-enabled build.
+-------------------------------------------------------------------
+  ])])
+
+  if test "x$enable_libevent" = "xyes"; then
+    AC_CHECK_HEADERS([event2/bufferevent_ssl.h],
+                     [AC_CHECK_LIB([event_openssl],
+                                   [bufferevent_openssl_get_ssl],
+                                   [],
+                                   [AC_MSG_ERROR([cannot find libevent_openssl
+-------------------------------------------------------------------
+libevent_openssl is required for an SSL-enabled build.
+-------------------------------------------------------------------
+                                   ])])],
+                     [AC_MSG_ERROR([cannot find libevent_openssl headers
+-------------------------------------------------------------------
+libevent_openssl is required for an SSL-enabled build.
+-------------------------------------------------------------------
+    ])])
+  else
+    AC_MSG_ERROR([SSL is currently only supported with libevent])
+  fi
+  AC_DEFINE([USE_SSL_SOCKET], [1])
+fi
+
+AM_CONDITIONAL([ENABLE_SSL], [test x"$enable_ssl" = "xyes"])
+
+
 # Provide more granular version numbers based on the version string,
 # using the format MAJOR.MINOR.PATCH[-SUFFIX], where SUFFIX can itself
 # contain dashes.

http://git-wip-us.apache.org/repos/asf/mesos/blob/14cf8d1c/src/python/native/ext_modules.py.in
----------------------------------------------------------------------
diff --git a/src/python/native/ext_modules.py.in 
b/src/python/native/ext_modules.py.in
index 4825fe4..4682e5e 100644
--- a/src/python/native/ext_modules.py.in
+++ b/src/python/native/ext_modules.py.in
@@ -38,7 +38,6 @@ libprocess = os.path.join('3rdparty', 'libprocess')
 # include them here (or more precisely, down where we actually include
 # libev.a and libprofiler.a).
 glog = os.path.join(libprocess, '3rdparty', 'glog-0.3.3')
-libev = os.path.join(libprocess, '3rdparty', 'libev-4.15')
 gperftools = os.path.join(libprocess, '3rdparty', 'gperftools-2.0')
 protobuf = os.path.join(libprocess, '3rdparty', 'protobuf-2.5.0')
 
@@ -69,7 +68,6 @@ EXTRA_OBJECTS = [
 
 # For leveldb, we need to check for the presence of libleveldb.a, since
 # it is possible to disable leveldb inside mesos.
-libev = os.path.join(abs_top_builddir, libev, '.libs', 'libev.a')
 libglog = os.path.join(abs_top_builddir, glog, '.libs', 'libglog.a')
 libleveldb = os.path.join(abs_top_builddir, leveldb, 'libleveldb.a')
 libzookeeper = os.path.join(
@@ -87,11 +85,6 @@ if os.path.exists(libzookeeper):
 else:
     EXTRA_OBJECTS.append('-lzookeeper_mt')
 
-if os.path.exists(libev):
-    EXTRA_OBJECTS.append(libev)
-else:
-    EXTRA_OBJECTS.append('-lev')
-
 if os.path.exists(libglog):
     EXTRA_OBJECTS.append(libglog)
 else:
@@ -102,6 +95,22 @@ if os.path.exists(libprotobuf):
 else:
   EXTRA_OBJECTS.append('-lprotobuf')
 
+
+# libev is a special case because it needs to be enabled only when
+# libevent *is not* enabled through the top level ./configure.
+#
+# TODO(hartem): this entire block MUST be removed once libev is deprecated
+# in favor of libevent.
+if '@ENABLE_LIBEVENT_TRUE@' == '#':
+    libev = os.path.join(libprocess, '3rdparty', 'libev-4.15')
+    libev = os.path.join(abs_top_builddir, libev, '.libs', 'libev.a')
+
+    if os.path.exists(libev):
+        EXTRA_OBJECTS.append(libev)
+    else:
+        EXTRA_OBJECTS.append('-lev')
+
+
 # For gperftools, we need to check for the presence of libprofiler.a, since
 # it is possible to disable perftools inside libprocess.
 libprofiler = os.path.join(

Reply via email to