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