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