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