Change the upstream source URL
[platform/upstream/c-ares.git] / configure.ac
index 666facd..703bde0 100644 (file)
@@ -1,12 +1,56 @@
 AC_PREREQ(2.57)
 
-dnl Version not hardcoded here. Fetched later from ares_version.h
-AC_INIT([c-ares], [-],
-  [c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares])
+AC_INIT([c-ares], [1.17.1],
+  [c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares])
 
-AC_CONFIG_SRCDIR([ares_ipv6.h])
-AM_CONFIG_HEADER([config.h])
+CARES_VERSION_INFO="6:2:4"
+dnl This flag accepts an argument of the form current[:revision[:age]]. So,
+dnl passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
+dnl 1.
+dnl
+dnl If either revision or age are omitted, they default to 0. Also note that age
+dnl must be less than or equal to the current interface number.
+dnl
+dnl Here are a set of rules to help you update your library version information:
+dnl
+dnl 1.Start with version information of 0:0:0 for each libtool library.
+dnl
+dnl 2.Update the version information only immediately before a public release of
+dnl your software. More frequent updates are unnecessary, and only guarantee
+dnl that the current interface number gets larger faster.
+dnl
+dnl 3.If the library source code has changed at all since the last update, then
+dnl increment revision (c:r+1:a)
+dnl
+dnl 4.If any interfaces have been added, removed, or changed since the last
+dnl update, increment current, and set revision to 0. (c+1:r=0:a)
+dnl
+dnl 5.If any interfaces have been added since the last public release, then
+dnl increment age. (c:r:a+1)
+dnl
+dnl 6.If any interfaces have been removed since the last public release, then
+dnl set age to 0. (c:r:a=0)
+dnl
+AC_SUBST([CARES_VERSION_INFO])
+
+XC_OVR_ZZ50
+XC_OVR_ZZ60
+CARES_OVERRIDE_AUTOCONF
+
+AC_CONFIG_SRCDIR([src/lib/ares_ipv6.h])
+AC_CONFIG_HEADERS([src/lib/ares_config.h include/ares_build.h])
+AC_CONFIG_MACRO_DIR([m4])
 AM_MAINTAINER_MODE
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+CARES_CHECK_OPTION_DEBUG
+CARES_CHECK_OPTION_OPTIMIZE
+CARES_CHECK_OPTION_WARNINGS
+CARES_CHECK_OPTION_WERROR
+CARES_CHECK_OPTION_SYMBOL_HIDING
+CARES_CHECK_OPTION_EXPOSE_STATICS
+
+XC_CHECK_PATH_SEPARATOR
 
 dnl SED is mandatory for configure process and libtool.
 dnl Set it now, allowing it to be changed later.
@@ -42,19 +86,19 @@ fi
 AC_SUBST([EGREP])
 
 dnl AR is mandatory for configure process and libtool.
-dnl This is target dependant, so check it as a tool.
-AC_PATH_TOOL([AR], [ar], [not_found],
-  [$PATH:/usr/bin:/usr/local/bin])
-if test -z "$AR" || test "$AR" = "not_found"; then
-  AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
+dnl This is target dependent, so check it as a tool.
+if test -z "$AR"; then
+  dnl allow it to be overridden
+  AC_PATH_TOOL([AR], [ar], [not_found],
+    [$PATH:/usr/bin:/usr/local/bin])
+  if test -z "$AR" || test "$AR" = "not_found"; then
+    AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
+  fi
 fi
 AC_SUBST([AR])
 
-dnl Fetch c-ares version from ares_version.h
-VERSION=`$SED -ne 's/^#define ARES_VERSION_STR "\(.*\)"/\1/p' ${srcdir}/ares_version.h`
-AM_INIT_AUTOMAKE([c-ares], [$VERSION])
-AC_MSG_CHECKING([c-ares version])
-AC_MSG_RESULT([$VERSION])
+AX_CODE_COVERAGE
+
 
 dnl
 dnl Detect the canonical host and target build environment
