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