From 0280c8fa837f7a47bec0d446f621b6c8768c1cf7 Mon Sep 17 00:00:00 2001 From: Glen Wiley Date: Mon, 2 Jun 2014 08:34:34 -0400 Subject: [PATCH] fixed configure test for libevent 1.x on RHEL/CentOS --- configure | 81 ++++++++++++++++++++++++++++++++++++++++--------- configure.ac | 16 ++++++++-- src/config.h.in | 7 +++-- 3 files changed, 83 insertions(+), 21 deletions(-) diff --git a/configure b/configure index 30b01122..6c89df61 100755 --- a/configure +++ b/configure @@ -1859,6 +1859,52 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t + +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -5642,7 +5688,7 @@ ia64-*-hpux*) rm -rf conftest* ;; -x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext @@ -5660,10 +5706,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; - powerpc64le-*linux*) - LD="${LD-ld} -m elf32lppclinux" - ;; - powerpc64-*linux*) + ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) @@ -5682,10 +5725,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - powerpcle-*linux*) - LD="${LD-ld} -m elf64lppc" - ;; - powerpc-*linux*) + ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) @@ -7140,6 +7180,10 @@ _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= @@ -11174,17 +11218,18 @@ _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 : +ac_fn_c_check_decl "$LINENO" "u_char" "ac_cv_have_decl_u_char" "$ac_includes_default" +if test "x$ac_cv_have_decl_u_char" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi cat >>confdefs.h <<_ACEOF -#define HAVE_U_CHAR 1 +#define HAVE_DECL_U_CHAR $ac_have_decl _ACEOF -fi - - getdns_LIBS=$LIBS getdns_LDFLAGS=$LDFLAGS @@ -11198,6 +11243,9 @@ else fi +# if user specified a location for libevent then use it, otherwise +# check for libevent 1 + have_libevent=0 EXTENSION_LIBEVENT_EXT_LIBS="" EXTENSION_LIBEVENT_LIB="" @@ -11286,6 +11334,9 @@ else 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 HAVE_DECL_U_CHAR == 0 + typedef unsigned char u_char; + #endif " if test "x$ac_cv_header_event_h" = xyes; then : cat >>confdefs.h <<_ACEOF diff --git a/configure.ac b/configure.ac index 77480756..6166a8d3 100644 --- a/configure.ac +++ b/configure.ac @@ -189,7 +189,7 @@ AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T AC_TYPE_UINT8_T -AC_CHECK_TYPES([u_char]) +AC_CHECK_DECLS([u_char]) getdns_LIBS=$LIBS getdns_LDFLAGS=$LDFLAGS @@ -200,6 +200,13 @@ AC_ARG_WITH([libevent], [with_libevent=search], [withval=no]) +# libevent 1.x requires a u_char typedef which is not always available +# on some systems so our check is a little complicated +# we further need to ensure that this is included in the getdns headers +# that get installed later so some users may not be building in an +# environment that has the generated config.h SO we need to generate +# this one extra header in that case + have_libevent=0 EXTENSION_LIBEVENT_EXT_LIBS="" EXTENSION_LIBEVENT_LIB="" @@ -219,9 +226,12 @@ AS_IF([test x_$withval = x_no], [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] + [#if HAVE_DECL_U_CHAR == 0 + typedef unsigned char u_char; + #endif])], [AC_INCLUDES_DEFAULT])], - [AC_MSG_ERROR([libevent missing, try without libevent])] + [AC_MSG_ERROR([libevent missing, try without libevent])] )], [have_libevent=1] [AC_MSG_NOTICE([assuming libevent in $withval])] diff --git a/src/config.h.in b/src/config.h.in index d3c657b9..4578b95d 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,5 +1,9 @@ /* src/config.h.in. Generated from configure.ac by autoheader. */ +/* Define to 1 if you have the declaration of `u_char', and to 0 if you don't. + */ +#undef HAVE_DECL_U_CHAR + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H @@ -63,9 +67,6 @@ /* 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