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