@@ -64,14 +108,16 @@ AC_CANONICAL_HOST
 dnl Get system canonical name
 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
 
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_PROG_INSTALL
+XC_CHECK_PROG_CC
+AX_CXX_COMPILE_STDCXX_11([noext],[optional])
+
+XC_AUTOMAKE
 
 dnl This defines _ALL_SOURCE for AIX
 CARES_CHECK_AIX_ALL_SOURCE
 
 dnl Our configure and build reentrant settings
+CARES_CONFIGURE_THREAD_SAFE
 CARES_CONFIGURE_REENTRANT
 
 dnl check for how to do large files
@@ -83,200 +129,85 @@ case $host_os in
     ;;
 esac
 
-dnl support building of Windows DLLs
-AC_LIBTOOL_WIN32_DLL
-
-dnl ************************************************************
-dnl Option to switch on debug options. This makes an assumption that
-dnl this is built as an 'ares' subdir in the curl source tree. Subject for
-dnl improval in the future!
-dnl
-AC_MSG_CHECKING([whether to enable debug options])
-AC_ARG_ENABLE(debug,
-AC_HELP_STRING([--enable-debug],[Enable pedantic debug options])
-AC_HELP_STRING([--disable-debug],[Disable debug options]),
-[ case "$enableval" in
-  no)
-       AC_MSG_RESULT(no)
-       ;;
-  *)   AC_MSG_RESULT(yes)
-
-    dnl when doing the debug stuff, use static library only
-    AC_DISABLE_SHARED
-
-    debugbuild="yes"
-
-    dnl the entire --enable-debug is a hack that lives and runs on top of
-    dnl libcurl stuff so this BUILDING_LIBCURL is not THAT much uglier
-    AC_DEFINE(BUILDING_LIBCURL, 1, [when building as static part of libcurl])
-
-    CPPFLAGS="$CPPFLAGS -DCURLDEBUG -I$srcdir/../include"
-    CFLAGS="$CFLAGS -g" 
-
-    dnl set compiler "debug" options to become more picky, and remove
-    dnl optimize options from CFLAGS
-    CURL_CC_DEBUG_OPTS
-
-       ;;
-  esac ],
-       AC_MSG_RESULT(no)
-)
-AM_CONDITIONAL(DEBUGBUILD, test x$debugbuild = xyes)
-AM_CONDITIONAL(CURLDEBUG, test x$debugbuild = xyes)
-
-dnl skip libtool C++ and Fortran compiler checks
-m4_ifdef([AC_PROG_CXX], [m4_undefine([AC_PROG_CXX])])
-m4_defun([AC_PROG_CXX],[])
-m4_ifdef([AC_PROG_CXXCPP], [m4_undefine([AC_PROG_CXXCPP])])
-m4_defun([AC_PROG_CXXCPP],[true])
-m4_ifdef([AC_PROG_F77], [m4_undefine([AC_PROG_F77])])
-m4_defun([AC_PROG_F77],[])
-
-dnl skip libtool C++ and Fortran linker checks
-m4_ifdef([AC_LIBTOOL_CXX], [m4_undefine([AC_LIBTOOL_CXX])])
-m4_defun([AC_LIBTOOL_CXX],[])
-m4_ifdef([AC_LIBTOOL_CXXCPP], [m4_undefine([AC_LIBTOOL_CXXCPP])])
-m4_defun([AC_LIBTOOL_CXXCPP],[true])
-m4_ifdef([AC_LIBTOOL_F77], [m4_undefine([AC_LIBTOOL_F77])])
-m4_defun([AC_LIBTOOL_F77],[])
-
-dnl force libtool to build static libraries with PIC on AMD64-linux
-AC_MSG_CHECKING([if arch-OS host is AMD64-linux (to build static libraries with PIC)])
-case $host in
-  x86_64*linux*)
-    AC_MSG_RESULT([yes])
-    with_pic=yes
-    ;;
-  *)
-    AC_MSG_RESULT([no])
-    ;;
-esac
-
-dnl libtool setup
-AC_PROG_LIBTOOL
-
-AC_MSG_CHECKING([if we need -no-undefined])
-case $host in
-  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
-    need_no_undefined=yes
-    ;;
-  *)
-    need_no_undefined=no
-    ;;
-esac
-AC_MSG_RESULT($need_no_undefined)
-AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
+XC_LIBTOOL
+
+
+#
+# Automake conditionals based on libtool related checks
+#
+
+AM_CONDITIONAL([CARES_LT_SHLIB_USE_VERSION_INFO],
+  [test "x$xc_lt_shlib_use_version_info" = 'xyes'])
+AM_CONDITIONAL([CARES_LT_SHLIB_USE_NO_UNDEFINED],
+  [test "x$xc_lt_shlib_use_no_undefined" = 'xyes'])
+AM_CONDITIONAL([CARES_LT_SHLIB_USE_MIMPURE_TEXT],
+  [test "x$xc_lt_shlib_use_mimpure_text" = 'xyes'])
+
+#
+# Due to libtool and automake machinery limitations of not allowing
+# specifying separate CPPFLAGS or CFLAGS when compiling objects for
+# inclusion of these in shared or static libraries, we are forced to
+# build using separate configure runs for shared and static libraries
+# on systems where different CPPFLAGS or CFLAGS are mandatory in order
+# to compile objects for each kind of library. Notice that relying on
+# the '-DPIC' CFLAG that libtool provides is not valid given that the
+# user might for example choose to build static libraries with PIC.
+#
+
+#
+# Make our Makefile.am files use the staticlib CPPFLAG only when strictly
+# targeting a static library and not building its shared counterpart.
+#
+
+AM_CONDITIONAL([USE_CPPFLAG_CARES_STATICLIB],
+  [test "x$xc_lt_build_static_only" = 'xyes'])
+
+#
+# Make staticlib CPPFLAG variable and its definition visible in output
+# files unconditionally, providing an empty definition unless strictly
+# targeting a static library and not building its shared counterpart.
+#
+
+CPPFLAG_CARES_STATICLIB=
+if test "x$xc_lt_build_static_only" = 'xyes'; then
+  CPPFLAG_CARES_STATICLIB='-DCARES_STATICLIB'
+fi
+AC_SUBST([CPPFLAG_CARES_STATICLIB])
 
 dnl **********************************************************************
 dnl platform/compiler/architecture specific checks/flags
 dnl **********************************************************************
 
