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