This is an automated email from the ASF dual-hosted git repository. tillt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 0f9448497ddb259063911811ab3ce5784747ca2d Author: Till Toenshoff <[email protected]> AuthorDate: Wed Sep 26 15:22:34 2018 +0200 Added version check and bundling of libevent within libprocess. Review: https://reviews.apache.org/r/68641/ --- 3rdparty/libprocess/Makefile.am | 24 +++++++-- 3rdparty/libprocess/configure.ac | 73 ++++++++++++-------------- 3rdparty/libprocess/m4/libevent.m4 | 103 +++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 43 deletions(-) diff --git a/3rdparty/libprocess/Makefile.am b/3rdparty/libprocess/Makefile.am index f9d9d06..22b1395 100644 --- a/3rdparty/libprocess/Makefile.am +++ b/3rdparty/libprocess/Makefile.am @@ -62,6 +62,7 @@ GRPC = $(BUNDLED_DIR)/grpc-$(GRPC_VERSION) GTEST = $(GOOGLETEST)/googletest HTTP_PARSER = $(BUNDLED_DIR)/http-parser-$(HTTP_PARSER_VERSION) LIBEV = $(BUNDLED_DIR)/libev-$(LIBEV_VERSION) +LIBEVENT = $(BUNDLED_DIR)/libevent-$(LIBEVENT_VERSION) PICOJSON = $(BUNDLED_DIR)/picojson-$(PICOJSON_VERSION) PROTOBUF = $(BUNDLED_DIR)/protobuf-$(PROTOBUF_VERSION) RAPIDJSON = $(BUNDLED_DIR)/rapidjson-$(RAPIDJSON_VERSION) @@ -154,6 +155,19 @@ BUNDLED_DEPS += $(LIBEV)-build-stamp else LIB_EV = -lev endif +else +if WITH_BUNDLED_LIBEVENT +LIB_EVENT_INCLUDE_FLAGS = -I$(LIBEVENT) +LIB_EVENT = $(LIBEVENT)/libevent_core.la $(LIBEVENT)/libevent_pthreads.la \ + $(LIBEVENT)/libevent_extra.la $(LIBEVENT)/libevent.la +if ENABLE_SSL +LIB_EVENT += $(LIBEVENT)/libevent_openssl.la +endif +$(LIBEVENT): $(LIBEVENT)-build-stamp +BUNDLED_DEPS += $(LIBEVENT)-build-stamp +else +LIB_EVENT = -levent +endif endif PICOJSON_INCLUDE_FLAGS = -D__STDC_FORMAT_MACROS @@ -258,6 +272,7 @@ libprocess_la_CPPFLAGS = \ $(GRPC_INCLUDE_FLAGS) \ $(HTTP_PARSER_INCLUDE_FLAGS) \ $(LIB_EV_INCLUDE_FLAGS) \ + $(LIB_EVENT_INCLUDE_FLAGS) \ $(PICOJSON_INCLUDE_FLAGS) \ $(PROTOBUF_INCLUDE_FLAGS) \ $(RAPIDJSON_INCLUDE_FLAGS) \ @@ -291,7 +306,8 @@ libprocess_la_LIBADD = \ $(LIB_GLOG) \ $(LIB_GPERFTOOLS) \ $(LIB_HTTP_PARSER) \ - $(LIB_EV) + $(LIB_EV) \ + $(LIB_EVENT) # Tests. check_PROGRAMS = libprocess-tests benchmarks @@ -399,12 +415,14 @@ if !ENABLE_STATIC_LIBPROCESS benchmarks_LDADD += \ $(LIB_GLOG) \ $(LIB_HTTP_PARSER) \ - $(LIB_EV) + $(LIB_EV) \ + $(LIB_EVENT) libprocess_tests_LDADD += \ $(LIB_GLOG) \ $(LIB_HTTP_PARSER) \ - $(LIB_EV) + $(LIB_EV) \ + $(LIB_EVENT) endif BUILT_SOURCES = \ diff --git a/3rdparty/libprocess/configure.ac b/3rdparty/libprocess/configure.ac index e9e2434..c3e3964 100644 --- a/3rdparty/libprocess/configure.ac +++ b/3rdparty/libprocess/configure.ac @@ -212,7 +212,7 @@ AC_ARG_WITH([libev], AC_ARG_WITH([libevent], AS_HELP_STRING([--with-libevent=@<:@=DIR@:>@], [specify where to locate the libevent library]), - [], []) + [without_bundled_libevent=yes], []) AC_ARG_WITH([picojson], AS_HELP_STRING([--with-picojson@<:@=DIR@:>@], @@ -798,38 +798,28 @@ if test -n "`echo $with_libevent`"; then 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 version 2+ is required for libprocess to build. -------------------------------------------------------------------- - ])])], - [AC_MSG_ERROR([cannot find libevent headers -------------------------------------------------------------------- -libevent version 2+ headers are 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 version 2+ is required for libprocess to build. -------------------------------------------------------------------- - ])])], - [AC_MSG_ERROR([cannot find libevent_pthreads headers -------------------------------------------------------------------- -libevent_pthreads version 2+ headers are required for libprocess to build. -------------------------------------------------------------------- - ])]) + # Check if user has asked us to use a preinstalled libevent, or if they + # asked us to ignore all bundled libraries while compiling and + # linking. + if test "x$without_bundled_libevent" = "xyes" || \ + test "x$enable_bundled" != "xyes"; then + MESOS_HAVE_LIBEVENT([2.0.22], [], [ + AC_MSG_ERROR([libevent version is incompatible +------------------------------------------------------------------- +libevent version 2.0.22 is the most recent we currently support. + +You may want to install an older version of libevent on your system +and point this build system to it via --with-libevent=DIR. +-------------------------------------------------------------------])]) + else + with_bundled_libevent=yes + fi fi -AM_CONDITIONAL([ENABLE_LIBEVENT], [test x"$enable_libevent" = "xyes"]) +AM_CONDITIONAL([ENABLE_LIBEVENT], + [test x"$enable_libevent" = "xyes"]) +AM_CONDITIONAL([WITH_BUNDLED_LIBEVENT], + [test "x$with_bundled_libevent" = "xyes"]) if test -n "`echo $with_picojson`"; then @@ -1015,27 +1005,30 @@ libcrypto is required for an SSL-enabled build. LIBS="-lssl -lcrypto $LIBS" 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 + if test "x$with_bundled_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 version 2+ is required for an SSL-enabled build. ------------------------------------------------------------------- - ])])], - [AC_MSG_ERROR([cannot find libevent_openssl headers + ])])], + [AC_MSG_ERROR([cannot find libevent_openssl headers ------------------------------------------------------------------- libevent_openssl version 2+ headers are required for an SSL-enabled build. ------------------------------------------------------------------- - ])]) + ])]) + fi 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"]) +AM_CONDITIONAL([ENABLE_SSL], + [test x"$enable_ssl" = "xyes"]) AC_SUBST([SSL_CPPFLAGS]) AC_SUBST([SSL_LINKERFLAGS]) diff --git a/3rdparty/libprocess/m4/libevent.m4 b/3rdparty/libprocess/m4/libevent.m4 new file mode 100644 index 0000000..b8462f8 --- /dev/null +++ b/3rdparty/libprocess/m4/libevent.m4 @@ -0,0 +1,103 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# SYNOPSIS +# +# MESOS_HAVE_LIBEVENT(MINIMAL_VERSION, action-if-true, action-if-false) +# +# DESCRIPTION +# +# Validates if we have a usable libevent. +# + +AC_DEFUN([MESOS_HAVE_LIBEVENT],[ + AC_CHECK_HEADERS([event2/event.h], [], [ + AC_MSG_ERROR([cannot find libevent headers +------------------------------------------------------------------- +libevent version 2+ headers are required for libprocess to build. +------------------------------------------------------------------- + ])]) + + AC_CHECK_LIB([event], [event_base_new], [], [ + AC_MSG_ERROR([cannot find libevent +------------------------------------------------------------------- +libevent version 2+ is required for libprocess to build. +------------------------------------------------------------------- + ])]) + + AC_CHECK_HEADERS([event2/thread.h], [], [ + AC_MSG_ERROR([cannot find libevent_pthreads headers +------------------------------------------------------------------- +libevent_pthreads version 2+ headers are required for libprocess to build. +------------------------------------------------------------------- + ])]) + + AC_CHECK_LIB([event_pthreads], [evthread_use_pthreads], [], [ + AC_MSG_ERROR([cannot find libevent_pthreads +------------------------------------------------------------------- +libevent_pthreads version 2+ is required for libprocess to build. +------------------------------------------------------------------- + ])]) + + AC_MSG_CHECKING([for libevent version]) + + # Save our flags. + saved_CFLAGS="$CFLAGS" + saved_LIBS="$LIBS" + + # Required flags for libevent. + LIBS="-levent" + CFLAGS="" + + # Compile and run C program that gets the libevent version numnber into + # "conftest.out" which gets cleaned up by AC_RUN_IFELSE itself. + AC_LANG_PUSH([C]) + AC_RUN_IFELSE([ + AC_LANG_SOURCE([[ + #include <event.h> + #include <stdio.h> + + int main(int argc, char** argv) + { + FILE* fp = fopen("conftest.out", "w"); + fprintf(fp, "%s", event_get_version()); + fclose(fp); + return 0; + } + ]])], + [libevent_version=`cat conftest.out`]) + AC_LANG_POP([C]) + + # Restore flags. + CFLAGS="$saved_CFLAGS" + LIBS="$saved_LIBS" + + AC_MSG_RESULT([$libevent_version]) + + AS_IF([test "x${libevent_version}" = "x"], [], [ + AX_COMPARE_VERSION([$libevent_version], + [le], [$1], + [is_libevent_usable=yes]) + ]) + + AS_IF([test "x$is_libevent_usable" = "xyes"], [ + $2 + ], [ + $3 + ]) +])
