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([config.h])
13 CARES_CHECK_OPTION_DEBUG
14 CARES_CHECK_OPTION_OPTIMIZE
15 CARES_CHECK_OPTION_WARNINGS
17 CARES_CHECK_PATH_SEPARATOR
19 dnl SED is mandatory for configure process and libtool.
20 dnl Set it now, allowing it to be changed later.
21 AC_PATH_PROG([SED], [sed], [not_found],
22 [$PATH:/usr/bin:/usr/local/bin])
23 if test -z "$SED" || test "$SED" = "not_found"; then
24 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
28 dnl GREP is mandatory for configure process and libtool.
29 dnl Set it now, allowing it to be changed later.
30 AC_PATH_PROG([GREP], [grep], [not_found],
31 [$PATH:/usr/bin:/usr/local/bin])
32 if test -z "$GREP" || test "$GREP" = "not_found"; then
33 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
37 dnl EGREP is mandatory for configure process and libtool.
38 dnl Set it now, allowing it to be changed later.
39 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
40 AC_MSG_CHECKING([for egrep])
42 AC_MSG_RESULT([$EGREP])
44 AC_PATH_PROG([EGREP], [egrep], [not_found],
45 [$PATH:/usr/bin:/usr/local/bin])
47 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
48 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
52 dnl AR is mandatory for configure process and libtool.
53 dnl This is target dependant, so check it as a tool.
54 AC_PATH_TOOL([AR], [ar], [not_found],
55 [$PATH:/usr/bin:/usr/local/bin])
56 if test -z "$AR" || test "$AR" = "not_found"; then
57 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
61 dnl Fetch c-ares version from ares_version.h
62 VERSION=`$SED -ne 's/^#define ARES_VERSION_STR "\(.*\)"/\1/p' ${srcdir}/ares_version.h`
63 AM_INIT_AUTOMAKE([c-ares], [$VERSION])
64 AC_MSG_CHECKING([c-ares version])
65 AC_MSG_RESULT([$VERSION])
68 dnl Detect the canonical host and target build environment
72 dnl Get system canonical name
73 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
79 dnl This defines _ALL_SOURCE for AIX
80 CARES_CHECK_AIX_ALL_SOURCE
82 dnl Our configure and build reentrant settings
83 CARES_CONFIGURE_REENTRANT
85 dnl check for how to do large files
90 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
94 dnl support building of Windows DLLs
97 CARES_PROCESS_DEBUG_BUILD_OPTS
99 AM_CONDITIONAL(DEBUGBUILD, test x$want_debug = xyes)
100 AM_CONDITIONAL(CURLDEBUG, test x$want_debug = xyes)
102 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
103 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
105 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
117 AC_MSG_CHECKING([if we need -no-undefined])
119 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
120 need_no_undefined=yes
126 AC_MSG_RESULT($need_no_undefined)
127 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
129 dnl **********************************************************************
130 dnl platform/compiler/architecture specific checks/flags
131 dnl **********************************************************************
134 CARES_SET_COMPILER_BASIC_OPTS
135 CARES_SET_COMPILER_DEBUG_OPTS
136 CARES_SET_COMPILER_OPTIMIZE_OPTS
137 CARES_SET_COMPILER_WARNING_OPTS
141 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
143 if test "$compiler_id" = "INTEL_UNIX_C"; then
145 if test "$compiler_num" -ge "900" &&
146 test "$compiler_num" -lt "1000"; then
148 CFLAGS="$CFLAGS -i-dynamic"
151 if test "$compiler_num" -ge "1000"; then
152 dnl icc 10.X or later
153 CFLAGS="$CFLAGS -shared-intel"
161 CURL_CHECK_COMPILER_HALT_ON_ERROR
162 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
164 dnl **********************************************************************
165 dnl Compilation based checks should not be done before this point.
166 dnl **********************************************************************
168 dnl **********************************************************************
169 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
170 dnl and ws2tcpip.h take precedence over any other further checks which
171 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
172 dnl this specific header files. And do them before its results are used.
173 dnl **********************************************************************
175 CURL_CHECK_HEADER_WINDOWS
176 CURL_CHECK_NATIVE_WINDOWS
177 case X-"$ac_cv_native_windows" in
179 CURL_CHECK_HEADER_WINSOCK
180 CURL_CHECK_HEADER_WINSOCK2
181 CURL_CHECK_HEADER_WS2TCPIP
184 ac_cv_header_winsock_h="no"
185 ac_cv_header_winsock2_h="no"
186 ac_cv_header_ws2tcpip_h="no"
190 dnl **********************************************************************
191 dnl Checks for libraries.
192 dnl **********************************************************************
194 dnl gethostbyname without lib or in the nsl lib?
195 AC_CHECK_FUNC(gethostbyname,
196 [HAVE_GETHOSTBYNAME="1"
198 [ AC_CHECK_LIB(nsl, gethostbyname,
199 [HAVE_GETHOSTBYNAME="1"
204 if test "$HAVE_GETHOSTBYNAME" != "1"
206 dnl gethostbyname in the socket lib?
207 AC_CHECK_LIB(socket, gethostbyname,
208 [HAVE_GETHOSTBYNAME="1"
209 LIBS="$LIBS -lsocket"
213 dnl At least one system has been identified to require BOTH nsl and socket
214 dnl libs at the same time to link properly.
215 if test "$HAVE_GETHOSTBYNAME" != "1"
217 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
218 my_ac_save_LIBS=$LIBS
219 LIBS="-lnsl -lsocket $LIBS"
227 HAVE_GETHOSTBYNAME="1"
230 LIBS=$my_ac_save_LIBS
234 if test "$HAVE_GETHOSTBYNAME" != "1"
236 dnl This is for winsock systems
237 if test "$ac_cv_header_windows_h" = "yes"; then
238 if test "$ac_cv_header_winsock_h" = "yes"; then
241 winsock_LIB="-lwinsock"
244 winsock_LIB="-lwsock32"
248 if test "$ac_cv_header_winsock2_h" = "yes"; then
249 winsock_LIB="-lws2_32"
251 if test ! -z "$winsock_LIB"; then
252 my_ac_save_LIBS=$LIBS
253 LIBS="$winsock_LIB $LIBS"
254 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
257 #ifdef HAVE_WINDOWS_H
258 #ifndef WIN32_LEAN_AND_MEAN
259 #define WIN32_LEAN_AND_MEAN
262 #ifdef HAVE_WINSOCK2_H
263 #include <winsock2.h>
265 #ifdef HAVE_WINSOCK_H
271 gethostbyname("www.dummysite.com");
275 HAVE_GETHOSTBYNAME="1"
279 LIBS=$my_ac_save_LIBS
285 if test "$HAVE_GETHOSTBYNAME" != "1"
287 dnl This is for Minix 3.1
288 AC_MSG_CHECKING([for gethostbyname for Minix 3])
291 /* Older Minix versions may need <net/gen/netdb.h> here instead */
294 gethostbyname("www.dummysite.com");
298 HAVE_GETHOSTBYNAME="1"
304 if test "$HAVE_GETHOSTBYNAME" != "1"
306 dnl This is for eCos with a stubbed DNS implementation
307 AC_MSG_CHECKING([for gethostbyname for eCos])
313 gethostbyname("www.dummysite.com");
317 HAVE_GETHOSTBYNAME="1"
323 if test "$HAVE_GETHOSTBYNAME" != "1"
325 dnl gethostbyname in the net lib - for BeOS
326 AC_CHECK_LIB(net, gethostbyname,
327 [HAVE_GETHOSTBYNAME="1"
333 if test "$HAVE_GETHOSTBYNAME" != "1"; then
334 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
338 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
340 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
341 AC_CHECK_LIB(resolve, strcasecmp,
342 [LIBS="-lresolve $LIBS"],
346 ac_cv_func_strcasecmp="no"
349 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
351 dnl **********************************************************************
352 dnl In case that function clock_gettime with monotonic timer is available,
353 dnl check for additional required libraries.
354 dnl **********************************************************************
355 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
357 AC_MSG_CHECKING([whether to use libgcc])
358 AC_ARG_ENABLE(libgcc,
359 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
360 [ case "$enableval" in
372 dnl Default is to try the thread-safe versions of a few functions
375 dnl detect AIX 4.3 or later
376 AC_MSG_CHECKING([AIX 4.3 or later])
378 #if defined(_AIX) && defined(_AIX43)
381 #error "this is not AIX 4.3 or later"
384 [ AC_MSG_RESULT([yes])
387 [ AC_MSG_RESULT([no]) ]
390 AC_ARG_ENABLE(thread,dnl
391 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
392 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
393 [ case "$enableval" in
396 AC_MSG_WARN(c-ares will not get built using thread-safe functions)
404 if test X"$OPT_THREAD" = Xoff
406 AC_DEFINE(DISABLED_THREADSAFE, 1,
407 [Set to explicitly specify we don't want to use thread-safe functions])
410 dnl for recent AIX versions, we skip all the thread-safe checks above since
411 dnl they claim a thread-safe libc using the standard API. But there are
412 dnl some functions still not thread-safe. Check for these!
414 dnl Let's hope this split URL remains working:
415 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
416 dnl genprogc/thread_quick_ref.htm
418 if test "x$RECENTAIX" = "xyes"; then
420 AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
425 dnl **********************************************************************
426 dnl Back to "normal" configuring
427 dnl **********************************************************************
429 dnl Checks for header files.
432 CURL_CHECK_HEADER_MALLOC
434 dnl check for a few basic system headers we need
453 arpa/nameser_compat.h \
455 dnl to do if not found
461 #ifdef HAVE_SYS_TYPES_H
462 #include <sys/types.h>
464 #ifdef HAVE_SYS_TIME_H
465 #include <sys/time.h>
467 dnl We do this default-include simply to make sure that the nameser_compat.h
468 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
469 dnl (and others?) is not designed to allow this.
470 #ifdef HAVE_ARPA_NAMESER_H
471 #include <arpa/nameser.h>
474 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
475 #ifdef HAVE_SYS_SOCKET_H
476 #include <sys/socket.h>
478 #ifdef HAVE_NETINET_IN_H
479 #include <netinet/in.h>
484 dnl Checks for typedefs, structures, and compiler characteristics.
488 CURL_CHECK_STRUCT_TIMEVAL
490 AC_CHECK_SIZEOF(size_t)
491 AC_CHECK_SIZEOF(long)
492 AC_CHECK_SIZEOF(time_t)
494 AC_CHECK_TYPE(long long,
495 [AC_DEFINE(HAVE_LONGLONG, 1,
496 [Define to 1 if the compiler supports the 'long long' data type.])]
500 if test "xyes" = "x$longlong"; then
501 AC_MSG_CHECKING([if numberLL works])
502 AC_COMPILE_IFELSE([long long val = 1000LL;],
503 [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
511 AC_CHECK_TYPE(ssize_t, ,
512 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
514 # check for bool type
515 AC_CHECK_TYPE([bool],[
516 AC_DEFINE(HAVE_BOOL_T, 1,
517 [Define to 1 if bool is an available type.])
519 #ifdef HAVE_SYS_TYPES_H
520 #include <sys/types.h>
522 #ifdef HAVE_STDBOOL_H
527 # Check for socklen_t or equivalent
528 CURL_CHECK_TYPE_SOCKLEN_T
532 TYPE_SOCKADDR_STORAGE
539 CURL_CHECK_FUNC_RECVFROM
541 CURL_CHECK_MSG_NOSIGNAL
543 CARES_CHECK_FUNC_FCNTL
544 CARES_CHECK_FUNC_FREEADDRINFO
545 CARES_CHECK_FUNC_GETADDRINFO
546 CARES_CHECK_FUNC_GETHOSTBYADDR
547 CARES_CHECK_FUNC_GETHOSTBYNAME
548 CARES_CHECK_FUNC_GETHOSTNAME
549 CARES_CHECK_FUNC_GETSERVBYPORT_R
550 CARES_CHECK_FUNC_INET_NTOP
551 CARES_CHECK_FUNC_INET_PTON
552 CARES_CHECK_FUNC_IOCTL
553 CARES_CHECK_FUNC_IOCTLSOCKET
554 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
555 CARES_CHECK_FUNC_SETSOCKOPT
556 CARES_CHECK_FUNC_STRCASECMP
557 CARES_CHECK_FUNC_STRCMPI
558 CARES_CHECK_FUNC_STRDUP
559 CARES_CHECK_FUNC_STRICMP
560 CARES_CHECK_FUNC_STRNCASECMP
561 CARES_CHECK_FUNC_STRNCMPI
562 CARES_CHECK_FUNC_STRNICMP
563 CARES_CHECK_FUNC_WRITEV
566 dnl check for AF_INET6
567 CARES_CHECK_CONSTANT(
570 #ifdef HAVE_WINDOWS_H
571 #ifndef WIN32_LEAN_AND_MEAN
572 #define WIN32_LEAN_AND_MEAN
575 #ifdef HAVE_WINSOCK2_H
576 #include <winsock2.h>
579 #ifdef HAVE_SYS_TYPES_H
580 #include <sys/types.h>
582 #ifdef HAVE_SYS_SOCKET_H
583 #include <sys/socket.h>
587 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
590 dnl check for PF_INET6
591 CARES_CHECK_CONSTANT(
594 #ifdef HAVE_WINDOWS_H
595 #ifndef WIN32_LEAN_AND_MEAN
596 #define WIN32_LEAN_AND_MEAN
599 #ifdef HAVE_WINSOCK2_H
600 #include <winsock2.h>
603 #ifdef HAVE_SYS_TYPES_H
604 #include <sys/types.h>
606 #ifdef HAVE_SYS_SOCKET_H
607 #include <sys/socket.h>
611 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
615 dnl check for the in6_addr 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_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
642 dnl check for the sockaddr_in6 structure
646 #ifdef HAVE_WINDOWS_H
647 #ifndef WIN32_LEAN_AND_MEAN
648 #define WIN32_LEAN_AND_MEAN
651 #ifdef HAVE_WINSOCK2_H
652 #include <winsock2.h>
653 #ifdef HAVE_WS2TCPIP_H
654 #include <ws2tcpip.h>
658 #ifdef HAVE_SYS_TYPES_H
659 #include <sys/types.h>
661 #ifdef HAVE_NETINET_IN_H
662 #include <netinet/in.h>
666 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
667 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
670 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
671 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
672 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
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>
697 dnl check for the addrinfo structure
698 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
699 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
700 [Define to 1 if you have struct addrinfo.]),,
703 #ifdef HAVE_WINDOWS_H
704 #ifndef WIN32_LEAN_AND_MEAN
705 #define WIN32_LEAN_AND_MEAN
708 #ifdef HAVE_WINSOCK2_H
709 #include <winsock2.h>
710 #ifdef HAVE_WS2TCPIP_H
711 #include <ws2tcpip.h>
715 #ifdef HAVE_SYS_TYPES_H
716 #include <sys/types.h>
718 #ifdef HAVE_NETINET_IN_H
719 #include <netinet/in.h>
721 #ifdef HAVE_SYS_SOCKET_H
722 #include <sys/socket.h>
732 AC_CHECK_FUNCS([bitncmp \
738 AC_MSG_CHECKING([deeper for $func])
746 eval "ac_cv_func_$func=yes"
747 AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$func])], [1],
748 [Define to 1 if you have the $func function.])
750 AC_MSG_RESULT([but still no])
755 dnl Check for inet_net_pton
756 AC_CHECK_FUNCS(inet_net_pton)
757 dnl Again, some systems have it, but not IPv6
758 if test "$ac_cv_func_inet_net_pton" = "yes" ; then
759 AC_MSG_CHECKING(if inet_net_pton supports IPv6)
762 #ifdef HAVE_SYS_TYPES_H
763 #include <sys/types.h>
765 #ifdef HAVE_SYS_SOCKET_H
766 #include <sys/socket.h>
768 #ifdef HAVE_NETINET_IN_H
769 #include <netinet/in.h>
773 struct in6_addr addr6;
774 if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
781 AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
782 ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
786 AC_CHECK_SIZEOF(struct in6_addr, ,
789 #ifdef HAVE_WINDOWS_H
790 #ifndef WIN32_LEAN_AND_MEAN
791 #define WIN32_LEAN_AND_MEAN
794 #ifdef HAVE_WINSOCK2_H
795 #include <winsock2.h>
796 #ifdef HAVE_WS2TCPIP_H
797 #include <ws2tcpip.h>
801 #ifdef HAVE_SYS_TYPES_H
802 #include <sys/types.h>
804 #ifdef HAVE_SYS_SOCKET_H
805 #include <sys/socket.h>
807 #ifdef HAVE_NETINET_IN_H
808 #include <netinet/in.h>
814 AC_CHECK_SIZEOF(struct in_addr, ,
817 #ifdef HAVE_WINDOWS_H
818 #ifndef WIN32_LEAN_AND_MEAN
819 #define WIN32_LEAN_AND_MEAN
822 #ifdef HAVE_WINSOCK2_H
823 #include <winsock2.h>
824 #ifdef HAVE_WS2TCPIP_H
825 #include <ws2tcpip.h>
829 #ifdef HAVE_SYS_TYPES_H
830 #include <sys/types.h>
832 #ifdef HAVE_SYS_SOCKET_H
833 #include <sys/socket.h>
835 #ifdef HAVE_NETINET_IN_H
836 #include <netinet/in.h>
843 dnl Check if the getnameinfo function is available
844 dnl and get the types of five of its arguments.
845 CURL_CHECK_FUNC_GETNAMEINFO
849 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
850 [define this if ares is built for a big endian system])],
852 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
855 dnl Check for user-specified random device
857 AC_HELP_STRING([--with-random=FILE],
858 [read randomness from FILE (default=/dev/urandom)]),
859 [ RANDOM_FILE="$withval" ],
861 dnl Check for random device. If we're cross compiling, we can't
862 dnl check, and it's better to assume it doesn't exist than it is
863 dnl to fail on AC_CHECK_FILE or later.
864 if test "$cross_compiling" = "no"; then
865 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
867 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
872 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
873 AC_SUBST(RANDOM_FILE)
874 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
875 [a suitable file/device to read random data from])
878 CARES_CHECK_OPTION_NONBLOCKING
879 CARES_CHECK_NONBLOCKING_SOCKET
881 CARES_PRIVATE_LIBS="$LIBS"
882 AC_SUBST(CARES_PRIVATE_LIBS)
884 dnl squeeze whitespace out of some variables
892 squeeze CARES_PRIVATE_LIBS
894 AC_CONFIG_FILES([Makefile libcares.pc])