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