-case $host in
-  #
-  x86_64*linux*)
-    #
-    dnl find out if icc is being used
-    if test "z$ICC" = "z"; then
-      CURL_DETECT_ICC
-    fi
-    #
-    if test "$ICC" = "yes"; then
-      dnl figure out icc version
-      AC_MSG_CHECKING([icc version])
-      iccver=`$CC -dumpversion`
-      iccnhi=`echo $iccver | cut -d . -f1`
-      iccnlo=`echo $iccver | cut -d . -f2`
-      iccnum=`(expr $iccnhi "*" 100 + $iccnlo) 2>/dev/null`
-      AC_MSG_RESULT($iccver)
-      #
-      if test "$iccnum" -ge "900" && test "$iccnum" -lt "1000"; then
-        dnl icc 9.X specific
-        CFLAGS="$CFLAGS -i-dynamic"
-      fi
-      #
-      if test "$iccnum" -ge "1000"; then
-        dnl icc 10.X or later
-        CFLAGS="$CFLAGS -shared-intel"
-      fi
-      #
-    fi
-    ;;
-  #
-esac
-
-AC_MSG_CHECKING([whether we are using the IBM C compiler])
-CURL_CHECK_DEF([__IBMC__], [], [silent])
-if test "$curl_cv_have_def___IBMC__" = "yes"; then
-  AC_MSG_RESULT([yes])
-  dnl Ensure that compiler optimizations are always thread-safe.
-  CFLAGS="$CFLAGS -qthreaded"
-  dnl Disable type based strict aliasing optimizations, using worst
-  dnl case aliasing assumptions when compiling. Type based aliasing
-  dnl would restrict the lvalues that could be safely used to access
-  dnl a data object.
-  CFLAGS="$CFLAGS -qnoansialias"
-  dnl Force compiler to stop after the compilation phase, without
-  dnl generating an object code file when compilation has errors.
-  CFLAGS="$CFLAGS -qhalt=e"
-else
-  AC_MSG_RESULT([no])
-fi
+CARES_CHECK_COMPILER
+CARES_SET_COMPILER_BASIC_OPTS
+CARES_SET_COMPILER_DEBUG_OPTS
+CARES_SET_COMPILER_OPTIMIZE_OPTS
+CARES_SET_COMPILER_WARNING_OPTS
 
