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