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