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])
11 AC_CONFIG_MACRO_DIR([m4])
14 CARES_CHECK_OPTION_DEBUG
15 CARES_CHECK_OPTION_OPTIMIZE
16 CARES_CHECK_OPTION_WARNINGS
17 CARES_CHECK_OPTION_WERROR
18 CARES_CHECK_OPTION_CURLDEBUG
19 CARES_CHECK_OPTION_SYMBOL_HIDING
21 CARES_CHECK_PATH_SEPARATOR_REQUIRED
23 dnl SED is mandatory for configure process and libtool.
24 dnl Set it now, allowing it to be changed later.
25 AC_PATH_PROG([SED], [sed], [not_found],
26 [$PATH:/usr/bin:/usr/local/bin])
27 if test -z "$SED" || test "$SED" = "not_found"; then
28 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
32 dnl GREP is mandatory for configure process and libtool.
33 dnl Set it now, allowing it to be changed later.
34 AC_PATH_PROG([GREP], [grep], [not_found],
35 [$PATH:/usr/bin:/usr/local/bin])
36 if test -z "$GREP" || test "$GREP" = "not_found"; then
37 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
41 dnl EGREP is mandatory for configure process and libtool.
42 dnl Set it now, allowing it to be changed later.
43 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
44 AC_MSG_CHECKING([for egrep])
46 AC_MSG_RESULT([$EGREP])
48 AC_PATH_PROG([EGREP], [egrep], [not_found],
49 [$PATH:/usr/bin:/usr/local/bin])
51 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
52 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
56 dnl AR is mandatory for configure process and libtool.
57 dnl This is target dependent, so check it as a tool.
58 AC_PATH_TOOL([AR], [ar], [not_found],
59 [$PATH:/usr/bin:/usr/local/bin])
60 if test -z "$AR" || test "$AR" = "not_found"; then
61 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
65 dnl Remove non-configure distributed ares_build.h
66 if test -f ${srcdir}/ares_build.h; then
67 rm -f ${srcdir}/ares_build.h
73 dnl Detect the canonical host and target build environment
77 dnl Get system canonical name
78 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
84 dnl This defines _ALL_SOURCE for AIX
85 CARES_CHECK_AIX_ALL_SOURCE
87 dnl Our configure and build reentrant settings
88 CARES_CONFIGURE_THREAD_SAFE
89 CARES_CONFIGURE_REENTRANT
91 dnl check for how to do large files
96 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
100 dnl support building of Windows DLLs
103 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
104 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
106 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
115 AC_MSG_CHECKING([if compiler is icc (to build with PIC)])
129 AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY])
132 AC_DEFINE(CARES_BUILDING_LIBRARY, 1, [when building c-ares library])
134 AC_MSG_CHECKING([if we need CARES_STATICLIB])
135 if test "X$enable_shared" = "Xno"
137 AC_DEFINE(CARES_STATICLIB, 1, [when not building a shared library])
148 dnl **********************************************************************
149 dnl platform/compiler/architecture specific checks/flags
150 dnl **********************************************************************
153 CARES_SET_COMPILER_BASIC_OPTS
154 CARES_SET_COMPILER_DEBUG_OPTS
155 CARES_SET_COMPILER_OPTIMIZE_OPTS
156 CARES_SET_COMPILER_WARNING_OPTS
158 if test "$compiler_id" = "INTEL_UNIX_C"; then
160 if test "$compiler_num" -ge "1000"; then
161 dnl icc 10.X or later
162 CFLAGS="$CFLAGS -shared-intel"
163 elif test "$compiler_num" -ge "900"; then
165 CFLAGS="$CFLAGS -i-dynamic"
170 CARES_CHECK_COMPILER_HALT_ON_ERROR
171 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
172 CARES_CHECK_COMPILER_SYMBOL_HIDING
174 CARES_CHECK_NO_UNDEFINED
175 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
177 CARES_CHECK_CURLDEBUG
178 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
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 **********************************************************************
212 dnl gethostbyname without lib or in the nsl lib?
213 AC_CHECK_FUNC(gethostbyname,
214 [HAVE_GETHOSTBYNAME="1"
216 [ AC_CHECK_LIB(nsl, gethostbyname,
217 [HAVE_GETHOSTBYNAME="1"
222 if test "$HAVE_GETHOSTBYNAME" != "1"
224 dnl gethostbyname in the socket lib?
225 AC_CHECK_LIB(socket, gethostbyname,
226 [HAVE_GETHOSTBYNAME="1"
227 LIBS="$LIBS -lsocket"
231 dnl At least one system has been identified to require BOTH nsl and socket
232 dnl libs at the same time to link properly.
233 if test "$HAVE_GETHOSTBYNAME" != "1"
235 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
236 my_ac_save_LIBS=$LIBS
237 LIBS="-lnsl -lsocket $LIBS"
245 HAVE_GETHOSTBYNAME="1"
248 LIBS=$my_ac_save_LIBS
252 if test "$HAVE_GETHOSTBYNAME" != "1"
254 dnl This is for winsock systems
255 if test "$ac_cv_header_windows_h" = "yes"; then
256 if test "$ac_cv_header_winsock_h" = "yes"; then
259 winsock_LIB="-lwinsock"
262 winsock_LIB="-lwsock32"
266 if test "$ac_cv_header_winsock2_h" = "yes"; then
267 winsock_LIB="-lws2_32"
269 if test ! -z "$winsock_LIB"; then
270 my_ac_save_LIBS=$LIBS
271 LIBS="$winsock_LIB $LIBS"
272 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
275 #ifdef HAVE_WINDOWS_H
276 #ifndef WIN32_LEAN_AND_MEAN
277 #define WIN32_LEAN_AND_MEAN
280 #ifdef HAVE_WINSOCK2_H
281 #include <winsock2.h>
283 #ifdef HAVE_WINSOCK_H
289 gethostbyname("www.dummysite.com");
293 HAVE_GETHOSTBYNAME="1"
297 LIBS=$my_ac_save_LIBS
303 if test "$HAVE_GETHOSTBYNAME" != "1"
305 dnl This is for Minix 3.1
306 AC_MSG_CHECKING([for gethostbyname for Minix 3])
309 /* Older Minix versions may need <net/gen/netdb.h> here instead */
312 gethostbyname("www.dummysite.com");
316 HAVE_GETHOSTBYNAME="1"
322 if test "$HAVE_GETHOSTBYNAME" != "1"
324 dnl This is for eCos with a stubbed DNS implementation
325 AC_MSG_CHECKING([for gethostbyname for eCos])
331 gethostbyname("www.dummysite.com");
335 HAVE_GETHOSTBYNAME="1"
341 if test "$HAVE_GETHOSTBYNAME" != "1"
343 dnl gethostbyname in the net lib - for BeOS
344 AC_CHECK_LIB(net, gethostbyname,
345 [HAVE_GETHOSTBYNAME="1"
351 if test "$HAVE_GETHOSTBYNAME" != "1"; then
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"
366 CARES_CHECK_LIBS_CONNECT
368 dnl **********************************************************************
369 dnl In case that function clock_gettime with monotonic timer is available,
370 dnl check for additional required libraries.
371 dnl **********************************************************************
372 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
374 AC_MSG_CHECKING([whether to use libgcc])
375 AC_ARG_ENABLE(libgcc,
376 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
377 [ case "$enableval" in
389 dnl Let's hope this split URL remains working:
390 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
391 dnl genprogc/thread_quick_ref.htm
394 dnl **********************************************************************
395 dnl Back to "normal" configuring
396 dnl **********************************************************************
398 dnl Checks for header files.
401 CURL_CHECK_HEADER_MALLOC
402 CURL_CHECK_HEADER_MEMORY
404 dnl check for a few basic system headers we need
425 arpa/nameser_compat.h \
427 dnl to do if not found
433 #ifdef HAVE_SYS_TYPES_H
434 #include <sys/types.h>
436 #ifdef HAVE_SYS_TIME_H
437 #include <sys/time.h>
439 dnl We do this default-include simply to make sure that the nameser_compat.h
440 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
441 dnl (and others?) is not designed to allow this.
442 #ifdef HAVE_ARPA_NAMESER_H
443 #include <arpa/nameser.h>
446 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
447 #ifdef HAVE_SYS_SOCKET_H
448 #include <sys/socket.h>
450 #ifdef HAVE_NETINET_IN_H
451 #include <netinet/in.h>
456 dnl Checks for typedefs, structures, and compiler characteristics.
460 CURL_CHECK_STRUCT_TIMEVAL
462 AC_CHECK_SIZEOF(size_t)
464 AC_CHECK_SIZEOF(long)
466 AC_CHECK_SIZEOF(time_t)
468 AC_CHECK_TYPE(long long,
469 [AC_DEFINE(HAVE_LONGLONG, 1,
470 [Define to 1 if the compiler supports the 'long long' data type.])]
474 if test "xyes" = "x$longlong"; then
475 AC_MSG_CHECKING([if numberLL works])
479 long long val = 1000LL;
483 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
491 AC_CHECK_TYPE(ssize_t, ,
492 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
494 # check for bool type
495 AC_CHECK_TYPE([bool],[
496 AC_DEFINE(HAVE_BOOL_T, 1,
497 [Define to 1 if bool is an available type.])
499 #ifdef HAVE_SYS_TYPES_H
500 #include <sys/types.h>
502 #ifdef HAVE_STDBOOL_H
507 CARES_CONFIGURE_ARES_SOCKLEN_T
511 TYPE_SOCKADDR_STORAGE
518 CURL_CHECK_FUNC_RECVFROM
520 CURL_CHECK_MSG_NOSIGNAL
522 CARES_CHECK_FUNC_CLOSESOCKET
523 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
524 CARES_CHECK_FUNC_CONNECT
525 CARES_CHECK_FUNC_FCNTL
526 CARES_CHECK_FUNC_FREEADDRINFO
527 CARES_CHECK_FUNC_GETADDRINFO
528 CARES_CHECK_FUNC_GETENV
529 CARES_CHECK_FUNC_GETHOSTBYADDR
530 CARES_CHECK_FUNC_GETHOSTBYNAME
531 CARES_CHECK_FUNC_GETHOSTNAME
532 CARES_CHECK_FUNC_GETSERVBYPORT_R
533 CARES_CHECK_FUNC_INET_NET_PTON
534 CARES_CHECK_FUNC_INET_NTOP
535 CARES_CHECK_FUNC_INET_PTON
536 CARES_CHECK_FUNC_IOCTL
537 CARES_CHECK_FUNC_IOCTLSOCKET
538 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
539 CARES_CHECK_FUNC_SETSOCKOPT
540 CARES_CHECK_FUNC_SOCKET
541 CARES_CHECK_FUNC_STRCASECMP
542 CARES_CHECK_FUNC_STRCMPI
543 CARES_CHECK_FUNC_STRDUP
544 CARES_CHECK_FUNC_STRICMP
545 CARES_CHECK_FUNC_STRNCASECMP
546 CARES_CHECK_FUNC_STRNCMPI
547 CARES_CHECK_FUNC_STRNICMP
548 CARES_CHECK_FUNC_WRITEV
551 dnl check for AF_INET6
552 CARES_CHECK_CONSTANT(
555 #ifdef HAVE_WINDOWS_H
556 #ifndef WIN32_LEAN_AND_MEAN
557 #define WIN32_LEAN_AND_MEAN
560 #ifdef HAVE_WINSOCK2_H
561 #include <winsock2.h>
564 #ifdef HAVE_SYS_TYPES_H
565 #include <sys/types.h>
567 #ifdef HAVE_SYS_SOCKET_H
568 #include <sys/socket.h>
572 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
575 dnl check for PF_INET6
576 CARES_CHECK_CONSTANT(
579 #ifdef HAVE_WINDOWS_H
580 #ifndef WIN32_LEAN_AND_MEAN
581 #define WIN32_LEAN_AND_MEAN
584 #ifdef HAVE_WINSOCK2_H
585 #include <winsock2.h>
588 #ifdef HAVE_SYS_TYPES_H
589 #include <sys/types.h>
591 #ifdef HAVE_SYS_SOCKET_H
592 #include <sys/socket.h>
596 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
600 dnl check for the in6_addr structure
604 #ifdef HAVE_WINDOWS_H
605 #ifndef WIN32_LEAN_AND_MEAN
606 #define WIN32_LEAN_AND_MEAN
609 #ifdef HAVE_WINSOCK2_H
610 #include <winsock2.h>
611 #ifdef HAVE_WS2TCPIP_H
612 #include <ws2tcpip.h>
616 #ifdef HAVE_SYS_TYPES_H
617 #include <sys/types.h>
619 #ifdef HAVE_NETINET_IN_H
620 #include <netinet/in.h>
624 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
627 dnl check for the sockaddr_in6 structure
631 #ifdef HAVE_WINDOWS_H
632 #ifndef WIN32_LEAN_AND_MEAN
633 #define WIN32_LEAN_AND_MEAN
636 #ifdef HAVE_WINSOCK2_H
637 #include <winsock2.h>
638 #ifdef HAVE_WS2TCPIP_H
639 #include <ws2tcpip.h>
643 #ifdef HAVE_SYS_TYPES_H
644 #include <sys/types.h>
646 #ifdef HAVE_NETINET_IN_H
647 #include <netinet/in.h>
651 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
652 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
655 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
656 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
657 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
661 #ifdef HAVE_WINDOWS_H
662 #ifndef WIN32_LEAN_AND_MEAN
663 #define WIN32_LEAN_AND_MEAN
666 #ifdef HAVE_WINSOCK2_H
667 #include <winsock2.h>
668 #ifdef HAVE_WS2TCPIP_H
669 #include <ws2tcpip.h>
673 #ifdef HAVE_SYS_TYPES_H
674 #include <sys/types.h>
676 #ifdef HAVE_NETINET_IN_H
677 #include <netinet/in.h>
682 dnl check for the addrinfo structure
683 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
684 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
685 [Define to 1 if you have struct addrinfo.]),,
688 #ifdef HAVE_WINDOWS_H
689 #ifndef WIN32_LEAN_AND_MEAN
690 #define WIN32_LEAN_AND_MEAN
693 #ifdef HAVE_WINSOCK2_H
694 #include <winsock2.h>
695 #ifdef HAVE_WS2TCPIP_H
696 #include <ws2tcpip.h>
700 #ifdef HAVE_SYS_TYPES_H
701 #include <sys/types.h>
703 #ifdef HAVE_NETINET_IN_H
704 #include <netinet/in.h>
706 #ifdef HAVE_SYS_SOCKET_H
707 #include <sys/socket.h>
717 AC_CHECK_FUNCS([bitncmp \
723 AC_MSG_CHECKING([deeper for $func])
731 eval "ac_cv_func_$func=yes"
732 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$func]), [1],
733 [Define to 1 if you have the $func function.])
735 AC_MSG_RESULT([but still no])
740 AC_CHECK_SIZEOF(struct in6_addr, ,
743 #ifdef HAVE_WINDOWS_H
744 #ifndef WIN32_LEAN_AND_MEAN
745 #define WIN32_LEAN_AND_MEAN
748 #ifdef HAVE_WINSOCK2_H
749 #include <winsock2.h>
750 #ifdef HAVE_WS2TCPIP_H
751 #include <ws2tcpip.h>
755 #ifdef HAVE_SYS_TYPES_H
756 #include <sys/types.h>
758 #ifdef HAVE_SYS_SOCKET_H
759 #include <sys/socket.h>
761 #ifdef HAVE_NETINET_IN_H
762 #include <netinet/in.h>
768 AC_CHECK_SIZEOF(struct in_addr, ,
771 #ifdef HAVE_WINDOWS_H
772 #ifndef WIN32_LEAN_AND_MEAN
773 #define WIN32_LEAN_AND_MEAN
776 #ifdef HAVE_WINSOCK2_H
777 #include <winsock2.h>
778 #ifdef HAVE_WS2TCPIP_H
779 #include <ws2tcpip.h>
783 #ifdef HAVE_SYS_TYPES_H
784 #include <sys/types.h>
786 #ifdef HAVE_SYS_SOCKET_H
787 #include <sys/socket.h>
789 #ifdef HAVE_NETINET_IN_H
790 #include <netinet/in.h>
797 dnl Check if the getnameinfo function is available
798 dnl and get the types of five of its arguments.
799 CURL_CHECK_FUNC_GETNAMEINFO
803 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
804 [define this if ares is built for a big endian system])],
806 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
809 dnl Check for user-specified random device
811 AC_HELP_STRING([--with-random=FILE],
812 [read randomness from FILE (default=/dev/urandom)]),
813 [ RANDOM_FILE="$withval" ],
815 dnl Check for random device. If we're cross compiling, we can't
816 dnl check, and it's better to assume it doesn't exist than it is
817 dnl to fail on AC_CHECK_FILE or later.
818 if test "$cross_compiling" = "no"; then
819 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
821 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
826 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
827 AC_SUBST(RANDOM_FILE)
828 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
829 [a suitable file/device to read random data from])
832 CARES_CHECK_OPTION_NONBLOCKING
833 CARES_CHECK_NONBLOCKING_SOCKET
835 CARES_CONFIGURE_SYMBOL_HIDING
837 CARES_PRIVATE_LIBS="$LIBS"
838 AC_SUBST(CARES_PRIVATE_LIBS)
840 CARES_CFLAG_EXTRAS=""
841 if test X"$want_werror" = Xyes; then
842 CARES_CFLAG_EXTRAS="-Werror"
844 AC_SUBST(CARES_CFLAG_EXTRAS)
846 dnl squeeze whitespace out of some variables
854 squeeze CARES_PRIVATE_LIBS
856 AC_CONFIG_FILES([Makefile libcares.pc])