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