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