Added ax_event_base.m4 to find and configure libevent
authorMarc Slemko <marc@apache.org>
Wed, 17 Jan 2007 08:32:16 +0000 (08:32 +0000)
committerMarc Slemko <marc@apache.org>
Wed, 17 Jan 2007 08:32:16 +0000 (08:32 +0000)
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
lib/cpp/aclocal/ax_event_base.m4 [new file with mode: 0644]
lib/cpp/configure.ac
lib/cpp/src/transport/TFileTransport.cpp

index 771830a..932e802 100644 (file)
@@ -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 (file)
index 0000000..4418350
--- /dev/null
@@ -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 <marc@facebook.com>
+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 <event/version.hpp>. 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
+
+])
index d542feb..8763a4a 100644 (file)
@@ -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)
index 7bc0e4a..cfdb3b9 100644 (file)
@@ -7,6 +7,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <iostream>
+#include <sys/stat.h>
 
 using namespace std;