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