Change the upstream source URL
[platform/upstream/c-ares.git] / configure.ac
index b89ce35..703bde0 100644 (file)
@@ -1,15 +1,44 @@
 AC_PREREQ(2.57)
 
-dnl Version not hardcoded here. Fetched later from ares_version.h
-AC_INIT([c-ares], [1.12.0],
+AC_INIT([c-ares], [1.17.1],
   [c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares])
 
+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([ares_ipv6.h])
-AC_CONFIG_HEADERS([ares_config.h ares_build.h])
+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])])
@@ -18,7 +47,6 @@ CARES_CHECK_OPTION_DEBUG
 CARES_CHECK_OPTION_OPTIMIZE
 CARES_CHECK_OPTION_WARNINGS
 CARES_CHECK_OPTION_WERROR
-CARES_CHECK_OPTION_CURLDEBUG
 CARES_CHECK_OPTION_SYMBOL_HIDING
 CARES_CHECK_OPTION_EXPOSE_STATICS
 
@@ -59,19 +87,18 @@ AC_SUBST([EGREP])
 
 dnl AR is mandatory for configure process and libtool.
 dnl This is target dependent, 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.])
+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])
 
 AX_CODE_COVERAGE
 
-dnl Remove non-configure distributed ares_build.h
-if test -f ${srcdir}/ares_build.h; then
-  rm -f ${srcdir}/ares_build.h
-fi
 
 dnl
 dnl Detect the canonical host and target build environment
@@ -104,6 +131,7 @@ esac
 
 XC_LIBTOOL
 
+
 #
 # Automake conditionals based on libtool related checks
 #
@@ -173,16 +201,13 @@ CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
 CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
 CARES_CHECK_COMPILER_SYMBOL_HIDING
 
-CARES_CHECK_CURLDEBUG
-AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
-
 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 **********************************************************************
@@ -194,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"
@@ -351,27 +377,12 @@ if test "$HAVE_GETHOSTBYNAME" != "1"; then
   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
 fi
 
-dnl resolv lib for iPhone
+dnl resolv lib for Apple (MacOS and iOS)
 AS_IF([test "x$host_vendor" = "xapple"], [
-  AC_MSG_CHECKING([for iPhone target])
-  AC_COMPILE_IFELSE([
-    AC_LANG_PROGRAM([[
-#include "TargetConditionals.h"
-    ]], [[
-#if TARGET_OS_IPHONE == 0
-#error Not an iPhone target
-#endif
-return 0;
-    ]])
-  ],[
-    AC_MSG_RESULT([yes])
-    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])
-    ])
-  ],[
-    AC_MSG_RESULT([no])
+  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])
   ])
 ])
 
@@ -388,11 +399,62 @@ ac_cv_func_strcasecmp="no"
 
 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,
@@ -485,7 +547,7 @@ CURL_CHECK_STRUCT_TIMEVAL
 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
@@ -505,8 +567,12 @@ 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],[
@@ -585,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.])
 )
 
@@ -609,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.])
 )
 
@@ -637,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.])
 )
 
@@ -664,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
 )
@@ -753,6 +819,11 @@ AC_CHECK_FUNCS([bitncmp \
   ])
 ])
 
+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.
@@ -780,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
@@ -837,10 +908,22 @@ if test "x$build_tests" = "xyes" ; then
 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_CONFIG_FILES([Makefile libcares.pc])
+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(['.'])