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