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
17 CARES_CHECK_OPTION_SYMBOL_HIDING
19 CARES_CHECK_PATH_SEPARATOR_REQUIRED
21 dnl SED is mandatory for configure process and libtool.
22 dnl Set it now, allowing it to be changed later.
23 AC_PATH_PROG([SED], [sed], [not_found],
24 [$PATH:/usr/bin:/usr/local/bin])
25 if test -z "$SED" || test "$SED" = "not_found"; then
26 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
30 dnl GREP is mandatory for configure process and libtool.
31 dnl Set it now, allowing it to be changed later.
32 AC_PATH_PROG([GREP], [grep], [not_found],
33 [$PATH:/usr/bin:/usr/local/bin])
34 if test -z "$GREP" || test "$GREP" = "not_found"; then
35 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
39 dnl EGREP is mandatory for configure process and libtool.
40 dnl Set it now, allowing it to be changed later.
41 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
42 AC_MSG_CHECKING([for egrep])
44 AC_MSG_RESULT([$EGREP])
46 AC_PATH_PROG([EGREP], [egrep], [not_found],
47 [$PATH:/usr/bin:/usr/local/bin])
49 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
50 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
54 dnl AR is mandatory for configure process and libtool.
55 dnl This is target dependent, so check it as a tool.
56 AC_PATH_TOOL([AR], [ar], [not_found],
57 [$PATH:/usr/bin:/usr/local/bin])
58 if test -z "$AR" || test "$AR" = "not_found"; then
59 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
63 dnl Fetch c-ares version from ares_version.h
64 VERSION=`$SED -ne 's/^#define ARES_VERSION_STR "\(.*\)"/\1/p' ${srcdir}/ares_version.h`
65 AM_INIT_AUTOMAKE([c-ares], [$VERSION])
66 AC_MSG_CHECKING([c-ares version])
67 AC_MSG_RESULT([$VERSION])
70 dnl Detect the canonical host and target build environment
74 dnl Get system canonical name
75 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
81 dnl This defines _ALL_SOURCE for AIX
82 CARES_CHECK_AIX_ALL_SOURCE
84 dnl Our configure and build reentrant settings
85 CARES_CONFIGURE_THREAD_SAFE
86 CARES_CONFIGURE_REENTRANT
88 dnl check for how to do large files
93 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
97 dnl support building of Windows DLLs
100 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
101 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
103 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
115 AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY])
118 AC_DEFINE(CARES_BUILDING_LIBRARY, 1, [when building c-ares library])
120 AC_MSG_CHECKING([if we need CARES_STATICLIB])
121 if test "X$enable_shared" = "Xno"
123 AC_DEFINE(CARES_STATICLIB, 1, [when not building a shared library])
134 dnl **********************************************************************
135 dnl platform/compiler/architecture specific checks/flags
136 dnl **********************************************************************
139 CARES_SET_COMPILER_BASIC_OPTS
140 CARES_SET_COMPILER_DEBUG_OPTS
141 CARES_SET_COMPILER_OPTIMIZE_OPTS
142 CARES_SET_COMPILER_WARNING_OPTS
146 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
148 if test "$compiler_id" = "INTEL_UNIX_C"; then
150 if test "$compiler_num" -ge "900" &&
151 test "$compiler_num" -lt "1000"; then
153 CFLAGS="$CFLAGS -i-dynamic"
156 if test "$compiler_num" -ge "1000"; then
157 dnl icc 10.X or later
158 CFLAGS="$CFLAGS -shared-intel"
166 CARES_CHECK_COMPILER_HALT_ON_ERROR
167 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
168 CARES_CHECK_COMPILER_SYMBOL_HIDING
170 CARES_CHECK_NO_UNDEFINED
171 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
173 CARES_CHECK_CURLDEBUG
174 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
176 dnl **********************************************************************
177 dnl Compilation based checks should not be done before this point.
178 dnl **********************************************************************
180 dnl **********************************************************************
181 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
182 dnl and ws2tcpip.h take precedence over any other further checks which
183 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
184 dnl this specific header files. And do them before its results are used.
185 dnl **********************************************************************
187 CURL_CHECK_HEADER_WINDOWS
188 CURL_CHECK_NATIVE_WINDOWS
189 case X-"$ac_cv_native_windows" in
191 CURL_CHECK_HEADER_WINSOCK
192 CURL_CHECK_HEADER_WINSOCK2
193 CURL_CHECK_HEADER_WS2TCPIP
196 ac_cv_header_winsock_h="no"
197 ac_cv_header_winsock2_h="no"
198 ac_cv_header_ws2tcpip_h="no"
202 dnl **********************************************************************
203 dnl Checks for libraries.
204 dnl **********************************************************************
208 dnl gethostbyname without lib or in the nsl lib?
209 AC_CHECK_FUNC(gethostbyname,
210 [HAVE_GETHOSTBYNAME="1"
212 [ AC_CHECK_LIB(nsl, gethostbyname,
213 [HAVE_GETHOSTBYNAME="1"
218 if test "$HAVE_GETHOSTBYNAME" != "1"
220 dnl gethostbyname in the socket lib?
221 AC_CHECK_LIB(socket, gethostbyname,
222 [HAVE_GETHOSTBYNAME="1"
223 LIBS="$LIBS -lsocket"
227 dnl At least one system has been identified to require BOTH nsl and socket
228 dnl libs at the same time to link properly.
229 if test "$HAVE_GETHOSTBYNAME" != "1"
231 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
232 my_ac_save_LIBS=$LIBS
233 LIBS="-lnsl -lsocket $LIBS"
241 HAVE_GETHOSTBYNAME="1"
244 LIBS=$my_ac_save_LIBS
248 if test "$HAVE_GETHOSTBYNAME" != "1"
250 dnl This is for winsock systems
251 if test "$ac_cv_header_windows_h" = "yes"; then
252 if test "$ac_cv_header_winsock_h" = "yes"; then
255 winsock_LIB="-lwinsock"
258 winsock_LIB="-lwsock32"
262 if test "$ac_cv_header_winsock2_h" = "yes"; then
263 winsock_LIB="-lws2_32"
265 if test ! -z "$winsock_LIB"; then
266 my_ac_save_LIBS=$LIBS
267 LIBS="$winsock_LIB $LIBS"
268 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
271 #ifdef HAVE_WINDOWS_H
272 #ifndef WIN32_LEAN_AND_MEAN
273 #define WIN32_LEAN_AND_MEAN
276 #ifdef HAVE_WINSOCK2_H
277 #include <winsock2.h>
279 #ifdef HAVE_WINSOCK_H
285 gethostbyname("www.dummysite.com");
289 HAVE_GETHOSTBYNAME="1"
293 LIBS=$my_ac_save_LIBS
299 if test "$HAVE_GETHOSTBYNAME" != "1"
301 dnl This is for Minix 3.1
302 AC_MSG_CHECKING([for gethostbyname for Minix 3])
305 /* Older Minix versions may need <net/gen/netdb.h> here instead */
308 gethostbyname("www.dummysite.com");
312 HAVE_GETHOSTBYNAME="1"
318 if test "$HAVE_GETHOSTBYNAME" != "1"
320 dnl This is for eCos with a stubbed DNS implementation
321 AC_MSG_CHECKING([for gethostbyname for eCos])
327 gethostbyname("www.dummysite.com");
331 HAVE_GETHOSTBYNAME="1"
337 if test "$HAVE_GETHOSTBYNAME" != "1"
339 dnl gethostbyname in the net lib - for BeOS
340 AC_CHECK_LIB(net, gethostbyname,
341 [HAVE_GETHOSTBYNAME="1"
347 if test "$HAVE_GETHOSTBYNAME" != "1"; then
348 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
352 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
354 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
355 AC_CHECK_LIB(resolve, strcasecmp,
356 [LIBS="-lresolve $LIBS"],
360 ac_cv_func_strcasecmp="no"
362 CARES_CHECK_LIBS_CONNECT
364 dnl **********************************************************************
365 dnl In case that function clock_gettime with monotonic timer is available,
366 dnl check for additional required libraries.
367 dnl **********************************************************************
368 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
370 AC_MSG_CHECKING([whether to use libgcc])
371 AC_ARG_ENABLE(libgcc,
372 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
373 [ case "$enableval" in
385 dnl Let's hope this split URL remains working:
386 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
387 dnl genprogc/thread_quick_ref.htm
390 dnl **********************************************************************
391 dnl Back to "normal" configuring
392 dnl **********************************************************************
394 dnl Checks for header files.
397 CURL_CHECK_HEADER_MALLOC
398 CURL_CHECK_HEADER_MEMORY
400 dnl check for a few basic system headers we need
421 arpa/nameser_compat.h \
423 dnl to do if not found
429 #ifdef HAVE_SYS_TYPES_H
430 #include <sys/types.h>
432 #ifdef HAVE_SYS_TIME_H
433 #include <sys/time.h>
435 dnl We do this default-include simply to make sure that the nameser_compat.h
436 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
437 dnl (and others?) is not designed to allow this.
438 #ifdef HAVE_ARPA_NAMESER_H
439 #include <arpa/nameser.h>
442 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
443 #ifdef HAVE_SYS_SOCKET_H
444 #include <sys/socket.h>
446 #ifdef HAVE_NETINET_IN_H
447 #include <netinet/in.h>
452 dnl Checks for typedefs, structures, and compiler characteristics.
456 CURL_CHECK_STRUCT_TIMEVAL
458 AC_CHECK_SIZEOF(size_t)
460 AC_CHECK_SIZEOF(long)
462 AC_CHECK_SIZEOF(time_t)
464 AC_CHECK_TYPE(long long,
465 [AC_DEFINE(HAVE_LONGLONG, 1,
466 [Define to 1 if the compiler supports the 'long long' data type.])]
470 if test "xyes" = "x$longlong"; then
471 AC_MSG_CHECKING([if numberLL works])
472 AC_COMPILE_IFELSE([long long val = 1000LL;],
473 [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
481 AC_CHECK_TYPE(ssize_t, ,
482 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
484 # check for bool type
485 AC_CHECK_TYPE([bool],[
486 AC_DEFINE(HAVE_BOOL_T, 1,
487 [Define to 1 if bool is an available type.])
489 #ifdef HAVE_SYS_TYPES_H
490 #include <sys/types.h>
492 #ifdef HAVE_STDBOOL_H
497 CARES_CONFIGURE_ARES_SOCKLEN_T
501 TYPE_SOCKADDR_STORAGE
508 CURL_CHECK_FUNC_RECVFROM
510 CURL_CHECK_MSG_NOSIGNAL
512 CARES_CHECK_FUNC_CLOSESOCKET
513 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
514 CARES_CHECK_FUNC_CONNECT
515 CARES_CHECK_FUNC_FCNTL
516 CARES_CHECK_FUNC_FREEADDRINFO
517 CARES_CHECK_FUNC_GETADDRINFO
518 CARES_CHECK_FUNC_GETHOSTBYADDR
519 CARES_CHECK_FUNC_GETHOSTBYNAME
520 CARES_CHECK_FUNC_GETHOSTNAME
521 CARES_CHECK_FUNC_GETSERVBYPORT_R
522 CARES_CHECK_FUNC_INET_NTOP
523 CARES_CHECK_FUNC_INET_PTON
524 CARES_CHECK_FUNC_IOCTL
525 CARES_CHECK_FUNC_IOCTLSOCKET
526 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
527 CARES_CHECK_FUNC_SETSOCKOPT
528 CARES_CHECK_FUNC_SOCKET
529 CARES_CHECK_FUNC_STRCASECMP
530 CARES_CHECK_FUNC_STRCMPI
531 CARES_CHECK_FUNC_STRDUP
532 CARES_CHECK_FUNC_STRICMP
533 CARES_CHECK_FUNC_STRNCASECMP
534 CARES_CHECK_FUNC_STRNCMPI
535 CARES_CHECK_FUNC_STRNICMP
536 CARES_CHECK_FUNC_WRITEV
539 dnl check for AF_INET6
540 CARES_CHECK_CONSTANT(
543 #ifdef HAVE_WINDOWS_H
544 #ifndef WIN32_LEAN_AND_MEAN
545 #define WIN32_LEAN_AND_MEAN
548 #ifdef HAVE_WINSOCK2_H
549 #include <winsock2.h>
552 #ifdef HAVE_SYS_TYPES_H
553 #include <sys/types.h>
555 #ifdef HAVE_SYS_SOCKET_H
556 #include <sys/socket.h>
560 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
563 dnl check for PF_INET6
564 CARES_CHECK_CONSTANT(
567 #ifdef HAVE_WINDOWS_H
568 #ifndef WIN32_LEAN_AND_MEAN
569 #define WIN32_LEAN_AND_MEAN
572 #ifdef HAVE_WINSOCK2_H
573 #include <winsock2.h>
576 #ifdef HAVE_SYS_TYPES_H
577 #include <sys/types.h>
579 #ifdef HAVE_SYS_SOCKET_H
580 #include <sys/socket.h>
584 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
588 dnl check for the in6_addr structure
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>
599 #ifdef HAVE_WS2TCPIP_H
600 #include <ws2tcpip.h>
604 #ifdef HAVE_SYS_TYPES_H
605 #include <sys/types.h>
607 #ifdef HAVE_NETINET_IN_H
608 #include <netinet/in.h>
612 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
615 dnl check for the sockaddr_in6 structure
619 #ifdef HAVE_WINDOWS_H
620 #ifndef WIN32_LEAN_AND_MEAN
621 #define WIN32_LEAN_AND_MEAN
624 #ifdef HAVE_WINSOCK2_H
625 #include <winsock2.h>
626 #ifdef HAVE_WS2TCPIP_H
627 #include <ws2tcpip.h>
631 #ifdef HAVE_SYS_TYPES_H
632 #include <sys/types.h>
634 #ifdef HAVE_NETINET_IN_H
635 #include <netinet/in.h>
639 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
640 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
643 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
644 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
645 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
649 #ifdef HAVE_WINDOWS_H
650 #ifndef WIN32_LEAN_AND_MEAN
651 #define WIN32_LEAN_AND_MEAN
654 #ifdef HAVE_WINSOCK2_H
655 #include <winsock2.h>
656 #ifdef HAVE_WS2TCPIP_H
657 #include <ws2tcpip.h>
661 #ifdef HAVE_SYS_TYPES_H
662 #include <sys/types.h>
664 #ifdef HAVE_NETINET_IN_H
665 #include <netinet/in.h>
670 dnl check for the addrinfo structure
671 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
672 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
673 [Define to 1 if you have struct addrinfo.]),,
676 #ifdef HAVE_WINDOWS_H
677 #ifndef WIN32_LEAN_AND_MEAN
678 #define WIN32_LEAN_AND_MEAN
681 #ifdef HAVE_WINSOCK2_H
682 #include <winsock2.h>
683 #ifdef HAVE_WS2TCPIP_H
684 #include <ws2tcpip.h>
688 #ifdef HAVE_SYS_TYPES_H
689 #include <sys/types.h>
691 #ifdef HAVE_NETINET_IN_H
692 #include <netinet/in.h>
694 #ifdef HAVE_SYS_SOCKET_H
695 #include <sys/socket.h>
705 AC_CHECK_FUNCS([bitncmp \
711 AC_MSG_CHECKING([deeper for $func])
719 eval "ac_cv_func_$func=yes"
720 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$func]), [1],
721 [Define to 1 if you have the $func function.])
723 AC_MSG_RESULT([but still no])
728 dnl Check for inet_net_pton
729 AC_CHECK_FUNCS(inet_net_pton)
730 dnl Again, some systems have it, but not IPv6
731 if test "$ac_cv_func_inet_net_pton" = "yes" ; then
732 AC_MSG_CHECKING(if inet_net_pton supports IPv6)
735 #ifdef HAVE_SYS_TYPES_H
736 #include <sys/types.h>
738 #ifdef HAVE_SYS_SOCKET_H
739 #include <sys/socket.h>
741 #ifdef HAVE_NETINET_IN_H
742 #include <netinet/in.h>
746 struct in6_addr addr6;
747 if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
754 AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
755 ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
759 AC_CHECK_SIZEOF(struct in6_addr, ,
762 #ifdef HAVE_WINDOWS_H
763 #ifndef WIN32_LEAN_AND_MEAN
764 #define WIN32_LEAN_AND_MEAN
767 #ifdef HAVE_WINSOCK2_H
768 #include <winsock2.h>
769 #ifdef HAVE_WS2TCPIP_H
770 #include <ws2tcpip.h>
774 #ifdef HAVE_SYS_TYPES_H
775 #include <sys/types.h>
777 #ifdef HAVE_SYS_SOCKET_H
778 #include <sys/socket.h>
780 #ifdef HAVE_NETINET_IN_H
781 #include <netinet/in.h>
787 AC_CHECK_SIZEOF(struct in_addr, ,
790 #ifdef HAVE_WINDOWS_H
791 #ifndef WIN32_LEAN_AND_MEAN
792 #define WIN32_LEAN_AND_MEAN
795 #ifdef HAVE_WINSOCK2_H
796 #include <winsock2.h>
797 #ifdef HAVE_WS2TCPIP_H
798 #include <ws2tcpip.h>
802 #ifdef HAVE_SYS_TYPES_H
803 #include <sys/types.h>
805 #ifdef HAVE_SYS_SOCKET_H
806 #include <sys/socket.h>
808 #ifdef HAVE_NETINET_IN_H
809 #include <netinet/in.h>
816 dnl Check if the getnameinfo function is available
817 dnl and get the types of five of its arguments.
818 CURL_CHECK_FUNC_GETNAMEINFO
822 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
823 [define this if ares is built for a big endian system])],
825 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
828 dnl Check for user-specified random device
830 AC_HELP_STRING([--with-random=FILE],
831 [read randomness from FILE (default=/dev/urandom)]),
832 [ RANDOM_FILE="$withval" ],
834 dnl Check for random device. If we're cross compiling, we can't
835 dnl check, and it's better to assume it doesn't exist than it is
836 dnl to fail on AC_CHECK_FILE or later.
837 if test "$cross_compiling" = "no"; then
838 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
840 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
845 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
846 AC_SUBST(RANDOM_FILE)
847 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
848 [a suitable file/device to read random data from])
851 CARES_CHECK_OPTION_NONBLOCKING
852 CARES_CHECK_NONBLOCKING_SOCKET
854 CARES_CONFIGURE_SYMBOL_HIDING
856 CARES_PRIVATE_LIBS="$LIBS"
857 AC_SUBST(CARES_PRIVATE_LIBS)
859 dnl squeeze whitespace out of some variables
867 squeeze CARES_PRIVATE_LIBS
869 AC_CONFIG_FILES([Makefile libcares.pc])