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