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