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