Another AC_TRY_LINK conversion to AC_LINK_IFELSE.
[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 AC_CONFIG_SRCDIR([ares_ipv6.h])
8 AM_CONFIG_HEADER([config.h])
9 AM_MAINTAINER_MODE
10
11 dnl SED is mandatory for configure process and libtool.
12 dnl Set it now, allowing it to be changed later.
13 AC_PATH_PROG([SED], [sed], [not_found],
14   [$PATH:/usr/bin:/usr/local/bin])
15 if test -z "$SED" || test "$SED" = "not_found"; then
16   AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
17 fi
18 AC_SUBST([SED])
19
20 dnl GREP is mandatory for configure process and libtool.
21 dnl Set it now, allowing it to be changed later.
22 AC_PATH_PROG([GREP], [grep], [not_found],
23   [$PATH:/usr/bin:/usr/local/bin])
24 if test -z "$GREP" || test "$GREP" = "not_found"; then
25   AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
26 fi
27 AC_SUBST([GREP])
28
29 dnl EGREP is mandatory for configure process and libtool.
30 dnl Set it now, allowing it to be changed later.
31 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
32   AC_MSG_CHECKING([for egrep])
33   EGREP="$GREP -E"
34   AC_MSG_RESULT([$EGREP])
35 else
36   AC_PATH_PROG([EGREP], [egrep], [not_found],
37     [$PATH:/usr/bin:/usr/local/bin])
38 fi
39 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
40   AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
41 fi
42 AC_SUBST([EGREP])
43
44 dnl AR is mandatory for configure process and libtool.
45 dnl This is target dependant, so check it as a tool.
46 AC_PATH_TOOL([AR], [ar], [not_found],
47   [$PATH:/usr/bin:/usr/local/bin])
48 if test -z "$AR" || test "$AR" = "not_found"; then
49   AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
50 fi
51 AC_SUBST([AR])
52
53 dnl Fetch c-ares version from ares_version.h
54 VERSION=`$SED -ne 's/^#define ARES_VERSION_STR "\(.*\)"/\1/p' ${srcdir}/ares_version.h`
55 AM_INIT_AUTOMAKE([c-ares], [$VERSION])
56 AC_MSG_CHECKING([c-ares version])
57 AC_MSG_RESULT([$VERSION])
58
59 dnl
60 dnl Detect the canonical host and target build environment
61 dnl
62
63 AC_CANONICAL_HOST
64 dnl Get system canonical name
65 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
66
67 AC_AIX
68 AC_PROG_CC
69 AM_PROG_CC_C_O
70 AC_PROG_INSTALL
71
72 dnl Our configure and build reentrant settings
73 CARES_CONFIGURE_REENTRANT
74
75 dnl check for how to do large files
76 AC_SYS_LARGEFILE
77
78 case $host_os in
79   solaris*)
80     AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
81     ;;
82 esac
83
84 dnl support building of Windows DLLs
85 AC_LIBTOOL_WIN32_DLL
86
87 dnl ************************************************************
88 dnl Option to switch on debug options. This makes an assumption that
89 dnl this is built as an 'ares' subdir in the curl source tree. Subject for
90 dnl improval in the future!
91 dnl
92 AC_MSG_CHECKING([whether to enable debug options])
93 AC_ARG_ENABLE(debug,
94 AC_HELP_STRING([--enable-debug],[Enable pedantic debug options])
95 AC_HELP_STRING([--disable-debug],[Disable debug options]),
96 [ case "$enableval" in
97   no)
98        AC_MSG_RESULT(no)
99        ;;
100   *)   AC_MSG_RESULT(yes)
101
102     dnl when doing the debug stuff, use static library only
103     AC_DISABLE_SHARED
104
105     debugbuild="yes"
106
107     dnl the entire --enable-debug is a hack that lives and runs on top of
108     dnl libcurl stuff so this BUILDING_LIBCURL is not THAT much uglier
109     AC_DEFINE(BUILDING_LIBCURL, 1, [when building as static part of libcurl])
110
111     CPPFLAGS="$CPPFLAGS -DCURLDEBUG -I$srcdir/../include"
112     CFLAGS="$CFLAGS -g" 
113
114     dnl set compiler "debug" options to become more picky, and remove
115     dnl optimize options from CFLAGS
116     CURL_CC_DEBUG_OPTS
117
118        ;;
119   esac ],
120        AC_MSG_RESULT(no)
121 )
122 AM_CONDITIONAL(DEBUGBUILD, test x$debugbuild = xyes)
123
124 dnl skip libtool C++ and Fortran compiler checks
125 m4_ifdef([AC_PROG_CXX], [m4_undefine([AC_PROG_CXX])])
126 m4_defun([AC_PROG_CXX],[])
127 m4_ifdef([AC_PROG_CXXCPP], [m4_undefine([AC_PROG_CXXCPP])])
128 m4_defun([AC_PROG_CXXCPP],[true])
129 m4_ifdef([AC_PROG_F77], [m4_undefine([AC_PROG_F77])])
130 m4_defun([AC_PROG_F77],[])
131
132 dnl skip libtool C++ and Fortran linker checks
133 m4_ifdef([AC_LIBTOOL_CXX], [m4_undefine([AC_LIBTOOL_CXX])])
134 m4_defun([AC_LIBTOOL_CXX],[])
135 m4_ifdef([AC_LIBTOOL_CXXCPP], [m4_undefine([AC_LIBTOOL_CXXCPP])])
136 m4_defun([AC_LIBTOOL_CXXCPP],[true])
137 m4_ifdef([AC_LIBTOOL_F77], [m4_undefine([AC_LIBTOOL_F77])])
138 m4_defun([AC_LIBTOOL_F77],[])
139
140 dnl force libtool to build static libraries with PIC on AMD64-linux
141 AC_MSG_CHECKING([if arch-OS host is AMD64-linux (to build static libraries with PIC)])
142 case $host in
143   x86_64*linux*)
144     AC_MSG_RESULT([yes])
145     with_pic=yes
146     ;;
147   *)
148     AC_MSG_RESULT([no])
149     ;;
150 esac
151
152 dnl libtool setup
153 AC_PROG_LIBTOOL
154
155 AC_MSG_CHECKING([if we need -no-undefined])
156 case $host in
157   *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
158     need_no_undefined=yes
159     ;;
160   *)
161     need_no_undefined=no
162     ;;
163 esac
164 AC_MSG_RESULT($need_no_undefined)
165 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
166
167 dnl **********************************************************************
168 dnl check if this is the Intel ICC compiler, and if so make it stricter
169 dnl (convert warning 147 into an error) so that it properly can detect the
170 dnl gethostbyname_r() version
171 dnl **********************************************************************
172 CURL_DETECT_ICC([CFLAGS="$CFLAGS -we 147"])
173
174 dnl **********************************************************************
175 dnl platform/compiler/architecture specific checks/flags
176 dnl **********************************************************************
177
178 case $host in
179   #
180   x86_64*linux*)
181     #
182     dnl find out if icc is being used
183     if test "z$ICC" = "z"; then
184       CURL_DETECT_ICC
185     fi
186     #
187     if test "$ICC" = "yes"; then
188       dnl figure out icc version
189       AC_MSG_CHECKING([icc version])
190       iccver=`$CC -dumpversion`
191       iccnhi=`echo $iccver | cut -d . -f1`
192       iccnlo=`echo $iccver | cut -d . -f2`
193       iccnum=`(expr $iccnhi "*" 100 + $iccnlo) 2>/dev/null`
194       AC_MSG_RESULT($iccver)
195       #
196       if test "$iccnum" -ge "900" && test "$iccnum" -lt "1000"; then
197         dnl icc 9.X specific
198         CFLAGS="$CFLAGS -i-dynamic"
199       fi
200       #
201       if test "$iccnum" -ge "1000"; then
202         dnl icc 10.X or later
203         CFLAGS="$CFLAGS -shared-intel"
204       fi
205       #
206     fi
207     ;;
208   #
209 esac
210
211 AC_MSG_CHECKING([whether we are using the IBM C compiler])
212 CURL_CHECK_DEF([__IBMC__], [], [silent])
213 CURL_CHECK_DEF([__IBMCPP__], [], [silent])
214 if test "$curl_cv_have_def___IBMC__" = "yes" ||
215   test "$curl_cv_have_def___IBMCPP__" = "yes"; then
216   AC_MSG_RESULT([yes])
217   dnl Ensure that compiler optimizations are always thread-safe.
218   CFLAGS="$CFLAGS -qthreaded"
219   dnl Disable type based strict aliasing optimizations, using worst
220   dnl case aliasing assumptions when compiling. Type based aliasing
221   dnl would restrict the lvalues that could be safely used to access
222   dnl a data object.
223   CFLAGS="$CFLAGS -qnoansialias"
224   dnl Force compiler to stop after the compilation phase, without
225   dnl generating an object code file when compilation has errors.
226   CFLAGS="$CFLAGS -qhalt=e"
227 else
228   AC_MSG_RESULT([no])
229 fi
230
231 AC_MSG_CHECKING([whether we are using the DEC/Compaq C compiler])
232 CURL_CHECK_DEF([__DECC], [], [silent])
233 CURL_CHECK_DEF([__DECC_VER], [], [silent])
234 if test "$curl_cv_have_def___DECC" = "yes" ||
235   test "$curl_cv_have_def___DECC_VER" = "yes"; then
236   AC_MSG_RESULT([yes])
237   dnl Select strict ANSI C compiler mode
238   CFLAGS="$CFLAGS -std1"
239   dnl Select a higher warning level than default level2
240   CFLAGS="$CFLAGS -msg_enable level3"
241   dnl Generate warnings for missing function prototypes
242   CFLAGS="$CFLAGS -warnprotos"
243   dnl Change some warnings into fatal errors
244   CFLAGS="$CFLAGS -msg_fatal toofewargs,toomanyargs"
245 else
246   AC_MSG_RESULT([no])
247 fi
248
249 CURL_CHECK_COMPILER_HALT_ON_ERROR
250 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
251
252 dnl **********************************************************************
253 dnl Compilation based checks should not be done before this point.
254 dnl **********************************************************************
255
256 dnl **********************************************************************
257 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h 
258 dnl and ws2tcpip.h take precedence over any other further checks which 
259 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
260 dnl this specific header files. And do them before its results are used.
261 dnl **********************************************************************
262
263 CURL_CHECK_HEADER_WINDOWS
264 CURL_CHECK_NATIVE_WINDOWS
265 case X-"$ac_cv_native_windows" in
266   X-yes)
267     CURL_CHECK_HEADER_WINSOCK
268     CURL_CHECK_HEADER_WINSOCK2
269     CURL_CHECK_HEADER_WS2TCPIP
270     ;;
271   *)
272     ac_cv_header_winsock_h="no"
273     ac_cv_header_winsock2_h="no"
274     ac_cv_header_ws2tcpip_h="no"
275     ;;
276 esac
277
278 dnl **********************************************************************
279 dnl Checks for libraries.
280 dnl **********************************************************************
281
282 dnl gethostbyname without lib or in the nsl lib?
283 AC_CHECK_FUNC(gethostbyname,
284               [HAVE_GETHOSTBYNAME="1"
285               ],
286               [ AC_CHECK_LIB(nsl, gethostbyname,
287                              [HAVE_GETHOSTBYNAME="1"
288                              LIBS="$LIBS -lnsl"
289                              ])
290               ])
291
292 if test "$HAVE_GETHOSTBYNAME" != "1"
293 then
294   dnl gethostbyname in the socket lib?
295   AC_CHECK_LIB(socket, gethostbyname,
296                [HAVE_GETHOSTBYNAME="1"
297                LIBS="$LIBS -lsocket"
298                ])
299 fi
300
301 dnl At least one system has been identified to require BOTH nsl and socket
302 dnl libs at the same time to link properly.
303 if test "$HAVE_GETHOSTBYNAME" != "1"
304 then
305   AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
306   my_ac_save_LIBS=$LIBS
307   LIBS="-lnsl -lsocket $LIBS"
308   AC_LINK_IFELSE([
309     AC_LANG_PROGRAM([[
310     ]],[[
311       gethostbyname();
312     ]])
313   ],[
314     AC_MSG_RESULT([yes])
315     HAVE_GETHOSTBYNAME="1"
316   ],[
317     AC_MSG_RESULT([no])
318     LIBS=$my_ac_save_LIBS
319   ])
320 fi
321
322 if test "$HAVE_GETHOSTBYNAME" != "1"
323 then
324   dnl This is for winsock systems
325   if test "$ac_cv_header_windows_h" = "yes"; then
326     if test "$ac_cv_header_winsock_h" = "yes"; then
327       case $host in
328         *-*-mingw32ce*)
329           winsock_LIB="-lwinsock"
330           ;;
331         *)
332           winsock_LIB="-lwsock32"
333           ;;
334       esac
335     fi
336     if test "$ac_cv_header_winsock2_h" = "yes"; then
337       winsock_LIB="-lws2_32"
338     fi
339     if test ! -z "$winsock_LIB"; then
340       my_ac_save_LIBS=$LIBS
341       LIBS="$winsock_LIB $LIBS"
342       AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
343       AC_LINK_IFELSE([
344         AC_LANG_PROGRAM([[
345 #ifdef HAVE_WINDOWS_H
346 #ifndef WIN32_LEAN_AND_MEAN
347 #define WIN32_LEAN_AND_MEAN
348 #endif
349 #include <windows.h>
350 #ifdef HAVE_WINSOCK2_H
351 #include <winsock2.h>
352 #else
353 #ifdef HAVE_WINSOCK_H
354 #include <winsock.h>
355 #endif
356 #endif
357 #endif
358         ]],[[
359           gethostbyname("www.dummysite.com");
360         ]])
361       ],[
362         AC_MSG_RESULT([yes])
363         HAVE_GETHOSTBYNAME="1"
364       ],[
365         AC_MSG_RESULT([no])
366         winsock_LIB=""
367         LIBS=$my_ac_save_LIBS
368       ])
369     fi
370   fi
371 fi
372
373 if test "$HAVE_GETHOSTBYNAME" != "1"
374 then
375   dnl This is for Minix 3.1
376   AC_MSG_CHECKING([for gethostbyname for Minix 3])
377   AC_LINK_IFELSE([
378     AC_LANG_PROGRAM([[
379 /* Older Minix versions may need <net/gen/netdb.h> here instead */
380 #include <netdb.h>
381     ]],[[
382       gethostbyname("www.dummysite.com");
383     ]])
384   ],[
385     AC_MSG_RESULT([yes])
386     HAVE_GETHOSTBYNAME="1"
387   ],[
388     AC_MSG_RESULT([no])
389   ])
390 fi
391
392 if test "$HAVE_GETHOSTBYNAME" != "1"
393 then
394   dnl This is for eCos with a stubbed DNS implementation
395   AC_MSG_CHECKING([for gethostbyname for eCos])
396   AC_LINK_IFELSE([
397     AC_LANG_PROGRAM([[
398 #include <stdio.h>
399 #include <netdb.h>
400     ]],[[
401       gethostbyname("www.dummysite.com");
402     ]])
403   ],[
404     AC_MSG_RESULT([yes])
405     HAVE_GETHOSTBYNAME="1"
406   ],[
407     AC_MSG_RESULT([no])
408   ])
409 fi
410
411 if test "$HAVE_GETHOSTBYNAME" != "1"
412 then
413   dnl gethostbyname in the net lib - for BeOS
414   AC_CHECK_LIB(net, gethostbyname,
415                [HAVE_GETHOSTBYNAME="1"
416                LIBS="$LIBS -lnet"
417                ])
418 fi
419
420
421 if test "$HAVE_GETHOSTBYNAME" = "1"; then
422   AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
423 else
424   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
425 fi
426
427 dnl resolve lib?
428 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
429
430 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
431   AC_CHECK_LIB(resolve, strcasecmp,
432               [LIBS="-lresolve $LIBS"],
433                ,
434                -lnsl)
435 fi
436
437 dnl socket lib?
438 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
439
440 dnl **********************************************************************
441 dnl In case that function clock_gettime with monotonic timer is available,
442 dnl check for additional required libraries.
443 dnl **********************************************************************
444 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
445
446 AC_MSG_CHECKING([whether to use libgcc])
447 AC_ARG_ENABLE(libgcc,
448 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
449 [ case "$enableval" in
450   yes)
451         LIBS="$LIBS -lgcc"
452        AC_MSG_RESULT(yes)
453        ;;
454   *)   AC_MSG_RESULT(no)
455        ;;
456   esac ],
457        AC_MSG_RESULT(no)
458 )
459
460
461 dnl Default is to try the thread-safe versions of a few functions
462 OPT_THREAD=on
463
464 dnl detect AIX 4.3 or later
465 AC_MSG_CHECKING([AIX 4.3 or later])
466 AC_PREPROC_IFELSE([
467 #if defined(_AIX) && defined(_AIX43)
468 printf("just fine");
469 #else
470 #error "this is not AIX 4.3 or later"
471 #endif
472 ],
473  [ AC_MSG_RESULT([yes])
474    RECENTAIX=yes
475    OPT_THREAD=off ],
476  [ AC_MSG_RESULT([no]) ]
477 )
478
479 AC_ARG_ENABLE(thread,dnl
480 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
481 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
482 [ case "$enableval" in
483   no)
484     OPT_THREAD=off
485     AC_MSG_WARN(c-ares will not get built using thread-safe functions)
486     ;;
487   *)
488     ;;
489   esac
490 ]
491 )
492
493 if test X"$OPT_THREAD" = Xoff
494 then
495   AC_DEFINE(DISABLED_THREADSAFE, 1,
496     [Set to explicitly specify we don't want to use thread-safe functions])
497 fi
498
499 dnl for recent AIX versions, we skip all the thread-safe checks above since
500 dnl they claim a thread-safe libc using the standard API. But there are
501 dnl some functions still not thread-safe. Check for these!
502
503 dnl Let's hope this split URL remains working:
504 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
505 dnl genprogc/thread_quick_ref.htm
506
507 if test "x$RECENTAIX" = "xyes"; then
508
509   AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
510
511 fi
512
513
514 dnl **********************************************************************
515 dnl Back to "normal" configuring
516 dnl **********************************************************************
517
518 dnl Checks for header files.
519 AC_HEADER_STDC
520
521 CURL_CHECK_HEADER_MALLOC
522
523 dnl check for a few basic system headers we need
524 AC_CHECK_HEADERS(
525        sys/types.h \
526        sys/time.h \
527        sys/select.h \
528        sys/socket.h \
529        sys/ioctl.h \
530        sys/param.h \
531        netdb.h \
532        netinet/in.h \
533        netinet/tcp.h \
534        net/if.h \
535        errno.h \
536        strings.h \
537        stdbool.h \
538        time.h \
539        arpa/nameser.h \
540        arpa/nameser_compat.h \
541        arpa/inet.h,
542 dnl to do if not found
543 [],
544 dnl to do if found
545 [],
546 dnl default includes
547 [
548 #ifdef HAVE_SYS_TYPES_H
549 #include <sys/types.h>
550 #endif
551 #ifdef HAVE_SYS_TIME_H
552 #include <sys/time.h>
553 #endif
554 dnl We do this default-include simply to make sure that the nameser_compat.h
555 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
556 dnl (and others?) is not designed to allow this.
557 #ifdef HAVE_ARPA_NAMESER_H
558 #include <arpa/nameser.h>
559 #endif
560
561 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
562 #ifdef HAVE_SYS_SOCKET_H
563 #include <sys/socket.h>
564 #endif
565 #ifdef HAVE_NETINET_IN_H
566 #include <netinet/in.h>
567 #endif
568 ]
569 )
570
571 dnl Checks for typedefs, structures, and compiler characteristics.
572 AC_C_CONST
573 AC_TYPE_SIZE_T
574 AC_HEADER_TIME
575 CURL_CHECK_STRUCT_TIMEVAL
576
577 AC_CHECK_SIZEOF(size_t)
578 AC_CHECK_SIZEOF(long)
579 AC_CHECK_SIZEOF(time_t)
580
581 AC_CHECK_TYPE(long long,
582    [AC_DEFINE(HAVE_LONGLONG, 1, [if your compiler supports long long])]
583    longlong="yes"  
584 )
585
586 if test "xyes" = "x$longlong"; then
587   AC_MSG_CHECKING([if numberLL works])
588   AC_COMPILE_IFELSE([long long val = 1000LL;],
589    [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
590    AC_MSG_RESULT(yes),
591    AC_MSG_RESULT(no)
592   )
593 fi
594
595
596 # check for ssize_t
597 AC_CHECK_TYPE(ssize_t, ,
598    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
599
600 # check for bool type
601 AC_CHECK_TYPE([bool],[
602   AC_DEFINE(HAVE_BOOL_T, 1,
603     [Define to 1 if bool is an available type.])
604 ], ,[
605 #ifdef HAVE_SYS_TYPES_H
606 #include <sys/types.h>
607 #endif
608 #ifdef HAVE_STDBOOL_H
609 #include <stdbool.h>
610 #endif
611 ])
612
613 # Check for socklen_t or equivalent
614 CURL_CHECK_TYPE_SOCKLEN_T
615
616 TYPE_IN_ADDR_T
617
618 TYPE_SOCKADDR_STORAGE
619
620 TYPE_SIG_ATOMIC_T
621
622 AC_TYPE_SIGNAL
623
624 CURL_CHECK_FUNC_RECV
625 CURL_CHECK_FUNC_RECVFROM
626 CURL_CHECK_FUNC_SEND
627 CURL_CHECK_MSG_NOSIGNAL
628
629 dnl check for AF_INET6
630 CARES_CHECK_CONSTANT(
631   [
632 #undef inline
633 #ifdef HAVE_WINDOWS_H
634 #ifndef WIN32_LEAN_AND_MEAN
635 #define WIN32_LEAN_AND_MEAN
636 #endif
637 #include <windows.h>
638 #ifdef HAVE_WINSOCK2_H
639 #include <winsock2.h>
640 #endif
641 #else
642 #ifdef HAVE_SYS_TYPES_H
643 #include <sys/types.h>
644 #endif
645 #ifdef HAVE_SYS_SOCKET_H
646 #include <sys/socket.h>
647 #endif
648 #endif
649   ], [PF_INET6], 
650      AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
651 )
652
653 dnl check for PF_INET6
654 CARES_CHECK_CONSTANT(
655   [
656 #undef inline
657 #ifdef HAVE_WINDOWS_H
658 #ifndef WIN32_LEAN_AND_MEAN
659 #define WIN32_LEAN_AND_MEAN
660 #endif
661 #include <windows.h>
662 #ifdef HAVE_WINSOCK2_H
663 #include <winsock2.h>
664 #endif
665 #else
666 #ifdef HAVE_SYS_TYPES_H
667 #include <sys/types.h>
668 #endif
669 #ifdef HAVE_SYS_SOCKET_H
670 #include <sys/socket.h>
671 #endif
672 #endif
673   ], [AF_INET6], 
674      AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
675 )
676
677
678 dnl check for the in6_addr structure
679 CARES_CHECK_STRUCT(
680   [
681 #undef inline
682 #ifdef HAVE_WINDOWS_H
683 #ifndef WIN32_LEAN_AND_MEAN
684 #define WIN32_LEAN_AND_MEAN
685 #endif
686 #include <windows.h>
687 #ifdef HAVE_WINSOCK2_H
688 #include <winsock2.h>
689 #ifdef HAVE_WS2TCPIP_H
690 #include <ws2tcpip.h>
691 #endif
692 #endif
693 #else
694 #ifdef HAVE_SYS_TYPES_H
695 #include <sys/types.h>
696 #endif
697 #ifdef HAVE_NETINET_IN_H
698 #include <netinet/in.h>
699 #endif
700 #endif
701   ], [in6_addr], 
702      AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
703 )
704
705 dnl check for the sockaddr_in6 structure
706 CARES_CHECK_STRUCT(
707   [
708 #undef inline
709 #ifdef HAVE_WINDOWS_H
710 #ifndef WIN32_LEAN_AND_MEAN
711 #define WIN32_LEAN_AND_MEAN
712 #endif
713 #include <windows.h>
714 #ifdef HAVE_WINSOCK2_H
715 #include <winsock2.h>
716 #ifdef HAVE_WS2TCPIP_H
717 #include <ws2tcpip.h>
718 #endif
719 #endif
720 #else
721 #ifdef HAVE_SYS_TYPES_H
722 #include <sys/types.h>
723 #endif
724 #ifdef HAVE_NETINET_IN_H
725 #include <netinet/in.h>
726 #endif
727 #endif
728   ], [sockaddr_in6], 
729      AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
730        [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
731 )
732
733 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
734     AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
735       [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
736    , ,
737   [
738 #undef inline
739 #ifdef HAVE_WINDOWS_H
740 #ifndef WIN32_LEAN_AND_MEAN
741 #define WIN32_LEAN_AND_MEAN
742 #endif
743 #include <windows.h>
744 #ifdef HAVE_WINSOCK2_H
745 #include <winsock2.h>
746 #ifdef HAVE_WS2TCPIP_H
747 #include <ws2tcpip.h>
748 #endif
749 #endif
750 #else
751 #ifdef HAVE_SYS_TYPES_H
752 #include <sys/types.h>
753 #endif
754 #ifdef HAVE_NETINET_IN_H
755 #include <netinet/in.h>
756 #endif
757 #endif
758   ])
759
760 dnl check for the addrinfo structure
761 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
762      AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
763        [Define to 1 if you have struct addrinfo.]),,
764   [
765 #undef inline
766 #ifdef HAVE_WINDOWS_H
767 #ifndef WIN32_LEAN_AND_MEAN
768 #define WIN32_LEAN_AND_MEAN
769 #endif
770 #include <windows.h>
771 #ifdef HAVE_WINSOCK2_H
772 #include <winsock2.h>
773 #ifdef HAVE_WS2TCPIP_H
774 #include <ws2tcpip.h>
775 #endif
776 #endif
777 #else
778 #ifdef HAVE_SYS_TYPES_H
779 #include <sys/types.h>
780 #endif
781 #ifdef HAVE_NETINET_IN_H
782 #include <netinet/in.h>
783 #endif
784 #ifdef HAVE_SYS_SOCKET_H
785 #include <sys/socket.h>
786 #endif
787 #ifdef HAVE_NETDB_H
788 #include <netdb.h>
789 #endif
790 #endif
791   ]
792 )
793
794
795 AC_CHECK_FUNCS([bitncmp \
796   gettimeofday \
797   if_indextoname
798 ],[
799 ],[
800   func="$ac_func"
801   AC_MSG_CHECKING([deeper for $func])
802   AC_LINK_IFELSE([
803     AC_LANG_PROGRAM([[
804     ]],[[
805       $func ();
806     ]])
807   ],[
808     AC_MSG_RESULT([yes])
809     eval "ac_cv_func_$func=yes"
810     AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$func])], [1],
811       [Define to 1 if you have the $func function.])
812   ],[
813     AC_MSG_RESULT([but still no])
814   ])
815 ])
816
817
818 dnl check for inet_pton
819 AC_CHECK_FUNCS(inet_pton)
820 dnl Some systems have it, but not IPv6
821 if test "$ac_cv_func_inet_pton" = "yes" ; then
822 AC_MSG_CHECKING(if inet_pton supports IPv6)
823 AC_TRY_RUN(
824   [
825 #ifdef HAVE_SYS_TYPES_H
826 #include <sys/types.h>
827 #endif
828 #ifdef HAVE_SYS_SOCKET_H
829 #include <sys/socket.h>
830 #endif
831 #ifdef HAVE_NETINET_IN_H
832 #include <netinet/in.h>
833 #endif
834 int main()
835   {
836     struct in6_addr addr6;
837     if (inet_pton(AF_INET6, "::1", &addr6) < 1)
838       exit(1);
839     else
840       exit(0);
841   }
842   ], [
843        AC_MSG_RESULT(yes)
844        AC_DEFINE_UNQUOTED(HAVE_INET_PTON_IPV6,1,[Define to 1 if inet_pton supports IPv6.])
845      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
846 fi
847 dnl Check for inet_net_pton
848 AC_CHECK_FUNCS(inet_net_pton)
849 dnl Again, some systems have it, but not IPv6
850 if test "$ac_cv_func_inet_net_pton" = "yes" ; then
851 AC_MSG_CHECKING(if inet_net_pton supports IPv6)
852 AC_TRY_RUN(
853   [
854 #ifdef HAVE_SYS_TYPES_H
855 #include <sys/types.h>
856 #endif
857 #ifdef HAVE_SYS_SOCKET_H
858 #include <sys/socket.h>
859 #endif
860 #ifdef HAVE_NETINET_IN_H
861 #include <netinet/in.h>
862 #endif
863 int main()
864   {
865     struct in6_addr addr6;
866     if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
867       exit(1);
868     else
869       exit(0);
870   }
871   ], [
872        AC_MSG_RESULT(yes)
873        AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
874      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
875 fi
876
877
878 dnl Check for inet_ntop
879 AC_CHECK_FUNCS(inet_ntop)
880 dnl Again, some systems have it, but not IPv6
881 if test "$ac_cv_func_inet_ntop" = "yes" ; then
882 AC_MSG_CHECKING(if inet_ntop supports IPv6)
883 AC_TRY_RUN(
884   [
885 #ifdef HAVE_SYS_TYPES_H
886 #include <sys/types.h>
887 #endif
888 #ifdef HAVE_SYS_SOCKET_H
889 #include <sys/socket.h>
890 #endif
891 #ifdef HAVE_NETINET_IN_H
892 #include <netinet/in.h>
893 #endif
894 #include <errno.h>
895 int main()
896   {
897     struct in6_addr addr6;
898     char buf[128];
899     if (inet_ntop(AF_INET6, &addr6, buf, 128) == 0 && errno == EAFNOSUPPORT)
900       exit(1);
901     else
902       exit(0);
903   }
904   ], [
905        AC_MSG_RESULT(yes)
906        AC_DEFINE_UNQUOTED(HAVE_INET_NTOP_IPV6,1,
907           [Define to 1 if inet_ntop supports IPv6.])
908      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
909 fi
910
911 AC_CHECK_SIZEOF(struct in6_addr, ,
912 [
913 #undef inline
914 #ifdef HAVE_WINDOWS_H
915 #ifndef WIN32_LEAN_AND_MEAN
916 #define WIN32_LEAN_AND_MEAN
917 #endif
918 #include <windows.h>
919 #ifdef HAVE_WINSOCK2_H
920 #include <winsock2.h>
921 #ifdef HAVE_WS2TCPIP_H
922 #include <ws2tcpip.h>
923 #endif
924 #endif
925 #else
926 #ifdef HAVE_SYS_TYPES_H
927 #include <sys/types.h>
928 #endif
929 #ifdef HAVE_SYS_SOCKET_H
930 #include <sys/socket.h>
931 #endif
932 #ifdef HAVE_NETINET_IN_H
933 #include <netinet/in.h>
934 #endif
935 #endif
936 ]
937 )
938
939 AC_CHECK_SIZEOF(struct in_addr, ,
940 [
941 #undef inline
942 #ifdef HAVE_WINDOWS_H
943 #ifndef WIN32_LEAN_AND_MEAN
944 #define WIN32_LEAN_AND_MEAN
945 #endif
946 #include <windows.h>
947 #ifdef HAVE_WINSOCK2_H
948 #include <winsock2.h>
949 #ifdef HAVE_WS2TCPIP_H
950 #include <ws2tcpip.h>
951 #endif
952 #endif
953 #else
954 #ifdef HAVE_SYS_TYPES_H
955 #include <sys/types.h>
956 #endif
957 #ifdef HAVE_SYS_SOCKET_H
958 #include <sys/socket.h>
959 #endif
960 #ifdef HAVE_NETINET_IN_H
961 #include <netinet/in.h>
962 #endif
963 #endif
964 ]
965 )
966
967
968 dnl Check if the getnameinfo function is available
969 dnl and get the types of five of its arguments.
970 CURL_CHECK_FUNC_GETNAMEINFO
971
972
973 dnl God bless non-standardized functions! We need to see which getservbyport_r
974 dnl variant is available
975 CARES_CHECK_GETSERVBYPORT_R
976
977 CURL_CHECK_NONBLOCKING_SOCKET
978
979 AC_C_BIGENDIAN(
980     [AC_DEFINE(ARES_BIG_ENDIAN, 1,
981       [define this if ares is built for a big endian system])],
982     ,
983     [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
984 )
985
986 dnl Check for user-specified random device
987 AC_ARG_WITH(random,
988 AC_HELP_STRING([--with-random=FILE],
989                [read randomness from FILE (default=/dev/urandom)]),
990     [ RANDOM_FILE="$withval" ],
991     [
992         dnl Check for random device.  If we're cross compiling, we can't
993         dnl check, and it's better to assume it doesn't exist than it is
994         dnl to fail on AC_CHECK_FILE or later.
995         if test "$cross_compiling" = "no"; then
996           AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
997         else
998           AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
999         fi
1000         
1001     ]
1002 )
1003 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
1004         AC_SUBST(RANDOM_FILE)
1005         AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
1006         [a suitable file/device to read random data from])
1007 fi
1008
1009 CARES_PRIVATE_LIBS="$LIBS"
1010 AC_SUBST(CARES_PRIVATE_LIBS)
1011
1012 AC_CONFIG_FILES([Makefile libcares.pc])
1013 AC_OUTPUT