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 AC_CONFIG_SRCDIR([ares_ipv6.h])
8 AM_CONFIG_HEADER([config.h])
11 CARES_CHECK_OPTION_DEBUG
12 CARES_CHECK_OPTION_OPTIMIZE
13 CARES_CHECK_OPTION_WARNINGS
15 dnl SED is mandatory for configure process and libtool.
16 dnl Set it now, allowing it to be changed later.
17 AC_PATH_PROG([SED], [sed], [not_found],
18 [$PATH:/usr/bin:/usr/local/bin])
19 if test -z "$SED" || test "$SED" = "not_found"; then
20 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
24 dnl GREP is mandatory for configure process and libtool.
25 dnl Set it now, allowing it to be changed later.
26 AC_PATH_PROG([GREP], [grep], [not_found],
27 [$PATH:/usr/bin:/usr/local/bin])
28 if test -z "$GREP" || test "$GREP" = "not_found"; then
29 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
33 dnl EGREP is mandatory for configure process and libtool.
34 dnl Set it now, allowing it to be changed later.
35 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
36 AC_MSG_CHECKING([for egrep])
38 AC_MSG_RESULT([$EGREP])
40 AC_PATH_PROG([EGREP], [egrep], [not_found],
41 [$PATH:/usr/bin:/usr/local/bin])
43 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
44 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
48 dnl AR is mandatory for configure process and libtool.
49 dnl This is target dependant, so check it as a tool.
50 AC_PATH_TOOL([AR], [ar], [not_found],
51 [$PATH:/usr/bin:/usr/local/bin])
52 if test -z "$AR" || test "$AR" = "not_found"; then
53 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
57 dnl Fetch c-ares version from ares_version.h
58 VERSION=`$SED -ne 's/^#define ARES_VERSION_STR "\(.*\)"/\1/p' ${srcdir}/ares_version.h`
59 AM_INIT_AUTOMAKE([c-ares], [$VERSION])
60 AC_MSG_CHECKING([c-ares version])
61 AC_MSG_RESULT([$VERSION])
64 dnl Detect the canonical host and target build environment
68 dnl Get system canonical name
69 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
75 dnl This defines _ALL_SOURCE for AIX
76 CARES_CHECK_AIX_ALL_SOURCE
78 dnl Our configure and build reentrant settings
79 CARES_CONFIGURE_REENTRANT
81 dnl check for how to do large files
86 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
90 dnl support building of Windows DLLs
93 CARES_PROCESS_DEBUG_BUILD_OPTS
95 AM_CONDITIONAL(DEBUGBUILD, test x$want_debug = xyes)
96 AM_CONDITIONAL(CURLDEBUG, test x$want_debug = xyes)
98 dnl skip libtool C++ and Fortran compiler checks
99 m4_ifdef([AC_PROG_CXX], [m4_undefine([AC_PROG_CXX])])
100 m4_defun([AC_PROG_CXX],[])
101 m4_ifdef([AC_PROG_CXXCPP], [m4_undefine([AC_PROG_CXXCPP])])
102 m4_defun([AC_PROG_CXXCPP],[true])
103 m4_ifdef([AC_PROG_F77], [m4_undefine([AC_PROG_F77])])
104 m4_defun([AC_PROG_F77],[])
106 dnl skip libtool C++ and Fortran linker checks
107 m4_ifdef([AC_LIBTOOL_CXX], [m4_undefine([AC_LIBTOOL_CXX])])
108 m4_defun([AC_LIBTOOL_CXX],[])
109 m4_ifdef([AC_LIBTOOL_CXXCPP], [m4_undefine([AC_LIBTOOL_CXXCPP])])
110 m4_defun([AC_LIBTOOL_CXXCPP],[true])
111 m4_ifdef([AC_LIBTOOL_F77], [m4_undefine([AC_LIBTOOL_F77])])
112 m4_defun([AC_LIBTOOL_F77],[])
114 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
115 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
117 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
133 AC_MSG_CHECKING([if we need -no-undefined])
135 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
136 need_no_undefined=yes
142 AC_MSG_RESULT($need_no_undefined)
143 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
145 dnl **********************************************************************
146 dnl platform/compiler/architecture specific checks/flags
147 dnl **********************************************************************
150 CARES_SET_COMPILER_BASIC_OPTS
151 CARES_SET_COMPILER_DEBUG_OPTS
152 CARES_SET_COMPILER_OPTIMIZE_OPTS
153 CARES_SET_COMPILER_WARNING_OPTS
157 dnl x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
159 if test "$compiler_id" = "INTEL_UNIX_C"; then
161 if test "$compiler_num" -ge "900" &&
162 test "$compiler_num" -lt "1000"; then
164 CFLAGS="$CFLAGS -i-dynamic"
167 if test "$compiler_num" -ge "1000"; then
168 dnl icc 10.X or later
169 CFLAGS="$CFLAGS -shared-intel"
177 CURL_CHECK_COMPILER_HALT_ON_ERROR
178 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
180 dnl **********************************************************************
181 dnl Compilation based checks should not be done before this point.
182 dnl **********************************************************************
184 dnl **********************************************************************
185 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
186 dnl and ws2tcpip.h take precedence over any other further checks which
187 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
188 dnl this specific header files. And do them before its results are used.
189 dnl **********************************************************************
191 CURL_CHECK_HEADER_WINDOWS
192 CURL_CHECK_NATIVE_WINDOWS
193 case X-"$ac_cv_native_windows" in
195 CURL_CHECK_HEADER_WINSOCK
196 CURL_CHECK_HEADER_WINSOCK2
197 CURL_CHECK_HEADER_WS2TCPIP
200 ac_cv_header_winsock_h="no"
201 ac_cv_header_winsock2_h="no"
202 ac_cv_header_ws2tcpip_h="no"
206 dnl **********************************************************************
207 dnl Checks for libraries.
208 dnl **********************************************************************
210 dnl gethostbyname without lib or in the nsl lib?
211 AC_CHECK_FUNC(gethostbyname,
212 [HAVE_GETHOSTBYNAME="1"
214 [ AC_CHECK_LIB(nsl, gethostbyname,
215 [HAVE_GETHOSTBYNAME="1"
220 if test "$HAVE_GETHOSTBYNAME" != "1"
222 dnl gethostbyname in the socket lib?
223 AC_CHECK_LIB(socket, gethostbyname,
224 [HAVE_GETHOSTBYNAME="1"
225 LIBS="$LIBS -lsocket"
229 dnl At least one system has been identified to require BOTH nsl and socket
230 dnl libs at the same time to link properly.
231 if test "$HAVE_GETHOSTBYNAME" != "1"
233 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
234 my_ac_save_LIBS=$LIBS
235 LIBS="-lnsl -lsocket $LIBS"
243 HAVE_GETHOSTBYNAME="1"
246 LIBS=$my_ac_save_LIBS
250 if test "$HAVE_GETHOSTBYNAME" != "1"
252 dnl This is for winsock systems
253 if test "$ac_cv_header_windows_h" = "yes"; then
254 if test "$ac_cv_header_winsock_h" = "yes"; then
257 winsock_LIB="-lwinsock"
260 winsock_LIB="-lwsock32"
264 if test "$ac_cv_header_winsock2_h" = "yes"; then
265 winsock_LIB="-lws2_32"
267 if test ! -z "$winsock_LIB"; then
268 my_ac_save_LIBS=$LIBS
269 LIBS="$winsock_LIB $LIBS"
270 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
273 #ifdef HAVE_WINDOWS_H
274 #ifndef WIN32_LEAN_AND_MEAN
275 #define WIN32_LEAN_AND_MEAN
278 #ifdef HAVE_WINSOCK2_H
279 #include <winsock2.h>
281 #ifdef HAVE_WINSOCK_H
287 gethostbyname("www.dummysite.com");
291 HAVE_GETHOSTBYNAME="1"
295 LIBS=$my_ac_save_LIBS
301 if test "$HAVE_GETHOSTBYNAME" != "1"
303 dnl This is for Minix 3.1
304 AC_MSG_CHECKING([for gethostbyname for Minix 3])
307 /* Older Minix versions may need <net/gen/netdb.h> here instead */
310 gethostbyname("www.dummysite.com");
314 HAVE_GETHOSTBYNAME="1"
320 if test "$HAVE_GETHOSTBYNAME" != "1"
322 dnl This is for eCos with a stubbed DNS implementation
323 AC_MSG_CHECKING([for gethostbyname for eCos])
329 gethostbyname("www.dummysite.com");
333 HAVE_GETHOSTBYNAME="1"
339 if test "$HAVE_GETHOSTBYNAME" != "1"
341 dnl gethostbyname in the net lib - for BeOS
342 AC_CHECK_LIB(net, gethostbyname,
343 [HAVE_GETHOSTBYNAME="1"
349 if test "$HAVE_GETHOSTBYNAME" = "1"; then
350 AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
352 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
356 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
358 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
359 AC_CHECK_LIB(resolve, strcasecmp,
360 [LIBS="-lresolve $LIBS"],
364 ac_cv_func_strcasecmp="no"
367 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
369 dnl **********************************************************************
370 dnl In case that function clock_gettime with monotonic timer is available,
371 dnl check for additional required libraries.
372 dnl **********************************************************************
373 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
375 AC_MSG_CHECKING([whether to use libgcc])
376 AC_ARG_ENABLE(libgcc,
377 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
378 [ case "$enableval" in
390 dnl Default is to try the thread-safe versions of a few functions
393 dnl detect AIX 4.3 or later
394 AC_MSG_CHECKING([AIX 4.3 or later])
396 #if defined(_AIX) && defined(_AIX43)
399 #error "this is not AIX 4.3 or later"
402 [ AC_MSG_RESULT([yes])
405 [ AC_MSG_RESULT([no]) ]
408 AC_ARG_ENABLE(thread,dnl
409 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
410 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
411 [ case "$enableval" in
414 AC_MSG_WARN(c-ares will not get built using thread-safe functions)
422 if test X"$OPT_THREAD" = Xoff
424 AC_DEFINE(DISABLED_THREADSAFE, 1,
425 [Set to explicitly specify we don't want to use thread-safe functions])
428 dnl for recent AIX versions, we skip all the thread-safe checks above since
429 dnl they claim a thread-safe libc using the standard API. But there are
430 dnl some functions still not thread-safe. Check for these!
432 dnl Let's hope this split URL remains working:
433 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
434 dnl genprogc/thread_quick_ref.htm
436 if test "x$RECENTAIX" = "xyes"; then
438 AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
443 dnl **********************************************************************
444 dnl Back to "normal" configuring
445 dnl **********************************************************************
447 dnl Checks for header files.
450 CURL_CHECK_HEADER_MALLOC
452 dnl check for a few basic system headers we need
470 arpa/nameser_compat.h \
472 dnl to do if not found
478 #ifdef HAVE_SYS_TYPES_H
479 #include <sys/types.h>
481 #ifdef HAVE_SYS_TIME_H
482 #include <sys/time.h>
484 dnl We do this default-include simply to make sure that the nameser_compat.h
485 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
486 dnl (and others?) is not designed to allow this.
487 #ifdef HAVE_ARPA_NAMESER_H
488 #include <arpa/nameser.h>
491 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
492 #ifdef HAVE_SYS_SOCKET_H
493 #include <sys/socket.h>
495 #ifdef HAVE_NETINET_IN_H
496 #include <netinet/in.h>
501 dnl Checks for typedefs, structures, and compiler characteristics.
505 CURL_CHECK_STRUCT_TIMEVAL
507 AC_CHECK_SIZEOF(size_t)
508 AC_CHECK_SIZEOF(long)
509 AC_CHECK_SIZEOF(time_t)
511 AC_CHECK_TYPE(long long,
512 [AC_DEFINE(HAVE_LONGLONG, 1,
513 [Define to 1 if the compiler supports the 'long long' data type.])]
517 if test "xyes" = "x$longlong"; then
518 AC_MSG_CHECKING([if numberLL works])
519 AC_COMPILE_IFELSE([long long val = 1000LL;],
520 [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
528 AC_CHECK_TYPE(ssize_t, ,
529 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
531 # check for bool type
532 AC_CHECK_TYPE([bool],[
533 AC_DEFINE(HAVE_BOOL_T, 1,
534 [Define to 1 if bool is an available type.])
536 #ifdef HAVE_SYS_TYPES_H
537 #include <sys/types.h>
539 #ifdef HAVE_STDBOOL_H
544 # Check for socklen_t or equivalent
545 CURL_CHECK_TYPE_SOCKLEN_T
549 TYPE_SOCKADDR_STORAGE
556 CURL_CHECK_FUNC_RECVFROM
558 CURL_CHECK_MSG_NOSIGNAL
560 CARES_CHECK_FUNC_GETHOSTNAME
561 CARES_CHECK_FUNC_GETSERVBYPORT_R
562 CARES_CHECK_FUNC_INET_NTOP
563 CARES_CHECK_FUNC_INET_PTON
564 CARES_CHECK_FUNC_STRCASECMP
565 CARES_CHECK_FUNC_STRCMPI
566 CARES_CHECK_FUNC_STRDUP
567 CARES_CHECK_FUNC_STRICMP
568 CARES_CHECK_FUNC_STRNCASECMP
569 CARES_CHECK_FUNC_STRNCMPI
570 CARES_CHECK_FUNC_STRNICMP
571 CARES_CHECK_FUNC_WRITEV
574 dnl check for AF_INET6
575 CARES_CHECK_CONSTANT(
578 #ifdef HAVE_WINDOWS_H
579 #ifndef WIN32_LEAN_AND_MEAN
580 #define WIN32_LEAN_AND_MEAN
583 #ifdef HAVE_WINSOCK2_H
584 #include <winsock2.h>
587 #ifdef HAVE_SYS_TYPES_H
588 #include <sys/types.h>
590 #ifdef HAVE_SYS_SOCKET_H
591 #include <sys/socket.h>
595 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
598 dnl check for PF_INET6
599 CARES_CHECK_CONSTANT(
602 #ifdef HAVE_WINDOWS_H
603 #ifndef WIN32_LEAN_AND_MEAN
604 #define WIN32_LEAN_AND_MEAN
607 #ifdef HAVE_WINSOCK2_H
608 #include <winsock2.h>
611 #ifdef HAVE_SYS_TYPES_H
612 #include <sys/types.h>
614 #ifdef HAVE_SYS_SOCKET_H
615 #include <sys/socket.h>
619 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
623 dnl check for the in6_addr structure
627 #ifdef HAVE_WINDOWS_H
628 #ifndef WIN32_LEAN_AND_MEAN
629 #define WIN32_LEAN_AND_MEAN
632 #ifdef HAVE_WINSOCK2_H
633 #include <winsock2.h>
634 #ifdef HAVE_WS2TCPIP_H
635 #include <ws2tcpip.h>
639 #ifdef HAVE_SYS_TYPES_H
640 #include <sys/types.h>
642 #ifdef HAVE_NETINET_IN_H
643 #include <netinet/in.h>
647 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
650 dnl check for the sockaddr_in6 structure
654 #ifdef HAVE_WINDOWS_H
655 #ifndef WIN32_LEAN_AND_MEAN
656 #define WIN32_LEAN_AND_MEAN
659 #ifdef HAVE_WINSOCK2_H
660 #include <winsock2.h>
661 #ifdef HAVE_WS2TCPIP_H
662 #include <ws2tcpip.h>
666 #ifdef HAVE_SYS_TYPES_H
667 #include <sys/types.h>
669 #ifdef HAVE_NETINET_IN_H
670 #include <netinet/in.h>
674 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
675 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
678 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
679 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
680 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
684 #ifdef HAVE_WINDOWS_H
685 #ifndef WIN32_LEAN_AND_MEAN
686 #define WIN32_LEAN_AND_MEAN
689 #ifdef HAVE_WINSOCK2_H
690 #include <winsock2.h>
691 #ifdef HAVE_WS2TCPIP_H
692 #include <ws2tcpip.h>
696 #ifdef HAVE_SYS_TYPES_H
697 #include <sys/types.h>
699 #ifdef HAVE_NETINET_IN_H
700 #include <netinet/in.h>
705 dnl check for the addrinfo structure
706 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
707 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
708 [Define to 1 if you have struct addrinfo.]),,
711 #ifdef HAVE_WINDOWS_H
712 #ifndef WIN32_LEAN_AND_MEAN
713 #define WIN32_LEAN_AND_MEAN
716 #ifdef HAVE_WINSOCK2_H
717 #include <winsock2.h>
718 #ifdef HAVE_WS2TCPIP_H
719 #include <ws2tcpip.h>
723 #ifdef HAVE_SYS_TYPES_H
724 #include <sys/types.h>
726 #ifdef HAVE_NETINET_IN_H
727 #include <netinet/in.h>
729 #ifdef HAVE_SYS_SOCKET_H
730 #include <sys/socket.h>
740 AC_CHECK_FUNCS([bitncmp \
746 AC_MSG_CHECKING([deeper for $func])
754 eval "ac_cv_func_$func=yes"
755 AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$func])], [1],
756 [Define to 1 if you have the $func function.])
758 AC_MSG_RESULT([but still no])
763 dnl Check for inet_net_pton
764 AC_CHECK_FUNCS(inet_net_pton)
765 dnl Again, some systems have it, but not IPv6
766 if test "$ac_cv_func_inet_net_pton" = "yes" ; then
767 AC_MSG_CHECKING(if inet_net_pton supports IPv6)
770 #ifdef HAVE_SYS_TYPES_H
771 #include <sys/types.h>
773 #ifdef HAVE_SYS_SOCKET_H
774 #include <sys/socket.h>
776 #ifdef HAVE_NETINET_IN_H
777 #include <netinet/in.h>
781 struct in6_addr addr6;
782 if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
789 AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
790 ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
794 AC_CHECK_SIZEOF(struct in6_addr, ,
797 #ifdef HAVE_WINDOWS_H
798 #ifndef WIN32_LEAN_AND_MEAN
799 #define WIN32_LEAN_AND_MEAN
802 #ifdef HAVE_WINSOCK2_H
803 #include <winsock2.h>
804 #ifdef HAVE_WS2TCPIP_H
805 #include <ws2tcpip.h>
809 #ifdef HAVE_SYS_TYPES_H
810 #include <sys/types.h>
812 #ifdef HAVE_SYS_SOCKET_H
813 #include <sys/socket.h>
815 #ifdef HAVE_NETINET_IN_H
816 #include <netinet/in.h>
822 AC_CHECK_SIZEOF(struct in_addr, ,
825 #ifdef HAVE_WINDOWS_H
826 #ifndef WIN32_LEAN_AND_MEAN
827 #define WIN32_LEAN_AND_MEAN
830 #ifdef HAVE_WINSOCK2_H
831 #include <winsock2.h>
832 #ifdef HAVE_WS2TCPIP_H
833 #include <ws2tcpip.h>
837 #ifdef HAVE_SYS_TYPES_H
838 #include <sys/types.h>
840 #ifdef HAVE_SYS_SOCKET_H
841 #include <sys/socket.h>
843 #ifdef HAVE_NETINET_IN_H
844 #include <netinet/in.h>
851 dnl Check if the getnameinfo function is available
852 dnl and get the types of five of its arguments.
853 CURL_CHECK_FUNC_GETNAMEINFO
856 CURL_CHECK_NONBLOCKING_SOCKET
859 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
860 [define this if ares is built for a big endian system])],
862 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
865 dnl Check for user-specified random device
867 AC_HELP_STRING([--with-random=FILE],
868 [read randomness from FILE (default=/dev/urandom)]),
869 [ RANDOM_FILE="$withval" ],
871 dnl Check for random device. If we're cross compiling, we can't
872 dnl check, and it's better to assume it doesn't exist than it is
873 dnl to fail on AC_CHECK_FILE or later.
874 if test "$cross_compiling" = "no"; then
875 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
877 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
882 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
883 AC_SUBST(RANDOM_FILE)
884 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
885 [a suitable file/device to read random data from])
888 CARES_PRIVATE_LIBS="$LIBS"
889 AC_SUBST(CARES_PRIVATE_LIBS)
891 dnl squeeze whitespace out of some variables
899 squeeze CARES_PRIVATE_LIBS
901 AC_CONFIG_FILES([Makefile libcares.pc])