Code

Adds --with-lwres and --enable-emulate-getaddrinfo but are not used in any of
authorJeremy T. Bouse <undrgrid@users.sourceforge.net>
Thu, 6 Mar 2003 06:40:46 +0000 (06:40 +0000)
committerJeremy T. Bouse <undrgrid@users.sourceforge.net>
Thu, 6 Mar 2003 06:40:46 +0000 (06:40 +0000)
the code at this time. Has a check for IPv6 support but only runs if using the
emulate-getaddrinfo routines, this needs to be modified.
!!! I need input from results of this run on various platforms to see what
results are seen in plugins/config.h so please help test !!!

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@371 f882894a-f735-0410-b71e-b25c423dba1c

acinclude.m4
configure.in

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..70d82e4b0ba467e5e4e22dde769f69c4e01b79ca 100644 (file)
@@ -0,0 +1,78 @@
+dnl @synopsis ACX_WHICH_GETHOSTBYNAME_R
+dnl
+dnl Provides a test to determine the correct way to call gethostbyname_r
+dnl
+dnl defines HAVE_GETHOSTBYNAME_R to the number of arguments required
+dnl
+dnl e.g. 6 arguments (linux)
+dnl e.g. 5 arguments (solaris)
+dnl e.g. 3 arguments (osf/1)
+dnl
+dnl @version $Id$
+dnl @author Brian Stafford <brian@stafford.uklinux.net>
+dnl
+dnl based on version by Caolan McNamara <caolan@skynet.ie>
+dnl based on David Arnold's autoconf suggestion in the threads faq
+dnl
+AC_DEFUN(ACX_WHICH_GETHOSTBYNAME_R,
+[AC_CACHE_CHECK(number of arguments to gethostbyname_r,
+                acx_which_gethostbyname_r, [
+        AC_TRY_COMPILE([
+#               include <netdb.h> 
+        ],      [
+
+        char *name;
+        struct hostent *he;
+        struct hostent_data data;
+        (void) gethostbyname_r(name, he, &data);
+
+                ],acx_which_gethostbyname_r=3, 
+                        [
+dnl                     acx_which_gethostbyname_r=0
+  AC_TRY_COMPILE([
+#   include <netdb.h>
+  ], [
+        char *name;
+        struct hostent *he, *res;
+        char *buffer = NULL;
+        int buflen = 2048;
+        int h_errnop;
+        (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
+  ],acx_which_gethostbyname_r=6,
+  
+  [
+dnl  acx_which_gethostbyname_r=0
+  AC_TRY_COMPILE([
+#   include <netdb.h>
+  ], [
+                        char *name;
+                        struct hostent *he;
+                        char *buffer = NULL;
+                        int buflen = 2048;
+                        int h_errnop;
+                        (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
+  ],acx_which_gethostbyname_r=5,acx_which_gethostbyname_r=0)
+
+  ]
+  
+  )
+                        ]
+                )
+        ])
+
+if test $acx_which_gethostbyname_r -gt 0 ; then
+    AC_DEFINE_UNQUOTED([HAVE_GETHOSTBYNAME_R], $acx_which_gethostbyname_r,
+                       [Number of parameters to gethostbyname_r or 0 if not available])
+fi
+
+])
+
+dnl @synopsis ACX_HELP_STRING(OPTION,DESCRIPTION)
+AC_DEFUN([ACX_HELP_STRING],
+         [  $1 builtin([substr],[                       ],len($1))[$2]])
+
+
+dnl @synopsis ACX_FEATURE(ENABLE_OR_WITH,NAME[,VALUE])
+AC_DEFUN([ACX_FEATURE],
+         [echo "builtin([substr],[                                  ],len(--$1-$2))--$1-$2: ifelse($3,,[$]translit($1-$2,-,_),$3)"])
+
index 08996c9a46e475325f5d1580c5c83412782243f3..ef0d06b69dce28c5213296dfeb54366ed7fa004e 100644 (file)
@@ -231,6 +231,121 @@ elif test "$OPENSSL" = "/usr/local/ssl/bin/openssl"; then
 fi
 AC_ARG_WITH(openssl,--with-openssl=<dir> sets path to openssl installation,[OPENSSL=$withval])
 
+dnl #########################################################################
+dnl Check if Posix getaddrinfo() is available.  It is also possible to use
+dnl the version from the lwres library distributed with BIND.
+dnl #########################################################################
+AC_ARG_ENABLE([emulate-getaddrinfo],
+              ACX_HELP_STRING([--enable-emulate-getaddrinfo],
+                             [enable getaddrinfo emulation (default=no)]),
+              ,
+              enable_emulate_getaddrinfo=no)
+AC_ARG_WITH(lwres,
+            ACX_HELP_STRING([--with-lwres=DIR],
+                           [use lwres library for getaddrinfo (default=no)]),
+            ,
+            with_lwres=no)
+
+dnl ## enable force to test getaddrinfo.c
+if test x$enable_emulate_getaddrinfo = xforce ; then
+        enable_emulate_getaddrinfo=yes
+        have_getaddrinfo=no
+else
+
+have_getaddrinfo=no
+if test x$with_lwres != xno ; then
+        if test "$with_lwres" != yes ; then
+                   CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
+                   LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
+        fi
+        AC_CHECK_HEADERS(lwres/netdb.h, ,
+                        [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
+        AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
+                     [AC_MSG_ERROR([cannot find the lwres library])],
+                     -lnsl -lpthread)
+        have_getaddrinfo=yes
+fi
+
+if test x$have_getaddrinfo != xyes ; then
+        AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
+fi
+
+dnl # Special nonsense for systems that actually have getaddrinfo but
+dnl # redefine the name to something else, e.g. OSF
+if test x$have_getaddrinfo != xyes ; then
+        AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
+        AC_TRY_LINK([
+#               include <netdb.h>
+        ], [
+                struct addrinfo hints, *res;
+                int err;
+
+                err = getaddrinfo ("host", "service", &hints, &res);
+        ], [
+                have_getaddrinfo=yes
+                AC_MSG_RESULT(yes)
+        ], [AC_MSG_RESULT(no)])
+fi
+
+fi
+
+if test x$have_getaddrinfo != xno ; then
+        if test x$enable_emulate_getaddrinfo != xno ; then
+                AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
+        fi
+        AC_DEFINE(HAVE_GETADDRINFO, 1,
+                  [Does system provide RFC 2553/Posix getaddrinfo?])
+else
+        if test x$enable_emulate_getaddrinfo != xyes ; then
+                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
+        fi
+        LIBOBJS="$LIBOBJS getaddrinfo.o"
+fi
+
+if test x"$enable_emulate_getaddrinfo" != xno ; then
+    have_resolver=no
+
+  dnl  Try for getipnodebyname
+    AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
+    if test x"$have_resolver" != xno ; then
+         AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
+                   [Set when getipnodebyname is available])
+    fi
+
+  dnl  Try for gethostbyname_r
+    if test x"$have_resolver" = xno ; then
+        AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
+                       [have_resolver=yes
+                        ACX_WHICH_GETHOSTBYNAME_R])
+    fi
+
+  dnl  Try for gethostbyname
+    if test x"$have_resolver" = xno ; then
+        if test x"$enable_pthreads" != xno ; then
+            AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
+        fi
+        AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
+                       [AC_MSG_ERROR([cannot find gethostbyname])])
+    fi
+    LIBOBJS="$LIBOBJS gethostbyname.o"
+
+    AC_CACHE_CHECK([for IPv6 support], acx_cv_sys_use_ipv6, [
+            AC_TRY_COMPILE([
+#               include <netinet/in.h>
+            ], [
+                struct sockaddr_in6 sin6;
+                void *p;
+
+                sin6.sin6_family = AF_INET6;
+                sin6.sin6_port = 587;
+                p = &sin6.sin6_addr;
+            ], [acx_cv_sys_use_ipv6=yes], [acx_cv_sys_use_ipv6=no])
+    ])
+    if test x"$acx_cv_sys_use_ipv6" != xno ; then
+            AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
+    fi
+fi
+
 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
 if test "$FOUNDINCLUDE" = "no"; then
   _SAVEDCPPFLAGS="$CPPFLAGS"