Skip to content
Snippets Groups Projects
acinclude.m4 93.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • /* headers for ioctlsocket test (Windows) */
    #undef inline
    #ifdef HAVE_WINDOWS_H
    #ifndef WIN32_LEAN_AND_MEAN
    #define WIN32_LEAN_AND_MEAN
    #endif
    
    #include <windows.h>
    
    #ifdef HAVE_WINSOCK2_H
    #include <winsock2.h>
    #else
    #ifdef HAVE_WINSOCK_H
    #include <winsock.h>
    #endif
    #endif
    #endif
    
          ]],[[
            /* ioctlsocket source code (Windows) */
            SOCKET sd;
            unsigned long flags = 0;
            sd = socket(0, 0, 0);
            ioctlsocket(sd, FIONBIO, &flags);
          ]])
        ],[
          dnl ioctlsocket test was good
          nonblock="ioctlsocket"
          AC_DEFINE(HAVE_IOCTLSOCKET, 1,
            [use ioctlsocket() for non-blocking sockets])
        ])
      fi
      #
      if test "$nonblock" = "unknown"; then
        AC_LINK_IFELSE([
          AC_LANG_PROGRAM([[
    
    /* headers for IoctlSocket test (Amiga?) */
    #include <sys/ioctl.h>
    
          ]],[[
            /* IoctlSocket source code (Amiga?) */
            int socket;
            int flags = IoctlSocket(socket, FIONBIO, (long)1);
          ]])
        ],[
          dnl Ioctlsocket test was good
          nonblock="IoctlSocket"
          AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
            [use Ioctlsocket() for non-blocking sockets])
        ])
      fi
      #
      if test "$nonblock" = "unknown"; then
        AC_COMPILE_IFELSE([
          AC_LANG_PROGRAM([[
    
    /* headers for SO_NONBLOCK test (BeOS) */
    
          ]],[[
            /* SO_NONBLOCK source code (BeOS) */
            long b = 1;
            int socket;
            int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
          ]])
        ],[
          dnl the SO_NONBLOCK test was good
          nonblock="SO_NONBLOCK"
          AC_DEFINE(HAVE_SO_NONBLOCK, 1,
            [use SO_NONBLOCK for non-blocking sockets])
        ])
      fi
      #
    
      AC_MSG_RESULT($nonblock)
    
      #
      if test "$nonblock" = "unknown"; then
        AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
          [disabled non-blocking sockets])
    
        AC_MSG_WARN([non-block sockets disabled])
      fi
    ])
    
    
    
    dnl TYPE_IN_ADDR_T
    dnl -------------------------------------------------
    
    dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
    
    
    AC_DEFUN([TYPE_IN_ADDR_T], [
      AC_CHECK_TYPE([in_addr_t], ,[
        dnl in_addr_t not available
        AC_CACHE_CHECK([for in_addr_t equivalent],
          [curl_cv_in_addr_t_equiv], [
          curl_cv_in_addr_t_equiv="unknown"
          for t in "unsigned long" int size_t unsigned long; do
            if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
              AC_LINK_IFELSE([
                AC_LANG_PROGRAM([[
    
    #undef inline
    #ifdef HAVE_WINDOWS_H
    #ifndef WIN32_LEAN_AND_MEAN
    #define WIN32_LEAN_AND_MEAN
    #endif
    #include <windows.h>
    #ifdef HAVE_WINSOCK2_H
    #include <winsock2.h>
    #else
    #ifdef HAVE_WINSOCK_H
    #include <winsock.h>
    #endif
    #endif
    #else
    #ifdef HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    #ifdef HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
    #ifdef HAVE_NETINET_IN_H
    #include <netinet/in.h>
    #endif
    
    Yang Tse's avatar
    Yang Tse committed
    #ifdef HAVE_ARPA_INET_H
    #include <arpa/inet.h>
    #endif
    
                ]],[[
                  $t data = inet_addr ("1.2.3.4");
                ]])
              ],[
                curl_cv_in_addr_t_equiv="$t"
              ])
            fi
          done
        ])
        case "$curl_cv_in_addr_t_equiv" in
          unknown)
            AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
            ;;
          *)
            AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
              [Type to use in place of in_addr_t when system does not provide it.])
            ;;
        esac
      ],[
    
    #undef inline
    #ifdef HAVE_WINDOWS_H
    #ifndef WIN32_LEAN_AND_MEAN
    #define WIN32_LEAN_AND_MEAN
    #endif
    #include <windows.h>
    #ifdef HAVE_WINSOCK2_H
    #include <winsock2.h>
    #else
    #ifdef HAVE_WINSOCK_H
    #include <winsock.h>
    #endif
    #endif
    #else
    #ifdef HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    #ifdef HAVE_SYS_SOCKET_H
    
    #include <sys/socket.h>
    
    #endif
    #ifdef HAVE_NETINET_IN_H
    #include <netinet/in.h>
    #endif
    
    Yang Tse's avatar
    Yang Tse committed
    #ifdef HAVE_ARPA_INET_H
    #include <arpa/inet.h>
    #endif
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
      ]) dnl AC_CHECK_TYPE
    ]) dnl AC_DEFUN
    
    dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
    
    dnl -------------------------------------------------
    
    dnl Check if monotonic clock_gettime is available.
    
    AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
    
      AC_REQUIRE([AC_HEADER_TIME])dnl
    
      AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
      AC_MSG_CHECKING([for monotonic clock_gettime])
    
        AC_LANG_PROGRAM([[
    
    #ifdef HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    #ifdef HAVE_SYS_TIME_H
    #include <sys/time.h>
    #ifdef TIME_WITH_SYS_TIME
    #include <time.h>
    #endif
    #else
    #ifdef HAVE_TIME_H
    #include <time.h>
    #endif
    #endif
    
          struct timespec ts;
          (void)clock_gettime(CLOCK_MONOTONIC, &ts);
    
      ],[
        AC_MSG_RESULT([yes])
        ac_cv_func_clock_gettime="yes"
      ],[
        AC_MSG_RESULT([no])
        ac_cv_func_clock_gettime="no"
      ])
    
      dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
      dnl until library linking and run-time checks for clock_gettime succeed.
    
    dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
    dnl -------------------------------------------------
    dnl If monotonic clock_gettime is available then,
    dnl check and prepended to LIBS any needed libraries.
    
    AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
      AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
    
      if test "$ac_cv_func_clock_gettime" = "yes"; then
        #
        AC_MSG_CHECKING([for clock_gettime in libraries])
        #
        curl_cv_save_LIBS="$LIBS"
        curl_cv_gclk_LIBS="unknown"
        #
        for x_xlibs in '' '-lrt' '-lposix4' ; do
    
          if test "$curl_cv_gclk_LIBS" = "unknown"; then
            if test -z "$x_xlibs"; then
              LIBS="$curl_cv_save_LIBS"
            else
              LIBS="$x_xlibs $curl_cv_save_LIBS"
            fi
            AC_LINK_IFELSE([
              AC_LANG_PROGRAM([[
    
    #ifdef HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    #ifdef HAVE_SYS_TIME_H
    #include <sys/time.h>
    #ifdef TIME_WITH_SYS_TIME
    #include <time.h>
    #endif
    #else
    #ifdef HAVE_TIME_H
    #include <time.h>
    #endif
    #endif
    
              ]],[[
                struct timespec ts;
                (void)clock_gettime(CLOCK_MONOTONIC, &ts);
              ]])
            ],[
              curl_cv_gclk_LIBS="$x_xlibs"
            ])
          fi
    
        done
        #
        LIBS="$curl_cv_save_LIBS"
        #
        case X-"$curl_cv_gclk_LIBS" in
          X-unknown)
            AC_MSG_RESULT([cannot find clock_gettime])
            AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
            ac_cv_func_clock_gettime="no"
            ;;
          X-)
            AC_MSG_RESULT([no additional lib required])
            ac_cv_func_clock_gettime="yes"
            ;;
          *)
            if test -z "$curl_cv_save_LIBS"; then
              LIBS="$curl_cv_gclk_LIBS"
            else
              LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
            fi
            AC_MSG_RESULT([$curl_cv_gclk_LIBS])
            ac_cv_func_clock_gettime="yes"
            ;;
        esac
        #
    
        dnl only do runtime verification when not cross-compiling
        if test "x$cross_compiling" != "xyes" &&
          test "$ac_cv_func_clock_gettime" = "yes"; then
          AC_MSG_CHECKING([if monotonic clock_gettime works])
          AC_RUN_IFELSE([
            AC_LANG_PROGRAM([[
    #ifdef HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    #ifdef HAVE_SYS_TIME_H
    #include <sys/time.h>
    #ifdef TIME_WITH_SYS_TIME
    #include <time.h>
    #endif
    #else
    #ifdef HAVE_TIME_H
    #include <time.h>
    #endif
    #endif
            ]],[[
              struct timespec ts;
              if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
                exit(0);
    
            ]])
          ],[
            AC_MSG_RESULT([yes])
          ],[
            AC_MSG_RESULT([no])
            AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
            ac_cv_func_clock_gettime="no"
            LIBS="$curl_cv_save_LIBS"
          ])
        fi
        #
    
        case "$ac_cv_func_clock_gettime" in
          yes)
            AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
              [Define to 1 if you have the clock_gettime function and monotonic timer.])
            ;;
        esac
        #
      fi
    
    
    dnl CURL_CHECK_FUNC_SELECT
    dnl -------------------------------------------------
    dnl Test if the socket select() function is available,
    dnl and check its return type and the types of its
    dnl arguments. If the function succeeds HAVE_SELECT
    dnl will be defined, defining the types of the
    dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
    dnl and SELECT_TYPE_ARG5, defining the type of the
    dnl function return value in SELECT_TYPE_RETV, and
    dnl also defining the type qualifier of fifth argument
    dnl in SELECT_QUAL_ARG5.
    
    AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
      AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
      AC_CHECK_HEADERS(sys/select.h sys/socket.h)
      #
      AC_MSG_CHECKING([for select])
    
        AC_LANG_PROGRAM([[
    
    #undef inline
    #ifdef HAVE_WINDOWS_H
    #ifndef WIN32_LEAN_AND_MEAN
    #define WIN32_LEAN_AND_MEAN
    #endif
    #include <windows.h>
    #ifdef HAVE_WINSOCK2_H
    #include <winsock2.h>
    #else
    #ifdef HAVE_WINSOCK_H
    #include <winsock.h>
    #endif
    #endif
    #endif
    #ifdef HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    #ifdef HAVE_SYS_TIME_H
    #include <sys/time.h>
    #ifdef TIME_WITH_SYS_TIME
    #include <time.h>
    #endif
    #else
    #ifdef HAVE_TIME_H
    #include <time.h>
    #endif
    #endif
    #ifndef HAVE_WINDOWS_H
    #ifdef HAVE_SYS_SELECT_H
    #include <sys/select.h>
    #endif
    #ifdef HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
    #endif
    
          select(0, 0, 0, 0, 0);
    
      ],[
        AC_MSG_RESULT([yes])
        curl_cv_select="yes"
      ],[
        AC_MSG_RESULT([no])
        curl_cv_select="no"
    
      ])
      #
      if test "$curl_cv_select" = "yes"; then
        AC_CACHE_CHECK([types of args and return type for select],
          [curl_cv_func_select_args], [
          curl_cv_func_select_args="unknown"
          for sel_retv in 'int' 'ssize_t'; do
            for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
              for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
                for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
    
                  if test "$curl_cv_func_select_args" = "unknown"; then
                    AC_COMPILE_IFELSE([
                      AC_LANG_PROGRAM([[
    
    #undef inline
    #ifdef HAVE_WINDOWS_H
    #ifndef WIN32_LEAN_AND_MEAN
    #define WIN32_LEAN_AND_MEAN
    #endif
    #include <windows.h>
    #ifdef HAVE_WINSOCK2_H
    #include <winsock2.h>
    #else
    #ifdef HAVE_WINSOCK_H
    #include <winsock.h>
    #endif
    #endif
    #define SELECTCALLCONV PASCAL
    #endif
    #ifdef HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    #ifdef HAVE_SYS_TIME_H
    #include <sys/time.h>
    #ifdef TIME_WITH_SYS_TIME
    #include <time.h>
    #endif
    #else
    #ifdef HAVE_TIME_H
    #include <time.h>
    #endif
    #endif
    #ifndef HAVE_WINDOWS_H
    #ifdef HAVE_SYS_SELECT_H
    #include <sys/select.h>
    #endif
    #ifdef HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
    #define SELECTCALLCONV
    #endif
    #ifndef HAVE_STRUCT_TIMEVAL
    
                        struct timeval {
                          long tv_sec;
                          long tv_usec;
                        };
    #endif
                        extern $sel_retv SELECTCALLCONV select($sel_arg1,
                                                               $sel_arg234,
                                                               $sel_arg234,
                                                               $sel_arg234,
                                                               $sel_arg5);
                      ]],[[
                        $sel_arg1   nfds=0;
                        $sel_arg234 rfds=0;
                        $sel_arg234 wfds=0;
                        $sel_arg234 efds=0;
                        $sel_retv res = select(nfds, rfds, wfds, efds, 0);
                      ]])
                    ],[
                      curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
                    ])
                  fi
    
                done
              done
            done
          done
        ]) # AC_CACHE_CHECK
        if test "$curl_cv_func_select_args" = "unknown"; then
          AC_MSG_WARN([Cannot find proper types to use for select args])
          AC_MSG_WARN([HAVE_SELECT will not be defined])
        else
          select_prev_IFS=$IFS; IFS=','
          set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
          IFS=$select_prev_IFS
          shift
          #
          sel_qual_type_arg5=$[3]
          #
          AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
            [Define to the type of arg 1 for select.])
          AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
            [Define to the type of args 2, 3 and 4 for select.])
          AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
            [Define to the function return type for select.])
          #
          prev_sh_opts=$-
          #
          case $prev_sh_opts in
            *f*)
              ;;
            *)
              set -f
              ;;
          esac
          #
          case "$sel_qual_type_arg5" in
            const*)
              sel_qual_arg5=const
              sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
            ;;
            *)
              sel_qual_arg5=
              sel_type_arg5=$sel_qual_type_arg5
            ;;
          esac
          #
          AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
            [Define to the type qualifier of arg 5 for select.])
          AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
            [Define to the type of arg 5 for select.])
          #
          case $prev_sh_opts in
            *f*)
              ;;
            *)
              set +f
              ;;
          esac
          #
          AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
            [Define to 1 if you have the select function.])
          ac_cv_func_select="yes"
        fi
      fi
    ]) # AC_DEFUN
    
    
    
    dnl ************************************************************
    dnl check for "localhost", if it doesn't exist, we can't do the
    dnl gethostbyname_r tests!
    dnl 
    
    
    AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
    
    AC_MSG_CHECKING([if "localhost" resolves])
    AC_TRY_RUN([
    #include <string.h>
    #include <sys/types.h>
    #include <netdb.h>
    
    #ifndef NULL
    #define NULL (void *)0
    #endif
    
    
    int
    main () {
    struct hostent *h;
    h = gethostbyname("localhost");
    exit (h == NULL ? 1 : 0); }],[
          AC_MSG_RESULT(yes)],[
          AC_MSG_RESULT(no)
          AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
    
          ]
    )
    ])
    
    dnl ************************************************************
    
    dnl check for working getaddrinfo() that works with AI_NUMERICHOST
    
    AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
    
      AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
      AC_TRY_RUN( [
    #include <netdb.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    
    
        struct addrinfo hints, *ai;
        int error;
    
        memset(&hints, 0, sizeof(hints));
    
        hints.ai_family = AF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
        error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
        if (error) {
    
    }
    ],[
      ac_cv_working_getaddrinfo="yes"
    ],[
      ac_cv_working_getaddrinfo="no"
    ],[
      ac_cv_working_getaddrinfo="yes"
    ])])
    if test "$ac_cv_working_getaddrinfo" = "yes"; then
      AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
      AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
    
      IPV6_ENABLED=1
      AC_SUBST(IPV6_ENABLED)
    fi
    ])
    
    
    
      dnl check for localtime_r
    
      AC_CHECK_FUNCS(localtime_r,[
        AC_MSG_CHECKING(whether localtime_r is declared)
        AC_EGREP_CPP(localtime_r,[
    
    #include <time.h>],[
          AC_MSG_RESULT(yes)],[
          AC_MSG_RESULT(no)
          AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
          AC_EGREP_CPP(localtime_r,[
    
    #define _REENTRANT
    #include <time.h>],[
    
            AC_MSG_RESULT(yes)],
            AC_MSG_RESULT(no))])])
    
    dnl
    dnl This function checks for strerror_r(). If it isn't found at first, it
    dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
    dnl in order to find this function.
    dnl
    dnl If the function is found, it will then proceed to check how the function
    dnl actually works: glibc-style or POSIX-style.
    dnl
    dnl glibc:
    dnl      char *strerror_r(int errnum, char *buf, size_t n);
    dnl  
    dnl  What this one does is to return the error string (no surprises there),
    dnl  but it doesn't usually copy anything into buf!  The 'buf' and 'n'
    dnl  parameters are only meant as an optional working area, in case strerror_r
    dnl  needs it.  A quick test on a few systems shows that it's generally not
    dnl  touched at all.
    dnl
    dnl POSIX:
    dnl      int strerror_r(int errnum, char *buf, size_t n);
    dnl
    
    AC_DEFUN([CURL_CHECK_STRERROR_R],
    [
    
      AC_CHECK_FUNCS(strerror_r)
    
      if test "x$ac_cv_func_strerror_r" = "xyes"; then
    
    
        AC_MSG_CHECKING(whether strerror_r is declared)
        AC_EGREP_CPP(strerror_r,[
    
    #include <string.h>],[
          AC_MSG_RESULT(yes)],[
          AC_MSG_RESULT(no)
    
          AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
    
          AC_EGREP_CPP(strerror_r,[
    
    #include <string.h>],[
    
            AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
           ) dnl with _THREAD_SAFE
        ]) dnl plain cpp for it
    
        dnl determine if this strerror_r() is glibc or POSIX
        AC_MSG_CHECKING([for a glibc strerror_r API])
        AC_TRY_RUN([
    #include <string.h>
    #include <errno.h>
    int
    main () {
      char buffer[1024]; /* big enough to play with */
      char *string =
        strerror_r(EACCES, buffer, sizeof(buffer));
        /* this should've returned a string */
        if(!string || !string[0])
          return 99;
        return 0;
    }
    ],
    
        AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
        AC_MSG_RESULT([yes]),
    
    
        dnl Use an inferior method of strerror_r detection while cross-compiling
        AC_EGREP_CPP(yes, [
    #include <features.h>
    #ifdef __GLIBC__
    yes
    #endif
    ], 
          dnl looks like glibc, so assume a glibc-style strerror_r()
          GLIBC_STRERROR_R="1"
          AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
          AC_MSG_RESULT([yes]),
          AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
        ) dnl while cross-compiling
    
        if test -z "$GLIBC_STRERROR_R"; then
    
          AC_MSG_CHECKING([for a POSIX strerror_r API])
          AC_TRY_RUN([
    
    #include <string.h>
    #include <errno.h>
    int
    main () {
      char buffer[1024]; /* big enough to play with */
      int error =
        strerror_r(EACCES, buffer, sizeof(buffer));
        /* This should've returned zero, and written an error string in the
           buffer.*/
        if(!buffer[0] || error)
          return 99;
        return 0;
    }
    ],
    
          AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
          AC_MSG_RESULT([yes]),
          AC_MSG_RESULT([no]) ,
          dnl cross-compiling!
          AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
        )
    
        fi dnl if not using glibc API
    
      fi dnl we have a strerror_r
    
    [
      dnl determine if function definition for inet_ntoa_r exists.
      AC_CHECK_FUNCS(inet_ntoa_r,[
        AC_MSG_CHECKING(whether inet_ntoa_r is declared)
        AC_EGREP_CPP(inet_ntoa_r,[
    
    #include <arpa/inet.h>],[
    
          AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
    
          AC_MSG_RESULT(yes)],[
          AC_MSG_RESULT(no)
          AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
          AC_EGREP_CPP(inet_ntoa_r,[
    
    #define _REENTRANT
    #include <arpa/inet.h>],[
    
            AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
            AC_MSG_RESULT(yes)],
            AC_MSG_RESULT(no))])])
    
    
    dnl CURL_CHECK_GETHOSTBYADDR_R
    dnl -------------------------------------------------
    dnl check number of arguments for gethostbyaddr_r, it
    dnl might take either 5, 7, or 8 arguments.
    
    AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
      #
      AC_MSG_CHECKING([for gethostbyaddr_r])
      AC_LINK_IFELSE([
        AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
      ],[
        AC_MSG_RESULT([yes])
        tmp_cv_gethostbyaddr_r="yes"
      ],[
        AC_MSG_RESULT([no])
        tmp_cv_gethostbyaddr_r="no"
      ])
      #
      if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
        AC_MSG_CHECKING([deeper for gethostbyaddr_r])
        AC_LINK_IFELSE([
          AC_LANG_PROGRAM([[
          ]],[[
            gethostbyaddr_r();
          ]])
        ],[
          AC_MSG_RESULT([yes])
          tmp_cv_gethostbyaddr_r="yes"
        ],[
    
          AC_MSG_RESULT([but still no])
    
          tmp_cv_gethostbyaddr_r="no"
        ])
      fi
      #
      if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
    
        ac_cv_gethostbyaddr_r_args="unknown"
    
        AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
        AC_COMPILE_IFELSE([
          AC_LANG_PROGRAM([[
    
    #include <sys/types.h>
    
    #include <netdb.h>
          ]],[[
            char * address;
            int length;
            int type;
            struct hostent h;
            struct hostent_data hdata;
            int rc;
            rc = gethostbyaddr_r(address, length, type, &h, &hdata);
          ]])
        ],[
          AC_MSG_RESULT([yes])
    
          AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
    
          ac_cv_gethostbyaddr_r_args="5"
        ],[
          AC_MSG_RESULT([no])
        ])
    
        if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
          AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
          AC_COMPILE_IFELSE([
            AC_LANG_PROGRAM([[
    
    #define _REENTRANT
    #include <sys/types.h>
    
    #include <netdb.h>
            ]],[[
              char * address;
              int length;
              int type;
              struct hostent h;
              struct hostent_data hdata;
              int rc;
              rc = gethostbyaddr_r(address, length, type, &h, &hdata);
            ]])
          ],[
            AC_MSG_RESULT([yes])
            AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
            ac_cv_gethostbyaddr_r_args="5"
          ],[
            AC_MSG_RESULT([no])
          ])
        fi
    
        if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
          AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
          AC_COMPILE_IFELSE([
            AC_LANG_PROGRAM([[
    
    #include <sys/types.h>
    
    #include <netdb.h>
            ]],[[
              char * address;
              int length;
              int type;
              struct hostent h;
              char buffer[8192];
              int h_errnop;
              struct hostent * hp;
              hp = gethostbyaddr_r(address, length, type, &h,
                                   buffer, 8192, &h_errnop);
            ]])
          ],[
            AC_MSG_RESULT([yes])
            AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
            ac_cv_gethostbyaddr_r_args="7"
          ],[
            AC_MSG_RESULT([no])
          ])
        fi
    
    
        if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
          AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 7 arguments])
          AC_COMPILE_IFELSE([
            AC_LANG_PROGRAM([[
    #undef _REENTRANT
    #define _REENTRANT
    #include <sys/types.h>
    #include <netdb.h>
            ]],[[
              char * address;
              int length;
              int type;
              struct hostent h;
              char buffer[8192];
              int h_errnop;
              struct hostent * hp;
              hp = gethostbyaddr_r(address, length, type, &h,
                                   buffer, 8192, &h_errnop);
            ]])
          ],[
            AC_MSG_RESULT([yes])
            AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
            ac_cv_gethostbyaddr_r_args="7"
          ],[
            AC_MSG_RESULT([no])
          ])
        fi
    
    
        if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
          AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
          AC_COMPILE_IFELSE([
            AC_LANG_PROGRAM([[
    
    #include <sys/types.h>
    
    #include <netdb.h>
            ]],[[
              char * address;
              int length;
              int type;
              struct hostent h;
              char buffer[8192];
              int h_errnop;
              struct hostent * hp;
              int rc;
              rc = gethostbyaddr_r(address, length, type, &h,
                                   buffer, 8192, &hp, &h_errnop);
            ]])
          ],[
            AC_MSG_RESULT([yes])
            AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
            ac_cv_gethostbyaddr_r_args="8"
          ],[
            AC_MSG_RESULT([no])
          ])
        fi
    
    
        if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
          AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 8 arguments])
          AC_COMPILE_IFELSE([
            AC_LANG_PROGRAM([[
    #undef _REENTRANT
    #define _REENTRANT
    #include <sys/types.h>
    #include <netdb.h>
            ]],[[
              char * address;
              int length;
              int type;
              struct hostent h;
              char buffer[8192];
              int h_errnop;
              struct hostent * hp;
              int rc;
              rc = gethostbyaddr_r(address, length, type, &h,
                                   buffer, 8192, &hp, &h_errnop);
            ]])
          ],[
            AC_MSG_RESULT([yes])
            AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
            ac_cv_gethostbyaddr_r_args="8"
          ],[
            AC_MSG_RESULT([no])
          ])
        fi
    
    
        if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
    
          AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
          AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
          ac_cv_func_gethostbyaddr_r="no"
    
        else
          AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
            [Define to 1 if you have the gethostbyaddr_r function.])
          ac_cv_func_gethostbyaddr_r="yes"
        fi
    
    
      else
        ac_cv_func_gethostbyaddr_r="no"
    
    
    dnl CURL_CHECK_GETHOSTBYNAME_R
    dnl -------------------------------------------------
    dnl check number of arguments for gethostbyname_r, it
    dnl might take either 3, 5, or 6 arguments.
    
    AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
      #
      AC_MSG_CHECKING([for gethostbyname_r])
      AC_LINK_IFELSE([
        AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
      ],[
        AC_MSG_RESULT([yes])
        tmp_cv_gethostbyname_r="yes"
      ],[
        AC_MSG_RESULT([no])
        tmp_cv_gethostbyname_r="no"
      ])
      #
      if test "$tmp_cv_gethostbyname_r" != "yes"; then
        AC_MSG_CHECKING([deeper for gethostbyname_r])
        AC_LINK_IFELSE([
          AC_LANG_PROGRAM([[
          ]],[[
            gethostbyname_r();
          ]])
        ],[
          AC_MSG_RESULT([yes])
          tmp_cv_gethostbyname_r="yes"
        ],[
    
          AC_MSG_RESULT([but still no])
    
          tmp_cv_gethostbyname_r="no"
        ])
      fi
      #
      if test "$tmp_cv_gethostbyname_r" = "yes"; then
    
        ac_cv_gethostbyname_r_args="unknown"