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