-AC_MSG_CHECKING([whether we are using the Intel C compiler])
-CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
-if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
-  AC_MSG_RESULT([yes])
-  dnl On Linux this compiler uses gcc's header files, so
-  dnl we select ANSI C89 dialect plus GNU extensions.
-  CPPFLAGS="$CPPFLAGS -std=gnu89"
-  if test "$curl_cv_def___INTEL_COMPILER" -gt "600"; then
-    dnl Show errors, warnings, and remarks
-    CPPFLAGS="$CPPFLAGS -Wall"
-    dnl Perform extra compile-time code checking
-    CPPFLAGS="$CPPFLAGS -Wcheck"
+if test "$compiler_id" = "INTEL_UNIX_C"; then
+  #
+  if test "$compiler_num" -ge "1000"; then
+    dnl icc 10.X or later
+    CFLAGS="$CFLAGS -shared-intel"
+  elif test "$compiler_num" -ge "900"; then
+    dnl icc 9.X specific
+    CFLAGS="$CFLAGS -i-dynamic"
   fi
-  dnl Change some warnings into errors
-  dnl #140: too many arguments in function call
-  dnl #147: declaration is incompatible with 'previous one'
-  dnl #165: too few arguments in function call
-  dnl #266: function declared implicitly
-  CPPFLAGS="$CPPFLAGS -we 140,147,165,266"
-  dnl Disable use of ANSI C aliasing rules in optimizations
-  CFLAGS="$CFLAGS -no-ansi-alias"
-else
-  AC_MSG_RESULT([no])
-fi
-
-AC_MSG_CHECKING([whether we are using the DEC/Compaq C compiler])
-CURL_CHECK_DEF([__DECC], [], [silent])
-CURL_CHECK_DEF([__DECC_VER], [], [silent])
-if test "$curl_cv_have_def___DECC" = "yes" &&
-  test "$curl_cv_have_def___DECC_VER" = "yes"; then
-  AC_MSG_RESULT([yes])
-  dnl Select strict ANSI C compiler mode
-  CFLAGS="$CFLAGS -std1"
-  dnl Turn off optimizer ANSI C aliasing rules
-  CFLAGS="$CFLAGS -noansi_alias"
-  dnl Select a higher warning level than default level2
-  CFLAGS="$CFLAGS -msg_enable level3"
-  dnl Generate warnings for missing function prototypes
-  CFLAGS="$CFLAGS -warnprotos"
-  dnl Change some warnings into fatal errors
-  CFLAGS="$CFLAGS -msg_fatal toofewargs,toomanyargs"
-else
-  AC_MSG_RESULT([no])
+  #
 fi
 
-CURL_CHECK_COMPILER_HALT_ON_ERROR
-CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
+CARES_CHECK_COMPILER_HALT_ON_ERROR
+CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
+CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
+CARES_CHECK_COMPILER_SYMBOL_HIDING
 
 dnl **********************************************************************
 dnl Compilation based checks should not be done before this point.
 dnl **********************************************************************
 
 dnl **********************************************************************
-dnl Make sure that our checks for headers windows.h winsock.h winsock2.h 
-dnl and ws2tcpip.h take precedence over any other further checks which 
+dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
+dnl and ws2tcpip.h take precedence over any other further checks which
 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
 dnl this specific header files. And do them before its results are used.
 dnl **********************************************************************
@@ -288,6 +219,7 @@ case X-"$ac_cv_native_windows" in
     CURL_CHECK_HEADER_WINSOCK
     CURL_CHECK_HEADER_WINSOCK2
     CURL_CHECK_HEADER_WS2TCPIP
+    CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
     ;;
   *)
     ac_cv_header_winsock_h="no"
@@ -300,6 +232,8 @@ dnl **********************************************************************
 dnl Checks for libraries.
 dnl **********************************************************************
 
