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