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