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