From 85ca7a13e89152843efe7c75956b0e22c1c4eb3b Mon Sep 17 00:00:00 2001 From: Marc Slemko Date: Wed, 17 Jan 2007 08:32:16 +0000 Subject: [PATCH] Added ax_event_base.m4 to find and configure libevent Modified configure.ac to pull in AX_EVENT_BASE Modified Makefile.am to take EVENT settings from automake. Reviewed by dcorson git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664919 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/Makefile.am | 4 +- lib/cpp/aclocal/ax_event_base.m4 | 84 ++++++++++++++++++++++++ lib/cpp/configure.ac | 2 + lib/cpp/src/transport/TFileTransport.cpp | 1 + 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 lib/cpp/aclocal/ax_event_base.m4 diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index 771830af..932e802f 100644 --- a/lib/cpp/Makefile.am +++ b/lib/cpp/Makefile.am @@ -1,7 +1,7 @@ lib_LTLIBRARIES = libthrift.la -common_cxxflags = -Wall -Isrc $(BOOST_CPPFLAGS) -common_ldflags = -Wall $(BOOST_LDFLAGS) -levent +common_cxxflags = -Wall -Isrc $(BOOST_CPPFLAGS) $(EVENT_CPPFLAGS) +common_ldflags = -Wall $(BOOST_LDFLAGS) $(EVENT_LDFLAGS) # Define the source file for the module diff --git a/lib/cpp/aclocal/ax_event_base.m4 b/lib/cpp/aclocal/ax_event_base.m4 new file mode 100644 index 00000000..4418350a --- /dev/null +++ b/lib/cpp/aclocal/ax_event_base.m4 @@ -0,0 +1,84 @@ +dnl @synopsis AX_EVENT([MINIMUM-VERSION]) +dnl +dnl Test for the libevent libraries of a particular version (or newer) +dnl +dnl If no path to the installed event library is given the macro +dnl searchs under /usr, /usr/local, and /opt, and evaluates the +dnl $EVENT_ROOT environment variable. +dnl +dnl This macro calls: +dnl +dnl AC_SUBST(EVENT_CPPFLAGS) / AC_SUBST(EVENT_LDFLAGS) +dnl +dnl And sets: +dnl +dnl HAVE_EVENT +dnl +dnl @category InstalledPackages +dnl @category Cxx +dnl @author Marc Kwiatkowski +dnl @version 2006-06-15 +dnl @license AllPermissive + +AC_DEFUN([AX_EVENT_BASE], +[ +AC_ARG_WITH([event], + AS_HELP_STRING([--with-event@<:@=DIR@:>@], [use event (default is yes) - it is possible to specify an alternate root directory for event]), + [ + if test "$withval" = "no"; then + want_event="no" + elif test "$withval" = "yes"; then + want_event="yes" + ac_event_path="" + else + want_event="yes" + ac_event_path="$withval" + fi + ], + [want_event="yes"]) + +if test "x$want_event" = "xyes"; then + event_lib_version_req=ifelse([$1], ,1.2.0,$1) + event_lib_version_req_shorten=`expr $event_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` + event_lib_version_req_major=`expr $event_lib_version_req : '\([[0-9]]*\)'` + event_lib_version_req_minor=`expr $event_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` + event_lib_version_req_sub_minor=`expr $event_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` + if test "x$event_lib_version_req_sub_minor" = "x" ; then + event_lib_version_req_sub_minor="0" + fi + WANT_EVENT_VERSION=`expr $event_lib_version_req_major \* 10000 \+ $event_lib_version_req_minor \* 100 \+ $event_lib_version_req_sub_minor` + WANT_EVENT_MAJOR_VERSION=$event_lib_version_req_major + WANT_EVENT_MINOR_VERSION=$event_lib_version_req_minor + AC_MSG_CHECKING(for eventlib >= $event_lib_version_req) + succeeded=no + + if test "$ac_event_path" != "" && test -f "$ac_event_path/include/event.h"; then + ac_event_include_path=$ac_event_path/include + EVENT_CPPFLAGS="-I$ac_event_include_path" + EVENT_LDFLAGS="-L$ac_event_path/lib -levent" + succeeded=yes + else + for ac_event_path_tmp in /usr /usr/local /opt ; do + if test -f "$ac_event_path_tmp/include/event.h"; then + ac_event_include_path=$ac_event_path_tmp/include + EVENT_CPPFLAGS="-I$ac_event_include_path" + EVENT_LDFLAGS="-L$ac_event_path_tmp/lib -levent" + succeeded=yes + break; + fi + done + fi + + if test "$succeeded" != "yes" ; then + AC_MSG_ERROR([[We could not detect the event libraries (version $event_lib_version_req_shorten or higher). If you have a staged event library (still not installed) please specify \$EVENT_ROOT in your environment and do not give a PATH to --with-event option. If you are sure you have event installed, then check your version number looking in . See http://randspringer.de/event for more documentation.]]) + else + AC_SUBST(EVENT_CPPFLAGS) + AC_SUBST(EVENT_LDFLAGS) + AC_DEFINE(HAVE_EVENT,,[define if the EVENT library is available]) + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" +fi + +]) diff --git a/lib/cpp/configure.ac b/lib/cpp/configure.ac index d542feb8..8763a4a0 100644 --- a/lib/cpp/configure.ac +++ b/lib/cpp/configure.ac @@ -50,6 +50,8 @@ AC_CHECK_HEADERS([unistd.h]) AX_BOOST_BASE([1.33.1]) +AX_EVENT_BASE([1.2.0]) + AC_CHECK_LIB(pthread, pthread_create) AC_CHECK_LIB(rt, sched_get_priority_min) diff --git a/lib/cpp/src/transport/TFileTransport.cpp b/lib/cpp/src/transport/TFileTransport.cpp index 7bc0e4ab..cfdb3b95 100644 --- a/lib/cpp/src/transport/TFileTransport.cpp +++ b/lib/cpp/src/transport/TFileTransport.cpp @@ -7,6 +7,7 @@ #include #include #include +#include using namespace std; -- 2.17.1