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