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