+CARES_CHECK_LIB_XNET
+
 dnl gethostbyname without lib or in the nsl lib?
 AC_CHECK_FUNC(gethostbyname,
               [HAVE_GETHOSTBYNAME="1"
@@ -439,12 +373,19 @@ then
 fi
 
 
-if test "$HAVE_GETHOSTBYNAME" = "1"; then
-  AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
-else
+if test "$HAVE_GETHOSTBYNAME" != "1"; then
   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
 fi
 
+dnl resolv lib for Apple (MacOS and iOS)
+AS_IF([test "x$host_vendor" = "xapple"], [
+  AC_SEARCH_LIBS([res_servicename], [resolv], [
+    AC_DEFINE([CARES_USE_LIBRESOLV], [1], [Use resolver library to configure cares])
+  ], [
+    AC_MSG_ERROR([Unable to find libresolv which is required for iPhone targets])
+  ])
+])
+
 dnl resolve lib?
 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
 
@@ -456,14 +397,64 @@ if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
 fi
 ac_cv_func_strcasecmp="no"
 
-dnl socket lib?
-AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
+CARES_CHECK_LIBS_CONNECT
+
+dnl iOS 10?
+AS_IF([test "x$host_vendor" = "xapple"], [
+  AC_MSG_CHECKING([for iOS minimum version 10 or later])
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <TargetConditionals.h>
+    ]], [[
+#if TARGET_OS_IPHONE == 0 || __IPHONE_OS_VERSION_MIN_REQUIRED < 100000
+#error Not iOS 10 or later
+#endif
+return 0;
+   ]])
+  ],[
+    AC_MSG_RESULT([yes])
+    ac_cv_ios_10="yes"
+  ],[
+    AC_MSG_RESULT([no])
+  ])
+])
+
+dnl macOS 10.12?
+AS_IF([test "x$host_vendor" = "xapple"], [
+  AC_MSG_CHECKING([for macOS minimum version 10.12 or later])
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <TargetConditionals.h>
+    ]], [[
+#ifndef MAC_OS_X_VERSION_10_12
+#  define MAC_OS_X_VERSION_10_12 101200
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
+#error Not macOS 10.12 or later
+#endif
+return 0;
+   ]])
+  ],[
+    AC_MSG_RESULT([yes])
+    ac_cv_macos_10_12="yes"
+  ],[
+    AC_MSG_RESULT([no])
+  ])
+])
 
 dnl **********************************************************************
 dnl In case that function clock_gettime with monotonic timer is available,
 dnl check for additional required libraries.
 dnl **********************************************************************
-CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
+dnl Xcode 8 bug: iOS when targeting less than 10, or macOS when targeting less than 10.12 will
+dnl say clock_gettime exists, it is a weak symbol that only exists in iOS 10 or macOS 10.12 and will
+dnl cause a crash at runtime when running on older versions.  Skip finding CLOCK_MONOTONIC on older
+dnl Apple OS's.
+if test "x$host_vendor" != "xapple" || test "x$ac_cv_ios_10" = "xyes" || test "x$ac_cv_macos_10_12" = "xyes"; then
+  CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
+fi
 
 AC_MSG_CHECKING([whether to use libgcc])
 AC_ARG_ENABLE(libgcc,
@@ -480,58 +471,10 @@ AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
 )
 
 
