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