From 9c5d8aa6871e227a9dd02e5cebb75debf426afe3 Mon Sep 17 00:00:00 2001 From: Glen Wiley Date: Fri, 7 Mar 2014 02:50:00 -0500 Subject: [PATCH] fixed detecting libevent v1 if libevent v2 is not available --- configure | 29 +++++++++++++++++++++++++++-- configure.ac | 9 +++++++-- src/config.h.in | 6 ++++++ src/example/getdns_libevent.h | 11 ++++++----- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/configure b/configure index aad6a775..2e91f15c 100755 --- a/configure +++ b/configure @@ -11169,6 +11169,16 @@ _ACEOF ;; esac +ac_fn_c_check_type "$LINENO" "u_char" "ac_cv_type_u_char" "$ac_includes_default" +if test "x$ac_cv_type_u_char" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_U_CHAR 1 +_ACEOF + + +fi + getdns_LIBS=$LIBS getdns_LDFLAGS=$LDFLAGS @@ -11268,8 +11278,23 @@ _ACEOF have_libevent=1 EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop" else - as_fn_error $? "event2/event.h missing, try without libevent" "$LINENO" 5 - have_libevent=0 + for ac_header in event.h +do : + ac_fn_c_check_header_compile "$LINENO" "event.h" "ac_cv_header_event_h" "$ac_includes_default +" +if test "x$ac_cv_header_event_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_EVENT_H 1 +_ACEOF + have_libevent=1 + EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop" +else + as_fn_error $? "event2/event.h and event.h missing, try without libevent" "$LINENO" 5 + have_libevent=0 +fi + +done + fi done diff --git a/configure.ac b/configure.ac index 97b3cd3e..b9f85b44 100644 --- a/configure.ac +++ b/configure.ac @@ -189,6 +189,7 @@ AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T AC_TYPE_UINT8_T +AC_CHECK_TYPES([u_char]) getdns_LIBS=$LIBS getdns_LDFLAGS=$LDFLAGS @@ -213,8 +214,12 @@ AS_IF([test x_$withval = x_no], [AC_CHECK_HEADERS([event2/event.h], [have_libevent=1] [EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop"], - [AC_MSG_ERROR([event2/event.h missing, try without libevent])] - [have_libevent=0], + [AC_CHECK_HEADERS([event.h], + [have_libevent=1] + [EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop"], + [AC_MSG_ERROR([event2/event.h and event.h missing, try without libevent])] + [have_libevent=0], + [AC_INCLUDES_DEFAULT])], [AC_INCLUDES_DEFAULT])], [AC_MSG_ERROR([libevent missing, try without libevent])] )], diff --git a/src/config.h.in b/src/config.h.in index 16cca3aa..e15a2edd 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -12,6 +12,9 @@ /* Define to 1 if you have the `event_base_new' function. */ #undef HAVE_EVENT_BASE_NEW +/* Define to 1 if you have the header file. */ +#undef HAVE_EVENT_H + /* Define to 1 if you have the header file. */ #undef HAVE_EV_H @@ -57,6 +60,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UV_H +/* Define to 1 if the system has the type `u_char'. */ +#undef HAVE_U_CHAR + /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR diff --git a/src/example/getdns_libevent.h b/src/example/getdns_libevent.h index 4c15fb0a..a513916b 100644 --- a/src/example/getdns_libevent.h +++ b/src/example/getdns_libevent.h @@ -27,10 +27,11 @@ #include #include #ifdef HAVE_EVENT2_EVENT_H -#include + #include #else -# ifndef u_char -# define u_char unsigned char -# endif -#include + #include +#endif + +#ifndef HAVE_U_CHAR + typedef unsigned char u_char; #endif