• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1AC_PREREQ(2.57)
2
3AC_INIT([c-ares], [1.16.1],
4  [c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares])
5
6XC_OVR_ZZ50
7XC_OVR_ZZ60
8CARES_OVERRIDE_AUTOCONF
9
10AC_CONFIG_SRCDIR([ares_ipv6.h])
11AC_CONFIG_HEADERS([ares_config.h ares_build.h])
12AC_CONFIG_MACRO_DIR([m4])
13AM_MAINTAINER_MODE
14m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
15
16CARES_CHECK_OPTION_DEBUG
17CARES_CHECK_OPTION_OPTIMIZE
18CARES_CHECK_OPTION_WARNINGS
19CARES_CHECK_OPTION_WERROR
20CARES_CHECK_OPTION_CURLDEBUG
21CARES_CHECK_OPTION_SYMBOL_HIDING
22CARES_CHECK_OPTION_EXPOSE_STATICS
23
24XC_CHECK_PATH_SEPARATOR
25
26dnl SED is mandatory for configure process and libtool.
27dnl Set it now, allowing it to be changed later.
28AC_PATH_PROG([SED], [sed], [not_found],
29  [$PATH:/usr/bin:/usr/local/bin])
30if test -z "$SED" || test "$SED" = "not_found"; then
31  AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
32fi
33AC_SUBST([SED])
34
35dnl GREP is mandatory for configure process and libtool.
36dnl Set it now, allowing it to be changed later.
37AC_PATH_PROG([GREP], [grep], [not_found],
38  [$PATH:/usr/bin:/usr/local/bin])
39if test -z "$GREP" || test "$GREP" = "not_found"; then
40  AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
41fi
42AC_SUBST([GREP])
43
44dnl EGREP is mandatory for configure process and libtool.
45dnl Set it now, allowing it to be changed later.
46if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
47  AC_MSG_CHECKING([for egrep])
48  EGREP="$GREP -E"
49  AC_MSG_RESULT([$EGREP])
50else
51  AC_PATH_PROG([EGREP], [egrep], [not_found],
52    [$PATH:/usr/bin:/usr/local/bin])
53fi
54if test -z "$EGREP" || test "$EGREP" = "not_found"; then
55  AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
56fi
57AC_SUBST([EGREP])
58
59dnl AR is mandatory for configure process and libtool.
60dnl This is target dependent, so check it as a tool.
61if test -z "$AR"; then
62  dnl allow it to be overridden
63  AC_PATH_TOOL([AR], [ar], [not_found],
64    [$PATH:/usr/bin:/usr/local/bin])
65  if test -z "$AR" || test "$AR" = "not_found"; then
66    AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
67  fi
68fi
69AC_SUBST([AR])
70
71AX_CODE_COVERAGE
72
73dnl Remove non-configure distributed ares_build.h
74if test -f ${srcdir}/ares_build.h; then
75  rm -f ${srcdir}/ares_build.h
76fi
77
78dnl
79dnl Detect the canonical host and target build environment
80dnl
81
82AC_CANONICAL_HOST
83dnl Get system canonical name
84AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
85
86XC_CHECK_PROG_CC
87AX_CXX_COMPILE_STDCXX_11([noext],[optional])
88
89XC_AUTOMAKE
90
91dnl This defines _ALL_SOURCE for AIX
92CARES_CHECK_AIX_ALL_SOURCE
93
94dnl Our configure and build reentrant settings
95CARES_CONFIGURE_THREAD_SAFE
96CARES_CONFIGURE_REENTRANT
97
98dnl check for how to do large files
99AC_SYS_LARGEFILE
100
101case $host_os in
102  solaris*)
103    AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
104    ;;
105esac
106
107XC_LIBTOOL
108
109#
110# Automake conditionals based on libtool related checks
111#
112
113AM_CONDITIONAL([CARES_LT_SHLIB_USE_VERSION_INFO],
114  [test "x$xc_lt_shlib_use_version_info" = 'xyes'])
115AM_CONDITIONAL([CARES_LT_SHLIB_USE_NO_UNDEFINED],
116  [test "x$xc_lt_shlib_use_no_undefined" = 'xyes'])
117AM_CONDITIONAL([CARES_LT_SHLIB_USE_MIMPURE_TEXT],
118  [test "x$xc_lt_shlib_use_mimpure_text" = 'xyes'])
119
120#
121# Due to libtool and automake machinery limitations of not allowing
122# specifying separate CPPFLAGS or CFLAGS when compiling objects for
123# inclusion of these in shared or static libraries, we are forced to
124# build using separate configure runs for shared and static libraries
125# on systems where different CPPFLAGS or CFLAGS are mandatory in order
126# to compile objects for each kind of library. Notice that relying on
127# the '-DPIC' CFLAG that libtool provides is not valid given that the
128# user might for example choose to build static libraries with PIC.
129#
130
131#
132# Make our Makefile.am files use the staticlib CPPFLAG only when strictly
133# targeting a static library and not building its shared counterpart.
134#
135
136AM_CONDITIONAL([USE_CPPFLAG_CARES_STATICLIB],
137  [test "x$xc_lt_build_static_only" = 'xyes'])
138
139#
140# Make staticlib CPPFLAG variable and its definition visible in output
141# files unconditionally, providing an empty definition unless strictly
142# targeting a static library and not building its shared counterpart.
143#
144
145CPPFLAG_CARES_STATICLIB=
146if test "x$xc_lt_build_static_only" = 'xyes'; then
147  CPPFLAG_CARES_STATICLIB='-DCARES_STATICLIB'
148fi
149AC_SUBST([CPPFLAG_CARES_STATICLIB])
150
151dnl **********************************************************************
152dnl platform/compiler/architecture specific checks/flags
153dnl **********************************************************************
154
155CARES_CHECK_COMPILER
156CARES_SET_COMPILER_BASIC_OPTS
157CARES_SET_COMPILER_DEBUG_OPTS
158CARES_SET_COMPILER_OPTIMIZE_OPTS
159CARES_SET_COMPILER_WARNING_OPTS
160
161if test "$compiler_id" = "INTEL_UNIX_C"; then
162  #
163  if test "$compiler_num" -ge "1000"; then
164    dnl icc 10.X or later
165    CFLAGS="$CFLAGS -shared-intel"
166  elif test "$compiler_num" -ge "900"; then
167    dnl icc 9.X specific
168    CFLAGS="$CFLAGS -i-dynamic"
169  fi
170  #
171fi
172
173CARES_CHECK_COMPILER_HALT_ON_ERROR
174CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
175CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
176CARES_CHECK_COMPILER_SYMBOL_HIDING
177
178CARES_CHECK_CURLDEBUG
179AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
180
181dnl **********************************************************************
182dnl Compilation based checks should not be done before this point.
183dnl **********************************************************************
184
185dnl **********************************************************************
186dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
187dnl and ws2tcpip.h take precedence over any other further checks which
188dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
189dnl this specific header files. And do them before its results are used.
190dnl **********************************************************************
191
192CURL_CHECK_HEADER_WINDOWS
193CURL_CHECK_NATIVE_WINDOWS
194case X-"$ac_cv_native_windows" in
195  X-yes)
196    CURL_CHECK_HEADER_WINSOCK
197    CURL_CHECK_HEADER_WINSOCK2
198    CURL_CHECK_HEADER_WS2TCPIP
199    CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
200    ;;
201  *)
202    ac_cv_header_winsock_h="no"
203    ac_cv_header_winsock2_h="no"
204    ac_cv_header_ws2tcpip_h="no"
205    ;;
206esac
207
208dnl **********************************************************************
209dnl Checks for libraries.
210dnl **********************************************************************
211
212CARES_CHECK_LIB_XNET
213
214dnl gethostbyname without lib or in the nsl lib?
215AC_CHECK_FUNC(gethostbyname,
216              [HAVE_GETHOSTBYNAME="1"
217              ],
218              [ AC_CHECK_LIB(nsl, gethostbyname,
219                             [HAVE_GETHOSTBYNAME="1"
220                             LIBS="$LIBS -lnsl"
221                             ])
222              ])
223
224if test "$HAVE_GETHOSTBYNAME" != "1"
225then
226  dnl gethostbyname in the socket lib?
227  AC_CHECK_LIB(socket, gethostbyname,
228               [HAVE_GETHOSTBYNAME="1"
229               LIBS="$LIBS -lsocket"
230               ])
231fi
232
233dnl At least one system has been identified to require BOTH nsl and socket
234dnl libs at the same time to link properly.
235if test "$HAVE_GETHOSTBYNAME" != "1"
236then
237  AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
238  my_ac_save_LIBS=$LIBS
239  LIBS="-lnsl -lsocket $LIBS"
240  AC_LINK_IFELSE([
241    AC_LANG_PROGRAM([[
242    ]],[[
243      gethostbyname();
244    ]])
245  ],[
246    AC_MSG_RESULT([yes])
247    HAVE_GETHOSTBYNAME="1"
248  ],[
249    AC_MSG_RESULT([no])
250    LIBS=$my_ac_save_LIBS
251  ])
252fi
253
254if test "$HAVE_GETHOSTBYNAME" != "1"
255then
256  dnl This is for winsock systems
257  if test "$ac_cv_header_windows_h" = "yes"; then
258    if test "$ac_cv_header_winsock_h" = "yes"; then
259      case $host in
260        *-*-mingw32ce*)
261          winsock_LIB="-lwinsock"
262          ;;
263        *)
264          winsock_LIB="-lwsock32"
265          ;;
266      esac
267    fi
268    if test "$ac_cv_header_winsock2_h" = "yes"; then
269      winsock_LIB="-lws2_32"
270    fi
271    if test ! -z "$winsock_LIB"; then
272      my_ac_save_LIBS=$LIBS
273      LIBS="$winsock_LIB $LIBS"
274      AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
275      AC_LINK_IFELSE([
276        AC_LANG_PROGRAM([[
277#ifdef HAVE_WINDOWS_H
278#ifndef WIN32_LEAN_AND_MEAN
279#define WIN32_LEAN_AND_MEAN
280#endif
281#include <windows.h>
282#ifdef HAVE_WINSOCK2_H
283#include <winsock2.h>
284#else
285#ifdef HAVE_WINSOCK_H
286#include <winsock.h>
287#endif
288#endif
289#endif
290        ]],[[
291          gethostbyname("www.dummysite.com");
292        ]])
293      ],[
294        AC_MSG_RESULT([yes])
295        HAVE_GETHOSTBYNAME="1"
296      ],[
297        AC_MSG_RESULT([no])
298        winsock_LIB=""
299        LIBS=$my_ac_save_LIBS
300      ])
301    fi
302  fi
303fi
304
305if test "$HAVE_GETHOSTBYNAME" != "1"
306then
307  dnl This is for Minix 3.1
308  AC_MSG_CHECKING([for gethostbyname for Minix 3])
309  AC_LINK_IFELSE([
310    AC_LANG_PROGRAM([[
311/* Older Minix versions may need <net/gen/netdb.h> here instead */
312#include <netdb.h>
313    ]],[[
314      gethostbyname("www.dummysite.com");
315    ]])
316  ],[
317    AC_MSG_RESULT([yes])
318    HAVE_GETHOSTBYNAME="1"
319  ],[
320    AC_MSG_RESULT([no])
321  ])
322fi
323
324if test "$HAVE_GETHOSTBYNAME" != "1"
325then
326  dnl This is for eCos with a stubbed DNS implementation
327  AC_MSG_CHECKING([for gethostbyname for eCos])
328  AC_LINK_IFELSE([
329    AC_LANG_PROGRAM([[
330#include <stdio.h>
331#include <netdb.h>
332    ]],[[
333      gethostbyname("www.dummysite.com");
334    ]])
335  ],[
336    AC_MSG_RESULT([yes])
337    HAVE_GETHOSTBYNAME="1"
338  ],[
339    AC_MSG_RESULT([no])
340  ])
341fi
342
343if test "$HAVE_GETHOSTBYNAME" != "1"
344then
345  dnl gethostbyname in the net lib - for BeOS
346  AC_CHECK_LIB(net, gethostbyname,
347               [HAVE_GETHOSTBYNAME="1"
348               LIBS="$LIBS -lnet"
349               ])
350fi
351
352
353if test "$HAVE_GETHOSTBYNAME" != "1"; then
354  AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
355fi
356
357dnl resolv lib for Apple (MacOS and iOS)
358AS_IF([test "x$host_vendor" = "xapple"], [
359  AC_SEARCH_LIBS([res_servicename], [resolv], [
360    AC_DEFINE([CARES_USE_LIBRESOLV], [1], [Use resolver library to configure cares])
361  ], [
362    AC_MSG_ERROR([Unable to find libresolv which is required for iPhone targets])
363  ])
364])
365
366dnl resolve lib?
367AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
368
369if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
370  AC_CHECK_LIB(resolve, strcasecmp,
371              [LIBS="-lresolve $LIBS"],
372               ,
373               -lnsl)
374fi
375ac_cv_func_strcasecmp="no"
376
377CARES_CHECK_LIBS_CONNECT
378
379dnl iOS 10?
380AS_IF([test "x$host_vendor" = "xapple"], [
381  AC_MSG_CHECKING([for iOS minimum version 10 or later])
382  AC_COMPILE_IFELSE([
383    AC_LANG_PROGRAM([[
384#include <stdio.h>
385#include <TargetConditionals.h>
386    ]], [[
387#if TARGET_OS_IPHONE == 0 || __IPHONE_OS_VERSION_MIN_REQUIRED < 100000
388#error Not iOS 10 or later
389#endif
390return 0;
391   ]])
392  ],[
393    AC_MSG_RESULT([yes])
394    ac_cv_ios_10="yes"
395  ],[
396    AC_MSG_RESULT([no])
397  ])
398])
399
400dnl macOS 10.12?
401AS_IF([test "x$host_vendor" = "xapple"], [
402  AC_MSG_CHECKING([for macOS minimum version 10.12 or later])
403  AC_COMPILE_IFELSE([
404    AC_LANG_PROGRAM([[
405#include <stdio.h>
406#include <TargetConditionals.h>
407    ]], [[
408#ifndef MAC_OS_X_VERSION_10_12
409#  define MAC_OS_X_VERSION_10_12 101200
410#endif
411#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
412#error Not macOS 10.12 or later
413#endif
414return 0;
415   ]])
416  ],[
417    AC_MSG_RESULT([yes])
418    ac_cv_macos_10_12="yes"
419  ],[
420    AC_MSG_RESULT([no])
421  ])
422])
423
424dnl **********************************************************************
425dnl In case that function clock_gettime with monotonic timer is available,
426dnl check for additional required libraries.
427dnl **********************************************************************
428dnl Xcode 8 bug: iOS when targeting less than 10, or macOS when targeting less than 10.12 will
429dnl say clock_gettime exists, it is a weak symbol that only exists in iOS 10 or macOS 10.12 and will
430dnl cause a crash at runtime when running on older versions.  Skip finding CLOCK_MONOTONIC on older
431dnl Apple OS's.
432if test "x$host_vendor" != "xapple" || test "x$ac_cv_ios_10" = "xyes" || test "x$ac_cv_macos_10_12" = "xyes"; then
433  CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
434fi
435
436AC_MSG_CHECKING([whether to use libgcc])
437AC_ARG_ENABLE(libgcc,
438AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
439[ case "$enableval" in
440  yes)
441        LIBS="$LIBS -lgcc"
442       AC_MSG_RESULT(yes)
443       ;;
444  *)   AC_MSG_RESULT(no)
445       ;;
446  esac ],
447       AC_MSG_RESULT(no)
448)
449
450
451dnl Let's hope this split URL remains working:
452dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
453dnl genprogc/thread_quick_ref.htm
454
455
456dnl **********************************************************************
457dnl Back to "normal" configuring
458dnl **********************************************************************
459
460dnl Checks for header files.
461AC_HEADER_STDC
462
463CURL_CHECK_HEADER_MALLOC
464CURL_CHECK_HEADER_MEMORY
465
466dnl check for a few basic system headers we need
467AC_CHECK_HEADERS(
468       sys/types.h \
469       sys/time.h \
470       sys/select.h \
471       sys/socket.h \
472       sys/ioctl.h \
473       sys/param.h \
474       sys/uio.h \
475       assert.h \
476       netdb.h \
477       netinet/in.h \
478       netinet/tcp.h \
479       net/if.h \
480       errno.h \
481       socket.h \
482       strings.h \
483       stdbool.h \
484       time.h \
485       limits.h \
486       arpa/nameser.h \
487       arpa/nameser_compat.h \
488       arpa/inet.h,
489dnl to do if not found
490[],
491dnl to do if found
492[],
493dnl default includes
494[
495#ifdef HAVE_SYS_TYPES_H
496#include <sys/types.h>
497#endif
498#ifdef HAVE_SYS_TIME_H
499#include <sys/time.h>
500#endif
501dnl We do this default-include simply to make sure that the nameser_compat.h
502dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
503dnl (and others?) is not designed to allow this.
504#ifdef HAVE_ARPA_NAMESER_H
505#include <arpa/nameser.h>
506#endif
507
508dnl *Sigh* these are needed in order for net/if.h to get properly detected.
509#ifdef HAVE_SYS_SOCKET_H
510#include <sys/socket.h>
511#endif
512#ifdef HAVE_NETINET_IN_H
513#include <netinet/in.h>
514#endif
515]
516)
517
518dnl Checks for typedefs, structures, and compiler characteristics.
519AC_C_CONST
520AC_TYPE_SIZE_T
521AC_HEADER_TIME
522CURL_CHECK_STRUCT_TIMEVAL
523
524AC_CHECK_TYPE(long long,
525   [AC_DEFINE(HAVE_LONGLONG, 1,
526     [Define to 1 if the compiler supports the 'long long' data type.])]
527   longlong="yes"
528)
529
530if test "xyes" = "x$longlong"; then
531  AC_MSG_CHECKING([if numberLL works])
532  AC_COMPILE_IFELSE([
533    AC_LANG_PROGRAM([[
534    ]],[[
535      long long val = 1000LL;
536    ]])
537  ],[
538    AC_MSG_RESULT([yes])
539    AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
540  ],[
541    AC_MSG_RESULT([no])
542  ])
543fi
544
545
546# check for ssize_t
547AC_CHECK_TYPE(ssize_t, [ CARES_TYPEOF_ARES_SSIZE_T=ssize_t ],
548  [ CARES_TYPEOF_ARES_SSIZE_T=int ])
549
550AC_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SSIZE_T], ${CARES_TYPEOF_ARES_SSIZE_T},
551  [the signed version of size_t])
552
553
554# check for bool type
555AC_CHECK_TYPE([bool],[
556  AC_DEFINE(HAVE_BOOL_T, 1,
557    [Define to 1 if bool is an available type.])
558], ,[
559#ifdef HAVE_SYS_TYPES_H
560#include <sys/types.h>
561#endif
562#ifdef HAVE_STDBOOL_H
563#include <stdbool.h>
564#endif
565])
566
567CARES_CONFIGURE_ARES_SOCKLEN_T
568
569TYPE_IN_ADDR_T
570
571TYPE_SOCKADDR_STORAGE
572
573TYPE_SIG_ATOMIC_T
574
575AC_TYPE_SIGNAL
576
577CURL_CHECK_FUNC_RECV
578CURL_CHECK_FUNC_RECVFROM
579CURL_CHECK_FUNC_SEND
580CURL_CHECK_MSG_NOSIGNAL
581
582CARES_CHECK_FUNC_CLOSESOCKET
583CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
584CARES_CHECK_FUNC_CONNECT
585CARES_CHECK_FUNC_FCNTL
586CARES_CHECK_FUNC_FREEADDRINFO
587CARES_CHECK_FUNC_GETADDRINFO
588CARES_CHECK_FUNC_GETENV
589CARES_CHECK_FUNC_GETHOSTBYADDR
590CARES_CHECK_FUNC_GETHOSTBYNAME
591CARES_CHECK_FUNC_GETHOSTNAME
592CARES_CHECK_FUNC_GETSERVBYPORT_R
593CARES_CHECK_FUNC_INET_NET_PTON
594CARES_CHECK_FUNC_INET_NTOP
595CARES_CHECK_FUNC_INET_PTON
596CARES_CHECK_FUNC_IOCTL
597CARES_CHECK_FUNC_IOCTLSOCKET
598CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
599CARES_CHECK_FUNC_SETSOCKOPT
600CARES_CHECK_FUNC_SOCKET
601CARES_CHECK_FUNC_STRCASECMP
602CARES_CHECK_FUNC_STRCMPI
603CARES_CHECK_FUNC_STRDUP
604CARES_CHECK_FUNC_STRICMP
605CARES_CHECK_FUNC_STRNCASECMP
606CARES_CHECK_FUNC_STRNCMPI
607CARES_CHECK_FUNC_STRNICMP
608CARES_CHECK_FUNC_WRITEV
609
610
611dnl check for AF_INET6
612CARES_CHECK_CONSTANT(
613  [
614#undef inline
615#ifdef HAVE_WINDOWS_H
616#ifndef WIN32_LEAN_AND_MEAN
617#define WIN32_LEAN_AND_MEAN
618#endif
619#include <windows.h>
620#ifdef HAVE_WINSOCK2_H
621#include <winsock2.h>
622#endif
623#else
624#ifdef HAVE_SYS_TYPES_H
625#include <sys/types.h>
626#endif
627#ifdef HAVE_SYS_SOCKET_H
628#include <sys/socket.h>
629#endif
630#endif
631  ], [PF_INET6],
632     AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
633)
634
635dnl check for PF_INET6
636CARES_CHECK_CONSTANT(
637  [
638#undef inline
639#ifdef HAVE_WINDOWS_H
640#ifndef WIN32_LEAN_AND_MEAN
641#define WIN32_LEAN_AND_MEAN
642#endif
643#include <windows.h>
644#ifdef HAVE_WINSOCK2_H
645#include <winsock2.h>
646#endif
647#else
648#ifdef HAVE_SYS_TYPES_H
649#include <sys/types.h>
650#endif
651#ifdef HAVE_SYS_SOCKET_H
652#include <sys/socket.h>
653#endif
654#endif
655  ], [AF_INET6],
656     AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
657)
658
659
660dnl check for the in6_addr structure
661CARES_CHECK_STRUCT(
662  [
663#undef inline
664#ifdef HAVE_WINDOWS_H
665#ifndef WIN32_LEAN_AND_MEAN
666#define WIN32_LEAN_AND_MEAN
667#endif
668#include <windows.h>
669#ifdef HAVE_WINSOCK2_H
670#include <winsock2.h>
671#ifdef HAVE_WS2TCPIP_H
672#include <ws2tcpip.h>
673#endif
674#endif
675#else
676#ifdef HAVE_SYS_TYPES_H
677#include <sys/types.h>
678#endif
679#ifdef HAVE_NETINET_IN_H
680#include <netinet/in.h>
681#endif
682#endif
683  ], [in6_addr],
684     AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
685)
686
687dnl check for the sockaddr_in6 structure
688CARES_CHECK_STRUCT(
689  [
690#undef inline
691#ifdef HAVE_WINDOWS_H
692#ifndef WIN32_LEAN_AND_MEAN
693#define WIN32_LEAN_AND_MEAN
694#endif
695#include <windows.h>
696#ifdef HAVE_WINSOCK2_H
697#include <winsock2.h>
698#ifdef HAVE_WS2TCPIP_H
699#include <ws2tcpip.h>
700#endif
701#endif
702#else
703#ifdef HAVE_SYS_TYPES_H
704#include <sys/types.h>
705#endif
706#ifdef HAVE_NETINET_IN_H
707#include <netinet/in.h>
708#endif
709#endif
710  ], [sockaddr_in6],
711     AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
712       [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
713)
714
715AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
716    AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
717      [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
718   , ,
719  [
720#undef inline
721#ifdef HAVE_WINDOWS_H
722#ifndef WIN32_LEAN_AND_MEAN
723#define WIN32_LEAN_AND_MEAN
724#endif
725#include <windows.h>
726#ifdef HAVE_WINSOCK2_H
727#include <winsock2.h>
728#ifdef HAVE_WS2TCPIP_H
729#include <ws2tcpip.h>
730#endif
731#endif
732#else
733#ifdef HAVE_SYS_TYPES_H
734#include <sys/types.h>
735#endif
736#ifdef HAVE_NETINET_IN_H
737#include <netinet/in.h>
738#endif
739#endif
740  ])
741
742dnl check for the addrinfo structure
743AC_CHECK_MEMBER(struct addrinfo.ai_flags,
744     AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
745       [Define to 1 if you have struct addrinfo.]),,
746  [
747#undef inline
748#ifdef HAVE_WINDOWS_H
749#ifndef WIN32_LEAN_AND_MEAN
750#define WIN32_LEAN_AND_MEAN
751#endif
752#include <windows.h>
753#ifdef HAVE_WINSOCK2_H
754#include <winsock2.h>
755#ifdef HAVE_WS2TCPIP_H
756#include <ws2tcpip.h>
757#endif
758#endif
759#else
760#ifdef HAVE_SYS_TYPES_H
761#include <sys/types.h>
762#endif
763#ifdef HAVE_NETINET_IN_H
764#include <netinet/in.h>
765#endif
766#ifdef HAVE_SYS_SOCKET_H
767#include <sys/socket.h>
768#endif
769#ifdef HAVE_NETDB_H
770#include <netdb.h>
771#endif
772#endif
773  ]
774)
775
776
777AC_CHECK_FUNCS([bitncmp \
778  gettimeofday \
779  if_indextoname
780],[
781],[
782  func="$ac_func"
783  AC_MSG_CHECKING([deeper for $func])
784  AC_LINK_IFELSE([
785    AC_LANG_PROGRAM([[
786    ]],[[
787      $func ();
788    ]])
789  ],[
790    AC_MSG_RESULT([yes])
791    eval "ac_cv_func_$func=yes"
792    AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
793      [Define to 1 if you have the $func function.])
794  ],[
795    AC_MSG_RESULT([but still no])
796  ])
797])
798
799dnl Android. Some variants like arm64 may no longer have __system_property_get
800dnl in libc, but they are defined in the headers.  Perform a link check.
801AC_CHECK_FUNC([__system_property_get], [
802    AC_DEFINE([HAVE___SYSTEM_PROPERTY_GET], [1], [Define if __system_property_get exists.])
803])
804
805dnl Check if the getnameinfo function is available
806dnl and get the types of five of its arguments.
807CURL_CHECK_FUNC_GETNAMEINFO
808
809
810AC_C_BIGENDIAN(
811    [AC_DEFINE(ARES_BIG_ENDIAN, 1,
812      [define this if ares is built for a big endian system])],
813    ,
814    [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
815)
816
817dnl Check for user-specified random device
818AC_ARG_WITH(random,
819AC_HELP_STRING([--with-random=FILE],
820               [read randomness from FILE (default=/dev/urandom)]),
821    [ RANDOM_FILE="$withval" ],
822    [
823        dnl Check for random device.  If we're cross compiling, we can't
824        dnl check, and it's better to assume it doesn't exist than it is
825        dnl to fail on AC_CHECK_FILE or later.
826        if test "$cross_compiling" = "no"; then
827          AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
828        else
829          AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
830        fi
831
832    ]
833)
834if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
835        AC_SUBST(RANDOM_FILE)
836        AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
837        [a suitable file/device to read random data from])
838fi
839
840CARES_CHECK_OPTION_NONBLOCKING
841CARES_CHECK_NONBLOCKING_SOCKET
842
843CARES_CONFIGURE_SYMBOL_HIDING
844
845CARES_PRIVATE_LIBS="$LIBS"
846AC_SUBST(CARES_PRIVATE_LIBS)
847
848CARES_CFLAG_EXTRAS=""
849if test X"$want_werror" = Xyes; then
850  CARES_CFLAG_EXTRAS="-Werror"
851fi
852AC_SUBST(CARES_CFLAG_EXTRAS)
853
854dnl squeeze whitespace out of some variables
855
856squeeze CFLAGS
857squeeze CPPFLAGS
858squeeze DEFS
859squeeze LDFLAGS
860squeeze LIBS
861
862squeeze CARES_PRIVATE_LIBS
863
864XC_CHECK_BUILD_FLAGS
865
866AC_MSG_CHECKING([whether to build tests])
867AC_ARG_ENABLE(tests,
868	AC_HELP_STRING([--enable-tests], [build test suite]),
869	[ build_tests="$enableval" ],
870	[ if test "x$HAVE_CXX11" = "x1" && test "x$cross_compiling" = "xno" ; then
871	    build_tests="yes"
872	  else
873	    build_tests="no"
874	  fi
875	]
876)
877
878if test "x$build_tests" = "xyes" ; then
879	if test "x$HAVE_CXX11" = "0" ; then
880		AC_MSG_ERROR([*** Building tests requires a CXX11 compiler])
881	fi
882	if test "x$cross_compiling" = "xyes" ; then
883		AC_MSG_ERROR([*** Tests not supported when cross compiling])
884	fi
885fi
886AC_MSG_RESULT([$build_tests])
887
888if test "x$build_tests" = "xyes" ; then
889  AC_CONFIG_SUBDIRS([test])
890fi
891
892AC_CONFIG_FILES([Makefile libcares.pc])
893AC_OUTPUT
894XC_AMEND_DISTCLEAN(['.'])
895