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