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