-dnl Default is to try the thread-safe versions of a few functions
-OPT_THREAD=on
-
-dnl detect AIX 4.3 or later
-AC_MSG_CHECKING([AIX 4.3 or later])
-AC_PREPROC_IFELSE([
-#if defined(_AIX) && defined(_AIX43)
-printf("just fine");
-#else
-#error "this is not AIX 4.3 or later"
-#endif
-],
- [ AC_MSG_RESULT([yes])
-   RECENTAIX=yes
-   OPT_THREAD=off ],
- [ AC_MSG_RESULT([no]) ]
-)
-
-AC_ARG_ENABLE(thread,dnl
-AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
-AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
-[ case "$enableval" in
-  no)
-    OPT_THREAD=off
-    AC_MSG_WARN(c-ares will not get built using thread-safe functions)
-    ;;
-  *)
-    ;;
-  esac
-]
-)
-
-if test X"$OPT_THREAD" = Xoff
-then
-  AC_DEFINE(DISABLED_THREADSAFE, 1,
-    [Set to explicitly specify we don't want to use thread-safe functions])
-fi
-
-dnl for recent AIX versions, we skip all the thread-safe checks above since
-dnl they claim a thread-safe libc using the standard API. But there are
-dnl some functions still not thread-safe. Check for these!
-
 dnl Let's hope this split URL remains working:
 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
 dnl genprogc/thread_quick_ref.htm
 
-if test "x$RECENTAIX" = "xyes"; then
-
-  AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
-
-fi
-
 
 dnl **********************************************************************
 dnl Back to "normal" configuring
@@ -541,6 +484,7 @@ dnl Checks for header files.
 AC_HEADER_STDC
 
 CURL_CHECK_HEADER_MALLOC
+CURL_CHECK_HEADER_MEMORY
 
 dnl check for a few basic system headers we need
 AC_CHECK_HEADERS(
@@ -551,14 +495,17 @@ AC_CHECK_HEADERS(
        sys/ioctl.h \
        sys/param.h \
        sys/uio.h \
+       assert.h \
        netdb.h \
        netinet/in.h \
        netinet/tcp.h \
        net/if.h \
        errno.h \
+       socket.h \
        strings.h \
        stdbool.h \
        time.h \
+       limits.h \
        arpa/nameser.h \
        arpa/nameser_compat.h \
        arpa/inet.h,
@@ -597,29 +544,35 @@ AC_TYPE_SIZE_T
 AC_HEADER_TIME
 CURL_CHECK_STRUCT_TIMEVAL
 
-AC_CHECK_SIZEOF(size_t)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(time_t)
-
 AC_CHECK_TYPE(long long,
    [AC_DEFINE(HAVE_LONGLONG, 1,
      [Define to 1 if the compiler supports the 'long long' data type.])]
-   longlong="yes"  
+   longlong="yes"
 )
 
 if test "xyes" = "x$longlong"; then
   AC_MSG_CHECKING([if numberLL works])
-  AC_COMPILE_IFELSE([long long val = 1000LL;],
-   [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
-   AC_MSG_RESULT(yes),
-   AC_MSG_RESULT(no)
-  )
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([[
+    ]],[[
+      long long val = 1000LL;
+    ]])
+  ],[
+    AC_MSG_RESULT([yes])
+    AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
+  ],[
+    AC_MSG_RESULT([no])
+  ])
 fi
 
 
 # check for ssize_t
-AC_CHECK_TYPE(ssize_t, ,
-   AC_DEFINE(ssize_t, int, [the signed version of size_t]))
+AC_CHECK_TYPE(ssize_t, [ CARES_TYPEOF_ARES_SSIZE_T=ssize_t ],
+  [ CARES_TYPEOF_ARES_SSIZE_T=int ])
+
+AC_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SSIZE_T], ${CARES_TYPEOF_ARES_SSIZE_T},
+  [the signed version of size_t])
+
 
 # check for bool type
 AC_CHECK_TYPE([bool],[
@@ -634,8 +587,7 @@ AC_CHECK_TYPE([bool],[
 #endif
 ])
 
-# Check for socklen_t or equivalent
-CURL_CHECK_TYPE_SOCKLEN_T
+CARES_CONFIGURE_ARES_SOCKLEN_T
 
 TYPE_IN_ADDR_T
 
@@ -650,8 +602,25 @@ CURL_CHECK_FUNC_RECVFROM
 CURL_CHECK_FUNC_SEND
 CURL_CHECK_MSG_NOSIGNAL
 
+CARES_CHECK_FUNC_CLOSESOCKET
+CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
+CARES_CHECK_FUNC_CONNECT
+CARES_CHECK_FUNC_FCNTL
+CARES_CHECK_FUNC_FREEADDRINFO
+CARES_CHECK_FUNC_GETADDRINFO
+CARES_CHECK_FUNC_GETENV
+CARES_CHECK_FUNC_GETHOSTBYADDR
+CARES_CHECK_FUNC_GETHOSTBYNAME
 CARES_CHECK_FUNC_GETHOSTNAME
 CARES_CHECK_FUNC_GETSERVBYPORT_R
+CARES_CHECK_FUNC_INET_NET_PTON
+CARES_CHECK_FUNC_INET_NTOP
+CARES_CHECK_FUNC_INET_PTON
+CARES_CHECK_FUNC_IOCTL
+CARES_CHECK_FUNC_IOCTLSOCKET
+CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
+CARES_CHECK_FUNC_SETSOCKOPT
+CARES_CHECK_FUNC_SOCKET
 CARES_CHECK_FUNC_STRCASECMP
 CARES_CHECK_FUNC_STRCMPI
 CARES_CHECK_FUNC_STRDUP
@@ -682,7 +651,7 @@ CARES_CHECK_CONSTANT(
 #include <sys/socket.h>
 #endif
 #endif
-  ], [PF_INET6], 
+  ], [PF_INET6],
      AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
 )
 
@@ -706,7 +675,7 @@ CARES_CHECK_CONSTANT(
 #include <sys/socket.h>
 #endif
 #endif
-  ], [AF_INET6], 
+  ], [AF_INET6],
      AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
 )
 
