3 dnl Version not hardcoded here. Fetched later from ares_version.h
5 [c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares])
7 CARES_OVERRIDE_AUTOCONF
9 AC_CONFIG_SRCDIR([ares_ipv6.h])
10 AM_CONFIG_HEADER([ares_config.h ares_build.h])
13 CARES_CHECK_OPTION_DEBUG
14 CARES_CHECK_OPTION_OPTIMIZE
15 CARES_CHECK_OPTION_WARNINGS
16 CARES_CHECK_OPTION_CURLDEBUG
18 CARES_CHECK_PATH_SEPARATOR_REQUIRED
20 dnl SED is mandatory for configure process and libtool.
21 dnl Set it now, allowing it to be changed later.
22 AC_PATH_PROG([SED], [sed], [not_found],
23 [$PATH:/usr/bin:/usr/local/bin])
24 if test -z "$SED" || test "$SED" = "not_found"; then
25 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
29 dnl GREP is mandatory for configure process and libtool.
30 dnl Set it now, allowing it to be changed later.
31 AC_PATH_PROG([GREP], [grep], [not_found],
32 [$PATH:/usr/bin:/usr/local/bin])
33 if test -z "$GREP" || test "$GREP" = "not_found"; then
34 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
38 dnl EGREP is mandatory for configure process and libtool.
39 dnl Set it now, allowing it to be changed later.
40 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
41 AC_MSG_CHECKING([for egrep])
43 AC_MSG_RESULT([$EGREP])
45 AC_PATH_PROG([EGREP], [egrep], [not_found],
46 [$PATH:/usr/bin:/usr/local/bin])
48 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
49 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
53 dnl AR is mandatory for configure process and libtool.
54 dnl This is target dependant, so check it as a tool.
55 AC_PATH_TOOL([AR], [ar], [not_found],
56 [$PATH:/usr/bin:/usr/local/bin])
57 if test -z "$AR" || test "$AR" = "not_found"; then
58 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
62 dnl Fetch c-ares version from ares_version.h
63 VERSION=`$SED -ne 's/^#define ARES_VERSION_STR "\(.*\)"/\1/p' ${srcdir}/ares_version.h`
64 AM_INIT_AUTOMAKE([c-ares], [$VERSION])
65 AC_MSG_CHECKING([c-ares version])
66 AC_MSG_RESULT([$VERSION])
69 dnl Detect the canonical host and target build environment
73 dnl Get system canonical name
74 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
80 dnl This defines _ALL_SOURCE for AIX
81 CARES_CHECK_AIX_ALL_SOURCE
83 dnl Our configure and build reentrant settings
84 CARES_CONFIGURE_REENTRANT
86 dnl check for how to do large files
91 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
95 dnl support building of Windows DLLs
98 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
99 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
101 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
113 dnl **********************************************************************
114 dnl platform/compiler/architecture specific checks/flags
115 dnl **********************************************************************
118 CARES_SET_COMPILER_BASIC_OPTS
119 CARES_SET_COMPILER_DEBUG_OPTS
120 CARES_SET_COMPILER_OPTIMIZE_OPTS
121 CARES_SET_COMPILER_WARNING_OPTS
125 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
127 if test "$compiler_id" = "INTEL_UNIX_C"; then
129 if test "$compiler_num" -ge "900" &&
130 test "$compiler_num" -lt "1000"; then
132 CFLAGS="$CFLAGS -i-dynamic"
135 if test "$compiler_num" -ge "1000"; then
136 dnl icc 10.X or later
137 CFLAGS="$CFLAGS -shared-intel"
145 CARES_CHECK_COMPILER_HALT_ON_ERROR
146 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
148 CARES_CHECK_NO_UNDEFINED
149 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
151 CARES_CHECK_CURLDEBUG
152 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
154 dnl **********************************************************************
155 dnl Compilation based checks should not be done before this point.
156 dnl **********************************************************************
158 dnl **********************************************************************
159 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
160 dnl and ws2tcpip.h take precedence over any other further checks which
161 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
162 dnl this specific header files. And do them before its results are used.
163 dnl **********************************************************************
165 CURL_CHECK_HEADER_WINDOWS
166 CURL_CHECK_NATIVE_WINDOWS
167 case X-"$ac_cv_native_windows" in
169 CURL_CHECK_HEADER_WINSOCK
170 CURL_CHECK_HEADER_WINSOCK2
171 CURL_CHECK_HEADER_WS2TCPIP
174 ac_cv_header_winsock_h="no"
175 ac_cv_header_winsock2_h="no"
176 ac_cv_header_ws2tcpip_h="no"
180 dnl **********************************************************************
181 dnl Checks for libraries.
182 dnl **********************************************************************
186 dnl gethostbyname without lib or in the nsl lib?
187 AC_CHECK_FUNC(gethostbyname,
188 [HAVE_GETHOSTBYNAME="1"
190 [ AC_CHECK_LIB(nsl, gethostbyname,
191 [HAVE_GETHOSTBYNAME="1"
196 if test "$HAVE_GETHOSTBYNAME" != "1"
198 dnl gethostbyname in the socket lib?
199 AC_CHECK_LIB(socket, gethostbyname,
200 [HAVE_GETHOSTBYNAME="1"
201 LIBS="$LIBS -lsocket"
205 dnl At least one system has been identified to require BOTH nsl and socket
206 dnl libs at the same time to link properly.
207 if test "$HAVE_GETHOSTBYNAME" != "1"
209 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
210 my_ac_save_LIBS=$LIBS
211 LIBS="-lnsl -lsocket $LIBS"
219 HAVE_GETHOSTBYNAME="1"
222 LIBS=$my_ac_save_LIBS
226 if test "$HAVE_GETHOSTBYNAME" != "1"
228 dnl This is for winsock systems
229 if test "$ac_cv_header_windows_h" = "yes"; then
230 if test "$ac_cv_header_winsock_h" = "yes"; then
233 winsock_LIB="-lwinsock"
236 winsock_LIB="-lwsock32"
240 if test "$ac_cv_header_winsock2_h" = "yes"; then
241 winsock_LIB="-lws2_32"
243 if test ! -z "$winsock_LIB"; then
244 my_ac_save_LIBS=$LIBS
245 LIBS="$winsock_LIB $LIBS"
246 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
249 #ifdef HAVE_WINDOWS_H
250 #ifndef WIN32_LEAN_AND_MEAN
251 #define WIN32_LEAN_AND_MEAN
254 #ifdef HAVE_WINSOCK2_H
255 #include <winsock2.h>
257 #ifdef HAVE_WINSOCK_H
263 gethostbyname("www.dummysite.com");
267 HAVE_GETHOSTBYNAME="1"
271 LIBS=$my_ac_save_LIBS
277 if test "$HAVE_GETHOSTBYNAME" != "1"
279 dnl This is for Minix 3.1
280 AC_MSG_CHECKING([for gethostbyname for Minix 3])
283 /* Older Minix versions may need <net/gen/netdb.h> here instead */
286 gethostbyname("www.dummysite.com");
290 HAVE_GETHOSTBYNAME="1"
296 if test "$HAVE_GETHOSTBYNAME" != "1"
298 dnl This is for eCos with a stubbed DNS implementation
299 AC_MSG_CHECKING([for gethostbyname for eCos])
305 gethostbyname("www.dummysite.com");
309 HAVE_GETHOSTBYNAME="1"
315 if test "$HAVE_GETHOSTBYNAME" != "1"
317 dnl gethostbyname in the net lib - for BeOS
318 AC_CHECK_LIB(net, gethostbyname,
319 [HAVE_GETHOSTBYNAME="1"
325 if test "$HAVE_GETHOSTBYNAME" != "1"; then
326 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
330 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
332 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
333 AC_CHECK_LIB(resolve, strcasecmp,
334 [LIBS="-lresolve $LIBS"],
338 ac_cv_func_strcasecmp="no"
340 CARES_CHECK_LIBS_CONNECT
342 dnl **********************************************************************
343 dnl In case that function clock_gettime with monotonic timer is available,
344 dnl check for additional required libraries.
345 dnl **********************************************************************
346 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
348 AC_MSG_CHECKING([whether to use libgcc])
349 AC_ARG_ENABLE(libgcc,
350 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
351 [ case "$enableval" in
363 dnl Default is to try the thread-safe versions of a few functions
366 dnl detect AIX 4.3 or later
367 AC_MSG_CHECKING([AIX 4.3 or later])
369 #if defined(_AIX) && defined(_AIX43)
372 #error "this is not AIX 4.3 or later"
375 [ AC_MSG_RESULT([yes])
378 [ AC_MSG_RESULT([no]) ]
381 AC_ARG_ENABLE(thread,dnl
382 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
383 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
384 [ case "$enableval" in
387 AC_MSG_WARN(c-ares will not get built using thread-safe functions)
395 if test X"$OPT_THREAD" = Xoff
397 AC_DEFINE(DISABLED_THREADSAFE, 1,
398 [Set to explicitly specify we don't want to use thread-safe functions])
401 dnl for recent AIX versions, we skip all the thread-safe checks above since
402 dnl they claim a thread-safe libc using the standard API. But there are
403 dnl some functions still not thread-safe. Check for these!
405 dnl Let's hope this split URL remains working:
406 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
407 dnl genprogc/thread_quick_ref.htm
409 if test "x$RECENTAIX" = "xyes"; then
411 AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
416 dnl **********************************************************************
417 dnl Back to "normal" configuring
418 dnl **********************************************************************
420 dnl Checks for header files.
423 CURL_CHECK_HEADER_MALLOC
424 CURL_CHECK_HEADER_MEMORY
426 dnl check for a few basic system headers we need
446 arpa/nameser_compat.h \
448 dnl to do if not found
454 #ifdef HAVE_SYS_TYPES_H
455 #include <sys/types.h>
457 #ifdef HAVE_SYS_TIME_H
458 #include <sys/time.h>
460 dnl We do this default-include simply to make sure that the nameser_compat.h
461 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
462 dnl (and others?) is not designed to allow this.
463 #ifdef HAVE_ARPA_NAMESER_H
464 #include <arpa/nameser.h>
467 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
468 #ifdef HAVE_SYS_SOCKET_H
469 #include <sys/socket.h>
471 #ifdef HAVE_NETINET_IN_H
472 #include <netinet/in.h>
477 dnl Checks for typedefs, structures, and compiler characteristics.
481 CURL_CHECK_STRUCT_TIMEVAL
483 AC_CHECK_SIZEOF(size_t)
485 AC_CHECK_SIZEOF(long)
487 AC_CHECK_SIZEOF(time_t)
489 AC_CHECK_TYPE(long long,
490 [AC_DEFINE(HAVE_LONGLONG, 1,
491 [Define to 1 if the compiler supports the 'long long' data type.])]
495 if test "xyes" = "x$longlong"; then
496 AC_MSG_CHECKING([if numberLL works])
497 AC_COMPILE_IFELSE([long long val = 1000LL;],
498 [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
506 AC_CHECK_TYPE(ssize_t, ,
507 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
509 # check for bool type
510 AC_CHECK_TYPE([bool],[
511 AC_DEFINE(HAVE_BOOL_T, 1,
512 [Define to 1 if bool is an available type.])
514 #ifdef HAVE_SYS_TYPES_H
515 #include <sys/types.h>
517 #ifdef HAVE_STDBOOL_H
522 CARES_CONFIGURE_ARES_SOCKLEN_T
526 TYPE_SOCKADDR_STORAGE
533 CURL_CHECK_FUNC_RECVFROM
535 CURL_CHECK_MSG_NOSIGNAL
537 CARES_CHECK_FUNC_CLOSESOCKET
538 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
539 CARES_CHECK_FUNC_CONNECT
540 CARES_CHECK_FUNC_FCNTL
541 CARES_CHECK_FUNC_FREEADDRINFO
542 CARES_CHECK_FUNC_GETADDRINFO
543 CARES_CHECK_FUNC_GETHOSTBYADDR
544 CARES_CHECK_FUNC_GETHOSTBYNAME
545 CARES_CHECK_FUNC_GETHOSTNAME
546 CARES_CHECK_FUNC_GETSERVBYPORT_R
547 CARES_CHECK_FUNC_INET_NTOP
548 CARES_CHECK_FUNC_INET_PTON
549 CARES_CHECK_FUNC_IOCTL
550 CARES_CHECK_FUNC_IOCTLSOCKET
551 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
552 CARES_CHECK_FUNC_SETSOCKOPT
553 CARES_CHECK_FUNC_SOCKET
554 CARES_CHECK_FUNC_STRCASECMP
555 CARES_CHECK_FUNC_STRCMPI
556 CARES_CHECK_FUNC_STRDUP
557 CARES_CHECK_FUNC_STRICMP
558 CARES_CHECK_FUNC_STRNCASECMP
559 CARES_CHECK_FUNC_STRNCMPI
560 CARES_CHECK_FUNC_STRNICMP
561 CARES_CHECK_FUNC_WRITEV
564 dnl check for AF_INET6
565 CARES_CHECK_CONSTANT(
568 #ifdef HAVE_WINDOWS_H
569 #ifndef WIN32_LEAN_AND_MEAN
570 #define WIN32_LEAN_AND_MEAN
573 #ifdef HAVE_WINSOCK2_H
574 #include <winsock2.h>
577 #ifdef HAVE_SYS_TYPES_H
578 #include <sys/types.h>
580 #ifdef HAVE_SYS_SOCKET_H
581 #include <sys/socket.h>
585 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
588 dnl check for PF_INET6
589 CARES_CHECK_CONSTANT(
592 #ifdef HAVE_WINDOWS_H
593 #ifndef WIN32_LEAN_AND_MEAN
594 #define WIN32_LEAN_AND_MEAN
597 #ifdef HAVE_WINSOCK2_H
598 #include <winsock2.h>
601 #ifdef HAVE_SYS_TYPES_H
602 #include <sys/types.h>
604 #ifdef HAVE_SYS_SOCKET_H
605 #include <sys/socket.h>
609 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
613 dnl check for the in6_addr structure
617 #ifdef HAVE_WINDOWS_H
618 #ifndef WIN32_LEAN_AND_MEAN
619 #define WIN32_LEAN_AND_MEAN
622 #ifdef HAVE_WINSOCK2_H
623 #include <winsock2.h>
624 #ifdef HAVE_WS2TCPIP_H
625 #include <ws2tcpip.h>
629 #ifdef HAVE_SYS_TYPES_H
630 #include <sys/types.h>
632 #ifdef HAVE_NETINET_IN_H
633 #include <netinet/in.h>
637 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
640 dnl check for the sockaddr_in6 structure
644 #ifdef HAVE_WINDOWS_H
645 #ifndef WIN32_LEAN_AND_MEAN
646 #define WIN32_LEAN_AND_MEAN
649 #ifdef HAVE_WINSOCK2_H
650 #include <winsock2.h>
651 #ifdef HAVE_WS2TCPIP_H
652 #include <ws2tcpip.h>
656 #ifdef HAVE_SYS_TYPES_H
657 #include <sys/types.h>
659 #ifdef HAVE_NETINET_IN_H
660 #include <netinet/in.h>
664 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
665 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
668 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
669 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
670 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
674 #ifdef HAVE_WINDOWS_H
675 #ifndef WIN32_LEAN_AND_MEAN
676 #define WIN32_LEAN_AND_MEAN
679 #ifdef HAVE_WINSOCK2_H
680 #include <winsock2.h>
681 #ifdef HAVE_WS2TCPIP_H
682 #include <ws2tcpip.h>
686 #ifdef HAVE_SYS_TYPES_H
687 #include <sys/types.h>
689 #ifdef HAVE_NETINET_IN_H
690 #include <netinet/in.h>
695 dnl check for the addrinfo structure
696 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
697 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
698 [Define to 1 if you have struct addrinfo.]),,
701 #ifdef HAVE_WINDOWS_H
702 #ifndef WIN32_LEAN_AND_MEAN
703 #define WIN32_LEAN_AND_MEAN
706 #ifdef HAVE_WINSOCK2_H
707 #include <winsock2.h>
708 #ifdef HAVE_WS2TCPIP_H
709 #include <ws2tcpip.h>
713 #ifdef HAVE_SYS_TYPES_H
714 #include <sys/types.h>
716 #ifdef HAVE_NETINET_IN_H
717 #include <netinet/in.h>
719 #ifdef HAVE_SYS_SOCKET_H
720 #include <sys/socket.h>
730 AC_CHECK_FUNCS([bitncmp \
736 AC_MSG_CHECKING([deeper for $func])
744 eval "ac_cv_func_$func=yes"
745 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$func]), [1],
746 [Define to 1 if you have the $func function.])
748 AC_MSG_RESULT([but still no])
753 dnl Check for inet_net_pton
754 AC_CHECK_FUNCS(inet_net_pton)
755 dnl Again, some systems have it, but not IPv6
756 if test "$ac_cv_func_inet_net_pton" = "yes" ; then
757 AC_MSG_CHECKING(if inet_net_pton supports IPv6)
760 #ifdef HAVE_SYS_TYPES_H
761 #include <sys/types.h>
763 #ifdef HAVE_SYS_SOCKET_H
764 #include <sys/socket.h>
766 #ifdef HAVE_NETINET_IN_H
767 #include <netinet/in.h>
771 struct in6_addr addr6;
772 if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
779 AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
780 ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
784 AC_CHECK_SIZEOF(struct in6_addr, ,
787 #ifdef HAVE_WINDOWS_H
788 #ifndef WIN32_LEAN_AND_MEAN
789 #define WIN32_LEAN_AND_MEAN
792 #ifdef HAVE_WINSOCK2_H
793 #include <winsock2.h>
794 #ifdef HAVE_WS2TCPIP_H
795 #include <ws2tcpip.h>
799 #ifdef HAVE_SYS_TYPES_H
800 #include <sys/types.h>
802 #ifdef HAVE_SYS_SOCKET_H
803 #include <sys/socket.h>
805 #ifdef HAVE_NETINET_IN_H
806 #include <netinet/in.h>
812 AC_CHECK_SIZEOF(struct in_addr, ,
815 #ifdef HAVE_WINDOWS_H
816 #ifndef WIN32_LEAN_AND_MEAN
817 #define WIN32_LEAN_AND_MEAN
820 #ifdef HAVE_WINSOCK2_H
821 #include <winsock2.h>
822 #ifdef HAVE_WS2TCPIP_H
823 #include <ws2tcpip.h>
827 #ifdef HAVE_SYS_TYPES_H
828 #include <sys/types.h>
830 #ifdef HAVE_SYS_SOCKET_H
831 #include <sys/socket.h>
833 #ifdef HAVE_NETINET_IN_H
834 #include <netinet/in.h>
841 dnl Check if the getnameinfo function is available
842 dnl and get the types of five of its arguments.
843 CURL_CHECK_FUNC_GETNAMEINFO
847 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
848 [define this if ares is built for a big endian system])],
850 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
853 dnl Check for user-specified random device
855 AC_HELP_STRING([--with-random=FILE],
856 [read randomness from FILE (default=/dev/urandom)]),
857 [ RANDOM_FILE="$withval" ],
859 dnl Check for random device. If we're cross compiling, we can't
860 dnl check, and it's better to assume it doesn't exist than it is
861 dnl to fail on AC_CHECK_FILE or later.
862 if test "$cross_compiling" = "no"; then
863 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
865 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
870 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
871 AC_SUBST(RANDOM_FILE)
872 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
873 [a suitable file/device to read random data from])
876 CARES_CHECK_OPTION_NONBLOCKING
877 CARES_CHECK_NONBLOCKING_SOCKET
879 CARES_PRIVATE_LIBS="$LIBS"
880 AC_SUBST(CARES_PRIVATE_LIBS)
882 dnl squeeze whitespace out of some variables
890 squeeze CARES_PRIVATE_LIBS
892 AC_CONFIG_FILES([Makefile libcares.pc])