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