Adjust DEC/Compaq C compiler settings.
[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 Turn off optimizer ANSI C aliasing rules
240   CFLAGS="$CFLAGS -noansi_alias"
241   dnl Select a higher warning level than default level2
242   CFLAGS="$CFLAGS -msg_enable level3"
243   dnl Generate warnings for missing function prototypes
244   CFLAGS="$CFLAGS -warnprotos"
245   dnl Change some warnings into fatal errors
246   CFLAGS="$CFLAGS -msg_fatal toofewargs,toomanyargs"
247 else
248   AC_MSG_RESULT([no])
249 fi
250
251 CURL_CHECK_COMPILER_HALT_ON_ERROR
252 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
253
254 dnl **********************************************************************
255 dnl Compilation based checks should not be done before this point.
256 dnl **********************************************************************
257
258 dnl **********************************************************************
259 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h 
260 dnl and ws2tcpip.h take precedence over any other further checks which 
261 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
262 dnl this specific header files. And do them before its results are used.
263 dnl **********************************************************************
264
265 CURL_CHECK_HEADER_WINDOWS
266 CURL_CHECK_NATIVE_WINDOWS
267 case X-"$ac_cv_native_windows" in
268   X-yes)
269     CURL_CHECK_HEADER_WINSOCK
270     CURL_CHECK_HEADER_WINSOCK2
271     CURL_CHECK_HEADER_WS2TCPIP
272     ;;
273   *)
274     ac_cv_header_winsock_h="no"
275     ac_cv_header_winsock2_h="no"
276     ac_cv_header_ws2tcpip_h="no"
277     ;;
278 esac
279
280 dnl **********************************************************************
281 dnl Checks for libraries.
282 dnl **********************************************************************
283
284 dnl gethostbyname without lib or in the nsl lib?
285 AC_CHECK_FUNC(gethostbyname,
286               [HAVE_GETHOSTBYNAME="1"
287               ],
288               [ AC_CHECK_LIB(nsl, gethostbyname,
289                              [HAVE_GETHOSTBYNAME="1"
290                              LIBS="$LIBS -lnsl"
291                              ])
292               ])
293
294 if test "$HAVE_GETHOSTBYNAME" != "1"
295 then
296   dnl gethostbyname in the socket lib?
297   AC_CHECK_LIB(socket, gethostbyname,
298                [HAVE_GETHOSTBYNAME="1"
299                LIBS="$LIBS -lsocket"
300                ])
301 fi
302
303 dnl At least one system has been identified to require BOTH nsl and socket
304 dnl libs at the same time to link properly.
305 if test "$HAVE_GETHOSTBYNAME" != "1"
306 then
307   AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
308   my_ac_save_LIBS=$LIBS
309   LIBS="-lnsl -lsocket $LIBS"
310   AC_LINK_IFELSE([
311     AC_LANG_PROGRAM([[
312     ]],[[
313       gethostbyname();
314     ]])
315   ],[
316     AC_MSG_RESULT([yes])
317     HAVE_GETHOSTBYNAME="1"
318   ],[
319     AC_MSG_RESULT([no])
320     LIBS=$my_ac_save_LIBS
321   ])
322 fi
323
324 if test "$HAVE_GETHOSTBYNAME" != "1"
325 then
326   dnl This is for winsock systems
327   if test "$ac_cv_header_windows_h" = "yes"; then
328     if test "$ac_cv_header_winsock_h" = "yes"; then
329       case $host in
330         *-*-mingw32ce*)
331           winsock_LIB="-lwinsock"
332           ;;
333         *)
334           winsock_LIB="-lwsock32"
335           ;;
336       esac
337     fi
338     if test "$ac_cv_header_winsock2_h" = "yes"; then
339       winsock_LIB="-lws2_32"
340     fi
341     if test ! -z "$winsock_LIB"; then
342       my_ac_save_LIBS=$LIBS
343       LIBS="$winsock_LIB $LIBS"
344       AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
345       AC_LINK_IFELSE([
346         AC_LANG_PROGRAM([[
347 #ifdef HAVE_WINDOWS_H
348 #ifndef WIN32_LEAN_AND_MEAN
349 #define WIN32_LEAN_AND_MEAN
350 #endif
351 #include <windows.h>
352 #ifdef HAVE_WINSOCK2_H
353 #include <winsock2.h>
354 #else
355 #ifdef HAVE_WINSOCK_H
356 #include <winsock.h>
357 #endif
358 #endif
359 #endif
360         ]],[[
361           gethostbyname("www.dummysite.com");
362         ]])
363       ],[
364         AC_MSG_RESULT([yes])
365         HAVE_GETHOSTBYNAME="1"
366       ],[
367         AC_MSG_RESULT([no])
368         winsock_LIB=""
369         LIBS=$my_ac_save_LIBS
370       ])
371     fi
372   fi
373 fi
374
375 if test "$HAVE_GETHOSTBYNAME" != "1"
376 then
377   dnl This is for Minix 3.1
378   AC_MSG_CHECKING([for gethostbyname for Minix 3])
379   AC_LINK_IFELSE([
380     AC_LANG_PROGRAM([[
381 /* Older Minix versions may need <net/gen/netdb.h> here instead */
382 #include <netdb.h>
383     ]],[[
384       gethostbyname("www.dummysite.com");
385     ]])
386   ],[
387     AC_MSG_RESULT([yes])
388     HAVE_GETHOSTBYNAME="1"
389   ],[
390     AC_MSG_RESULT([no])
391   ])
392 fi
393
394 if test "$HAVE_GETHOSTBYNAME" != "1"
395 then
396   dnl This is for eCos with a stubbed DNS implementation
397   AC_MSG_CHECKING([for gethostbyname for eCos])
398   AC_LINK_IFELSE([
399     AC_LANG_PROGRAM([[
400 #include <stdio.h>
401 #include <netdb.h>
402     ]],[[
403       gethostbyname("www.dummysite.com");
404     ]])
405   ],[
406     AC_MSG_RESULT([yes])
407     HAVE_GETHOSTBYNAME="1"
408   ],[
409     AC_MSG_RESULT([no])
410   ])
411 fi
412
413 if test "$HAVE_GETHOSTBYNAME" != "1"
414 then
415   dnl gethostbyname in the net lib - for BeOS
416   AC_CHECK_LIB(net, gethostbyname,
417                [HAVE_GETHOSTBYNAME="1"
418                LIBS="$LIBS -lnet"
419                ])
420 fi
421
422
423 if test "$HAVE_GETHOSTBYNAME" = "1"; then
424   AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
425 else
426   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
427 fi
428
429 dnl resolve lib?
430 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
431
432 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
433   AC_CHECK_LIB(resolve, strcasecmp,
434               [LIBS="-lresolve $LIBS"],
435                ,
436                -lnsl)
437 fi
438
439 dnl socket lib?
440 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
441
442 dnl **********************************************************************
443 dnl In case that function clock_gettime with monotonic timer is available,
444 dnl check for additional required libraries.
445 dnl **********************************************************************
446 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
447
448 AC_MSG_CHECKING([whether to use libgcc])
449 AC_ARG_ENABLE(libgcc,
450 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
451 [ case "$enableval" in
452   yes)
453         LIBS="$LIBS -lgcc"
454        AC_MSG_RESULT(yes)
455        ;;
456   *)   AC_MSG_RESULT(no)
457        ;;
458   esac ],
459        AC_MSG_RESULT(no)
460 )
461
462
463 dnl Default is to try the thread-safe versions of a few functions
464 OPT_THREAD=on
465
466 dnl detect AIX 4.3 or later
467 AC_MSG_CHECKING([AIX 4.3 or later])
468 AC_PREPROC_IFELSE([
469 #if defined(_AIX) && defined(_AIX43)
470 printf("just fine");
471 #else
472 #error "this is not AIX 4.3 or later"
473 #endif
474 ],
475  [ AC_MSG_RESULT([yes])
476    RECENTAIX=yes
477    OPT_THREAD=off ],
478  [ AC_MSG_RESULT([no]) ]
479 )
480
481 AC_ARG_ENABLE(thread,dnl
482 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
483 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
484 [ case "$enableval" in
485   no)
486     OPT_THREAD=off
487     AC_MSG_WARN(c-ares will not get built using thread-safe functions)
488     ;;
489   *)
490     ;;
491   esac
492 ]
493 )
494
495 if test X"$OPT_THREAD" = Xoff
496 then
497   AC_DEFINE(DISABLED_THREADSAFE, 1,
498     [Set to explicitly specify we don't want to use thread-safe functions])
499 fi
500
501 dnl for recent AIX versions, we skip all the thread-safe checks above since
502 dnl they claim a thread-safe libc using the standard API. But there are
503 dnl some functions still not thread-safe. Check for these!
504
505 dnl Let's hope this split URL remains working:
506 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
507 dnl genprogc/thread_quick_ref.htm
508
509 if test "x$RECENTAIX" = "xyes"; then
510
511   AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
512
513 fi
514
515
516 dnl **********************************************************************
517 dnl Back to "normal" configuring
518 dnl **********************************************************************
519
520 dnl Checks for header files.
521 AC_HEADER_STDC
522
523 CURL_CHECK_HEADER_MALLOC
524
525 dnl check for a few basic system headers we need
526 AC_CHECK_HEADERS(
527        sys/types.h \
528        sys/time.h \
529        sys/select.h \
530        sys/socket.h \
531        sys/ioctl.h \
532        sys/param.h \
533        netdb.h \
534        netinet/in.h \
535        netinet/tcp.h \
536        net/if.h \
537        errno.h \
538        strings.h \
539        stdbool.h \
540        time.h \
541        arpa/nameser.h \
542        arpa/nameser_compat.h \
543        arpa/inet.h,
544 dnl to do if not found
545 [],
546 dnl to do if found
547 [],
548 dnl default includes
549 [
550 #ifdef HAVE_SYS_TYPES_H
551 #include <sys/types.h>
552 #endif
553 #ifdef HAVE_SYS_TIME_H
554 #include <sys/time.h>
555 #endif
556 dnl We do this default-include simply to make sure that the nameser_compat.h
557 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
558 dnl (and others?) is not designed to allow this.
559 #ifdef HAVE_ARPA_NAMESER_H
560 #include <arpa/nameser.h>
561 #endif
562
563 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
564 #ifdef HAVE_SYS_SOCKET_H
565 #include <sys/socket.h>
566 #endif
567 #ifdef HAVE_NETINET_IN_H
568 #include <netinet/in.h>
569 #endif
570 ]
571 )
572
573 dnl Checks for typedefs, structures, and compiler characteristics.
574 AC_C_CONST
575 AC_TYPE_SIZE_T
576 AC_HEADER_TIME
577 CURL_CHECK_STRUCT_TIMEVAL
578
579 AC_CHECK_SIZEOF(size_t)
580 AC_CHECK_SIZEOF(long)
581 AC_CHECK_SIZEOF(time_t)
582
583 AC_CHECK_TYPE(long long,
584    [AC_DEFINE(HAVE_LONGLONG, 1, [if your compiler supports long long])]
585    longlong="yes"  
586 )
587
588 if test "xyes" = "x$longlong"; then
589   AC_MSG_CHECKING([if numberLL works])
590   AC_COMPILE_IFELSE([long long val = 1000LL;],
591    [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
592    AC_MSG_RESULT(yes),
593    AC_MSG_RESULT(no)
594   )
595 fi
596
597
598 # check for ssize_t
599 AC_CHECK_TYPE(ssize_t, ,
600    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
601
602 # check for bool type
603 AC_CHECK_TYPE([bool],[
604   AC_DEFINE(HAVE_BOOL_T, 1,
605     [Define to 1 if bool is an available type.])
606 ], ,[
607 #ifdef HAVE_SYS_TYPES_H
608 #include <sys/types.h>
609 #endif
610 #ifdef HAVE_STDBOOL_H
611 #include <stdbool.h>
612 #endif
613 ])
614
615 # Check for socklen_t or equivalent
616 CURL_CHECK_TYPE_SOCKLEN_T
617
618 TYPE_IN_ADDR_T
619
620 TYPE_SOCKADDR_STORAGE
621
622 TYPE_SIG_ATOMIC_T
623
624 AC_TYPE_SIGNAL
625
626 CURL_CHECK_FUNC_RECV
627 CURL_CHECK_FUNC_RECVFROM
628 CURL_CHECK_FUNC_SEND
629 CURL_CHECK_MSG_NOSIGNAL
630
631 dnl check for AF_INET6
632 CARES_CHECK_CONSTANT(
633   [
634 #undef inline
635 #ifdef HAVE_WINDOWS_H
636 #ifndef WIN32_LEAN_AND_MEAN
637 #define WIN32_LEAN_AND_MEAN
638 #endif
639 #include <windows.h>
640 #ifdef HAVE_WINSOCK2_H
641 #include <winsock2.h>
642 #endif
643 #else
644 #ifdef HAVE_SYS_TYPES_H
645 #include <sys/types.h>
646 #endif
647 #ifdef HAVE_SYS_SOCKET_H
648 #include <sys/socket.h>
649 #endif
650 #endif
651   ], [PF_INET6], 
652      AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
653 )
654
655 dnl check for PF_INET6
656 CARES_CHECK_CONSTANT(
657   [
658 #undef inline
659 #ifdef HAVE_WINDOWS_H
660 #ifndef WIN32_LEAN_AND_MEAN
661 #define WIN32_LEAN_AND_MEAN
662 #endif
663 #include <windows.h>
664 #ifdef HAVE_WINSOCK2_H
665 #include <winsock2.h>
666 #endif
667 #else
668 #ifdef HAVE_SYS_TYPES_H
669 #include <sys/types.h>
670 #endif
671 #ifdef HAVE_SYS_SOCKET_H
672 #include <sys/socket.h>
673 #endif
674 #endif
675   ], [AF_INET6], 
676      AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
677 )
678
679
680 dnl check for the in6_addr structure
681 CARES_CHECK_STRUCT(
682   [
683 #undef inline
684 #ifdef HAVE_WINDOWS_H
685 #ifndef WIN32_LEAN_AND_MEAN
686 #define WIN32_LEAN_AND_MEAN
687 #endif
688 #include <windows.h>
689 #ifdef HAVE_WINSOCK2_H
690 #include <winsock2.h>
691 #ifdef HAVE_WS2TCPIP_H
692 #include <ws2tcpip.h>
693 #endif
694 #endif
695 #else
696 #ifdef HAVE_SYS_TYPES_H
697 #include <sys/types.h>
698 #endif
699 #ifdef HAVE_NETINET_IN_H
700 #include <netinet/in.h>
701 #endif
702 #endif
703   ], [in6_addr], 
704      AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
705 )
706
707 dnl check for the sockaddr_in6 structure
708 CARES_CHECK_STRUCT(
709   [
710 #undef inline
711 #ifdef HAVE_WINDOWS_H
712 #ifndef WIN32_LEAN_AND_MEAN
713 #define WIN32_LEAN_AND_MEAN
714 #endif
715 #include <windows.h>
716 #ifdef HAVE_WINSOCK2_H
717 #include <winsock2.h>
718 #ifdef HAVE_WS2TCPIP_H
719 #include <ws2tcpip.h>
720 #endif
721 #endif
722 #else
723 #ifdef HAVE_SYS_TYPES_H
724 #include <sys/types.h>
725 #endif
726 #ifdef HAVE_NETINET_IN_H
727 #include <netinet/in.h>
728 #endif
729 #endif
730   ], [sockaddr_in6], 
731      AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
732        [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
733 )
734
735 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
736     AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
737       [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
738    , ,
739   [
740 #undef inline
741 #ifdef HAVE_WINDOWS_H
742 #ifndef WIN32_LEAN_AND_MEAN
743 #define WIN32_LEAN_AND_MEAN
744 #endif
745 #include <windows.h>
746 #ifdef HAVE_WINSOCK2_H
747 #include <winsock2.h>
748 #ifdef HAVE_WS2TCPIP_H
749 #include <ws2tcpip.h>
750 #endif
751 #endif
752 #else
753 #ifdef HAVE_SYS_TYPES_H
754 #include <sys/types.h>
755 #endif
756 #ifdef HAVE_NETINET_IN_H
757 #include <netinet/in.h>
758 #endif
759 #endif
760   ])
761
762 dnl check for the addrinfo structure
763 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
764      AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
765        [Define to 1 if you have struct addrinfo.]),,
766   [
767 #undef inline
768 #ifdef HAVE_WINDOWS_H
769 #ifndef WIN32_LEAN_AND_MEAN
770 #define WIN32_LEAN_AND_MEAN
771 #endif
772 #include <windows.h>
773 #ifdef HAVE_WINSOCK2_H
774 #include <winsock2.h>
775 #ifdef HAVE_WS2TCPIP_H
776 #include <ws2tcpip.h>
777 #endif
778 #endif
779 #else
780 #ifdef HAVE_SYS_TYPES_H
781 #include <sys/types.h>
782 #endif
783 #ifdef HAVE_NETINET_IN_H
784 #include <netinet/in.h>
785 #endif
786 #ifdef HAVE_SYS_SOCKET_H
787 #include <sys/socket.h>
788 #endif
789 #ifdef HAVE_NETDB_H
790 #include <netdb.h>
791 #endif
792 #endif
793   ]
794 )
795
796
797 AC_CHECK_FUNCS([bitncmp \
798   gettimeofday \
799   if_indextoname
800 ],[
801 ],[
802   func="$ac_func"
803   AC_MSG_CHECKING([deeper for $func])
804   AC_LINK_IFELSE([
805     AC_LANG_PROGRAM([[
806     ]],[[
807       $func ();
808     ]])
809   ],[
810     AC_MSG_RESULT([yes])
811     eval "ac_cv_func_$func=yes"
812     AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$func])], [1],
813       [Define to 1 if you have the $func function.])
814   ],[
815     AC_MSG_RESULT([but still no])
816   ])
817 ])
818
819
820 dnl check for inet_pton
821 AC_CHECK_FUNCS(inet_pton)
822 dnl Some systems have it, but not IPv6
823 if test "$ac_cv_func_inet_pton" = "yes" ; then
824 AC_MSG_CHECKING(if inet_pton supports IPv6)
825 AC_TRY_RUN(
826   [
827 #ifdef HAVE_SYS_TYPES_H
828 #include <sys/types.h>
829 #endif
830 #ifdef HAVE_SYS_SOCKET_H
831 #include <sys/socket.h>
832 #endif
833 #ifdef HAVE_NETINET_IN_H
834 #include <netinet/in.h>
835 #endif
836 int main()
837   {
838     struct in6_addr addr6;
839     if (inet_pton(AF_INET6, "::1", &addr6) < 1)
840       exit(1);
841     else
842       exit(0);
843   }
844   ], [
845        AC_MSG_RESULT(yes)
846        AC_DEFINE_UNQUOTED(HAVE_INET_PTON_IPV6,1,[Define to 1 if inet_pton supports IPv6.])
847      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
848 fi
849 dnl Check for inet_net_pton
850 AC_CHECK_FUNCS(inet_net_pton)
851 dnl Again, some systems have it, but not IPv6
852 if test "$ac_cv_func_inet_net_pton" = "yes" ; then
853 AC_MSG_CHECKING(if inet_net_pton supports IPv6)
854 AC_TRY_RUN(
855   [
856 #ifdef HAVE_SYS_TYPES_H
857 #include <sys/types.h>
858 #endif
859 #ifdef HAVE_SYS_SOCKET_H
860 #include <sys/socket.h>
861 #endif
862 #ifdef HAVE_NETINET_IN_H
863 #include <netinet/in.h>
864 #endif
865 int main()
866   {
867     struct in6_addr addr6;
868     if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
869       exit(1);
870     else
871       exit(0);
872   }
873   ], [
874        AC_MSG_RESULT(yes)
875        AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
876      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
877 fi
878
879
880 dnl Check for inet_ntop
881 AC_CHECK_FUNCS(inet_ntop)
882 dnl Again, some systems have it, but not IPv6
883 if test "$ac_cv_func_inet_ntop" = "yes" ; then
884 AC_MSG_CHECKING(if inet_ntop supports IPv6)
885 AC_TRY_RUN(
886   [
887 #ifdef HAVE_SYS_TYPES_H
888 #include <sys/types.h>
889 #endif
890 #ifdef HAVE_SYS_SOCKET_H
891 #include <sys/socket.h>
892 #endif
893 #ifdef HAVE_NETINET_IN_H
894 #include <netinet/in.h>
895 #endif
896 #include <errno.h>
897 int main()
898   {
899     struct in6_addr addr6;
900     char buf[128];
901     if (inet_ntop(AF_INET6, &addr6, buf, 128) == 0 && errno == EAFNOSUPPORT)
902       exit(1);
903     else
904       exit(0);
905   }
906   ], [
907        AC_MSG_RESULT(yes)
908        AC_DEFINE_UNQUOTED(HAVE_INET_NTOP_IPV6,1,
909           [Define to 1 if inet_ntop supports IPv6.])
910      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
911 fi
912
913 AC_CHECK_SIZEOF(struct in6_addr, ,
914 [
915 #undef inline
916 #ifdef HAVE_WINDOWS_H
917 #ifndef WIN32_LEAN_AND_MEAN
918 #define WIN32_LEAN_AND_MEAN
919 #endif
920 #include <windows.h>
921 #ifdef HAVE_WINSOCK2_H
922 #include <winsock2.h>
923 #ifdef HAVE_WS2TCPIP_H
924 #include <ws2tcpip.h>
925 #endif
926 #endif
927 #else
928 #ifdef HAVE_SYS_TYPES_H
929 #include <sys/types.h>
930 #endif
931 #ifdef HAVE_SYS_SOCKET_H
932 #include <sys/socket.h>
933 #endif
934 #ifdef HAVE_NETINET_IN_H
935 #include <netinet/in.h>
936 #endif
937 #endif
938 ]
939 )
940
941 AC_CHECK_SIZEOF(struct in_addr, ,
942 [
943 #undef inline
944 #ifdef HAVE_WINDOWS_H
945 #ifndef WIN32_LEAN_AND_MEAN
946 #define WIN32_LEAN_AND_MEAN
947 #endif
948 #include <windows.h>
949 #ifdef HAVE_WINSOCK2_H
950 #include <winsock2.h>
951 #ifdef HAVE_WS2TCPIP_H
952 #include <ws2tcpip.h>
953 #endif
954 #endif
955 #else
956 #ifdef HAVE_SYS_TYPES_H
957 #include <sys/types.h>
958 #endif
959 #ifdef HAVE_SYS_SOCKET_H
960 #include <sys/socket.h>
961 #endif
962 #ifdef HAVE_NETINET_IN_H
963 #include <netinet/in.h>
964 #endif
965 #endif
966 ]
967 )
968
969
970 dnl Check if the getnameinfo function is available
971 dnl and get the types of five of its arguments.
972 CURL_CHECK_FUNC_GETNAMEINFO
973
974
975 dnl God bless non-standardized functions! We need to see which getservbyport_r
976 dnl variant is available
977 CARES_CHECK_GETSERVBYPORT_R
978
979 CURL_CHECK_NONBLOCKING_SOCKET
980
981 AC_C_BIGENDIAN(
982     [AC_DEFINE(ARES_BIG_ENDIAN, 1,
983       [define this if ares is built for a big endian system])],
984     ,
985     [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
986 )
987
988 dnl Check for user-specified random device
989 AC_ARG_WITH(random,
990 AC_HELP_STRING([--with-random=FILE],
991                [read randomness from FILE (default=/dev/urandom)]),
992     [ RANDOM_FILE="$withval" ],
993     [
994         dnl Check for random device.  If we're cross compiling, we can't
995         dnl check, and it's better to assume it doesn't exist than it is
996         dnl to fail on AC_CHECK_FILE or later.
997         if test "$cross_compiling" = "no"; then
998           AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
999         else
1000           AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
1001         fi
1002         
1003     ]
1004 )
1005 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
1006         AC_SUBST(RANDOM_FILE)
1007         AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
1008         [a suitable file/device to read random data from])
1009 fi
1010
1011 CARES_PRIVATE_LIBS="$LIBS"
1012 AC_SUBST(CARES_PRIVATE_LIBS)
1013
1014 AC_CONFIG_FILES([Makefile libcares.pc])
1015 AC_OUTPUT