@@ -734,7 +703,7 @@ CARES_CHECK_STRUCT(
 #include <netinet/in.h>
 #endif
 #endif
-  ], [in6_addr], 
+  ], [in6_addr],
      AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
 )
 
@@ -761,7 +730,7 @@ CARES_CHECK_STRUCT(
 #include <netinet/in.h>
 #endif
 #endif
-  ], [sockaddr_in6], 
+  ], [sockaddr_in6],
      AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
        [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
 )
@@ -843,171 +812,24 @@ AC_CHECK_FUNCS([bitncmp \
   ],[
     AC_MSG_RESULT([yes])
     eval "ac_cv_func_$func=yes"
-    AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$func])], [1],
+    AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
       [Define to 1 if you have the $func function.])
   ],[
     AC_MSG_RESULT([but still no])
   ])
 ])
 
-
-dnl check for inet_pton
-AC_CHECK_FUNCS(inet_pton)
-dnl Some systems have it, but not IPv6
-if test "$ac_cv_func_inet_pton" = "yes" ; then
-AC_MSG_CHECKING(if inet_pton supports IPv6)
-AC_TRY_RUN(
-  [
-#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
-int main()
-  {
-    struct in6_addr addr6;
-    if (inet_pton(AF_INET6, "::1", &addr6) < 1)
-      exit(1);
-    else
-      exit(0);
-  }
-  ], [
-       AC_MSG_RESULT(yes)
-       AC_DEFINE_UNQUOTED(HAVE_INET_PTON_IPV6,1,[Define to 1 if inet_pton supports IPv6.])
-     ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
-fi
-dnl Check for inet_net_pton
-AC_CHECK_FUNCS(inet_net_pton)
-dnl Again, some systems have it, but not IPv6
-if test "$ac_cv_func_inet_net_pton" = "yes" ; then
-AC_MSG_CHECKING(if inet_net_pton supports IPv6)
-AC_TRY_RUN(
-  [
-#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
-int main()
-  {
-    struct in6_addr addr6;
-    if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
-      exit(1);
-    else
-      exit(0);
-  }
-  ], [
-       AC_MSG_RESULT(yes)
-       AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
-     ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
-fi
-
-
-dnl Check for inet_ntop
-AC_CHECK_FUNCS(inet_ntop)
-dnl Again, some systems have it, but not IPv6
-if test "$ac_cv_func_inet_ntop" = "yes" ; then
-AC_MSG_CHECKING(if inet_ntop supports IPv6)
-AC_TRY_RUN(
-  [
-#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
-#include <errno.h>
-int main()
-  {
-    struct in6_addr addr6;
-    char buf[128];
-    if (inet_ntop(AF_INET6, &addr6, buf, 128) == 0 && errno == EAFNOSUPPORT)
-      exit(1);
-    else
-      exit(0);
-  }
-  ], [
-       AC_MSG_RESULT(yes)
-       AC_DEFINE_UNQUOTED(HAVE_INET_NTOP_IPV6,1,
-          [Define to 1 if inet_ntop supports IPv6.])
-     ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
-fi
-
-AC_CHECK_SIZEOF(struct in6_addr, ,
-[
-#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>
-#ifdef HAVE_WS2TCPIP_H
-#include <ws2tcpip.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
-#endif
-]
-)
-
-AC_CHECK_SIZEOF(struct in_addr, ,
-[
-#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>
-#ifdef HAVE_WS2TCPIP_H
-#include <ws2tcpip.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
-#endif
-]
-)
-
+dnl Android. Some variants like arm64 may no longer have __system_property_get
+dnl in libc, but they are defined in the headers.  Perform a link check.
+AC_CHECK_FUNC([__system_property_get], [
+    AC_DEFINE([HAVE___SYSTEM_PROPERTY_GET], [1], [Define if __system_property_get exists.])
+])
 
 dnl Check if the getnameinfo function is available
 dnl and get the types of five of its arguments.
 CURL_CHECK_FUNC_GETNAMEINFO
 
 
-CURL_CHECK_NONBLOCKING_SOCKET
-
 AC_C_BIGENDIAN(
     [AC_DEFINE(ARES_BIG_ENDIAN, 1,
       [define this if ares is built for a big endian system])],
@@ -1029,7 +851,7 @@ AC_HELP_STRING([--with-random=FILE],
         else
           AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
         fi
-        
+
     ]
 )
 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
@@ -1038,8 +860,70 @@ if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
         [a suitable file/device to read random data from])
 fi
 
+CARES_CHECK_OPTION_NONBLOCKING
+CARES_CHECK_NONBLOCKING_SOCKET
+
+CARES_CONFIGURE_SYMBOL_HIDING
+
 CARES_PRIVATE_LIBS="$LIBS"
 AC_SUBST(CARES_PRIVATE_LIBS)
 
-AC_CONFIG_FILES([Makefile libcares.pc])
+CARES_CFLAG_EXTRAS=""
+if test X"$want_werror" = Xyes; then
+  CARES_CFLAG_EXTRAS="-Werror"
+fi
+AC_SUBST(CARES_CFLAG_EXTRAS)
+
+dnl squeeze whitespace out of some variables
+
+squeeze CFLAGS
+squeeze CPPFLAGS
+squeeze DEFS
+squeeze LDFLAGS
+squeeze LIBS
+
+squeeze CARES_PRIVATE_LIBS
+
+XC_CHECK_BUILD_FLAGS
+
+AC_MSG_CHECKING([whether to build tests])
+AC_ARG_ENABLE(tests,
+       AC_HELP_STRING([--enable-tests], [build test suite]),
+       [ build_tests="$enableval" ],
+       [ if test "x$HAVE_CXX11" = "x1" && test "x$cross_compiling" = "xno" ; then
+           build_tests="yes"
+         else
+           build_tests="no"
+         fi
+       ]
+)
+
+if test "x$build_tests" = "xyes" ; then
+       if test "x$HAVE_CXX11" = "0" ; then
+               AC_MSG_ERROR([*** Building tests requires a CXX11 compiler])
+       fi
+       if test "x$cross_compiling" = "xyes" ; then
+               AC_MSG_ERROR([*** Tests not supported when cross compiling])
+       fi
+fi
+AC_MSG_RESULT([$build_tests])
+
+
+BUILD_SUBDIRS="include src docs"
+if test "x$build_tests" = "xyes" ; then
+  AC_CONFIG_SUBDIRS([test])
+  BUILD_SUBDIRS="${BUILD_SUBDIRS} test"
+fi
+
+AC_SUBST(BUILD_SUBDIRS)
+
+AC_CONFIG_FILES([Makefile           \
+                 include/Makefile   \
+                 src/Makefile       \
+                 src/lib/Makefile   \
+                 src/tools/Makefile \
+                 docs/Makefile      \
+                 libcares.pc ])
+
 AC_OUTPUT
+XC_AMEND_DISTCLEAN(['.'])