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_WERROR
17 CARES_CHECK_OPTION_CURLDEBUG
18 CARES_CHECK_OPTION_SYMBOL_HIDING
20 CARES_CHECK_PATH_SEPARATOR_REQUIRED
22 dnl SED is mandatory for configure process and libtool.
23 dnl Set it now, allowing it to be changed later.
24 AC_PATH_PROG([SED], [sed], [not_found],
25 [$PATH:/usr/bin:/usr/local/bin])
26 if test -z "$SED" || test "$SED" = "not_found"; then
27 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
31 dnl GREP is mandatory for configure process and libtool.
32 dnl Set it now, allowing it to be changed later.
33 AC_PATH_PROG([GREP], [grep], [not_found],
34 [$PATH:/usr/bin:/usr/local/bin])
35 if test -z "$GREP" || test "$GREP" = "not_found"; then
36 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
40 dnl EGREP is mandatory for configure process and libtool.
41 dnl Set it now, allowing it to be changed later.
42 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
43 AC_MSG_CHECKING([for egrep])
45 AC_MSG_RESULT([$EGREP])
47 AC_PATH_PROG([EGREP], [egrep], [not_found],
48 [$PATH:/usr/bin:/usr/local/bin])
50 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
51 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
55 dnl AR is mandatory for configure process and libtool.
56 dnl This is target dependent, so check it as a tool.
57 AC_PATH_TOOL([AR], [ar], [not_found],
58 [$PATH:/usr/bin:/usr/local/bin])
59 if test -z "$AR" || test "$AR" = "not_found"; then
60 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
64 dnl Remove non-configure distributed ares_build.h
65 if test -f ${srcdir}/ares_build.h; then
66 rm -f ${srcdir}/ares_build.h
69 dnl Fetch c-ares version from ares_version.h
70 VERSION=`$SED -ne 's/^#define ARES_VERSION_STR "\(.*\)"/\1/p' ${srcdir}/ares_version.h`
71 AM_INIT_AUTOMAKE([c-ares], [$VERSION])
72 AC_MSG_CHECKING([c-ares version])
73 AC_MSG_RESULT([$VERSION])
76 dnl Detect the canonical host and target build environment
80 dnl Get system canonical name
81 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
87 dnl This defines _ALL_SOURCE for AIX
88 CARES_CHECK_AIX_ALL_SOURCE
90 dnl Our configure and build reentrant settings
91 CARES_CONFIGURE_THREAD_SAFE
92 CARES_CONFIGURE_REENTRANT
94 dnl check for how to do large files
99 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
103 dnl support building of Windows DLLs
106 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
107 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
109 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
118 AC_MSG_CHECKING([if compiler is icc (to build with PIC)])
132 AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY])
135 AC_DEFINE(CARES_BUILDING_LIBRARY, 1, [when building c-ares library])
137 AC_MSG_CHECKING([if we need CARES_STATICLIB])
138 if test "X$enable_shared" = "Xno"
140 AC_DEFINE(CARES_STATICLIB, 1, [when not building a shared library])
151 dnl **********************************************************************
152 dnl platform/compiler/architecture specific checks/flags
153 dnl **********************************************************************
156 CARES_SET_COMPILER_BASIC_OPTS
157 CARES_SET_COMPILER_DEBUG_OPTS
158 CARES_SET_COMPILER_OPTIMIZE_OPTS
159 CARES_SET_COMPILER_WARNING_OPTS
161 if test "$compiler_id" = "INTEL_UNIX_C"; then
163 if test "$compiler_num" -ge "1000"; then
164 dnl icc 10.X or later
165 CFLAGS="$CFLAGS -shared-intel"
166 elif test "$compiler_num" -ge "900"; then
168 CFLAGS="$CFLAGS -i-dynamic"
173 CARES_CHECK_COMPILER_HALT_ON_ERROR
174 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
175 CARES_CHECK_COMPILER_SYMBOL_HIDING
177 CARES_CHECK_NO_UNDEFINED
178 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
180 CARES_CHECK_CURLDEBUG
181 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
183 dnl **********************************************************************
184 dnl Compilation based checks should not be done before this point.
185 dnl **********************************************************************
187 dnl **********************************************************************
188 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
189 dnl and ws2tcpip.h take precedence over any other further checks which
190 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
191 dnl this specific header files. And do them before its results are used.
192 dnl **********************************************************************
194 CURL_CHECK_HEADER_WINDOWS
195 CURL_CHECK_NATIVE_WINDOWS
196 case X-"$ac_cv_native_windows" in
198 CURL_CHECK_HEADER_WINSOCK
199 CURL_CHECK_HEADER_WINSOCK2
200 CURL_CHECK_HEADER_WS2TCPIP
203 ac_cv_header_winsock_h="no"
204 ac_cv_header_winsock2_h="no"
205 ac_cv_header_ws2tcpip_h="no"
209 dnl **********************************************************************
210 dnl Checks for libraries.
211 dnl **********************************************************************
215 dnl gethostbyname without lib or in the nsl lib?
216 AC_CHECK_FUNC(gethostbyname,
217 [HAVE_GETHOSTBYNAME="1"
219 [ AC_CHECK_LIB(nsl, gethostbyname,
220 [HAVE_GETHOSTBYNAME="1"
225 if test "$HAVE_GETHOSTBYNAME" != "1"
227 dnl gethostbyname in the socket lib?
228 AC_CHECK_LIB(socket, gethostbyname,
229 [HAVE_GETHOSTBYNAME="1"
230 LIBS="$LIBS -lsocket"
234 dnl At least one system has been identified to require BOTH nsl and socket
235 dnl libs at the same time to link properly.
236 if test "$HAVE_GETHOSTBYNAME" != "1"
238 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
239 my_ac_save_LIBS=$LIBS
240 LIBS="-lnsl -lsocket $LIBS"
248 HAVE_GETHOSTBYNAME="1"
251 LIBS=$my_ac_save_LIBS
255 if test "$HAVE_GETHOSTBYNAME" != "1"
257 dnl This is for winsock systems
258 if test "$ac_cv_header_windows_h" = "yes"; then
259 if test "$ac_cv_header_winsock_h" = "yes"; then
262 winsock_LIB="-lwinsock"
265 winsock_LIB="-lwsock32"
269 if test "$ac_cv_header_winsock2_h" = "yes"; then
270 winsock_LIB="-lws2_32"
272 if test ! -z "$winsock_LIB"; then
273 my_ac_save_LIBS=$LIBS
274 LIBS="$winsock_LIB $LIBS"
275 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
278 #ifdef HAVE_WINDOWS_H
279 #ifndef WIN32_LEAN_AND_MEAN
280 #define WIN32_LEAN_AND_MEAN
283 #ifdef HAVE_WINSOCK2_H
284 #include <winsock2.h>
286 #ifdef HAVE_WINSOCK_H
292 gethostbyname("www.dummysite.com");
296 HAVE_GETHOSTBYNAME="1"
300 LIBS=$my_ac_save_LIBS
306 if test "$HAVE_GETHOSTBYNAME" != "1"
308 dnl This is for Minix 3.1
309 AC_MSG_CHECKING([for gethostbyname for Minix 3])
312 /* Older Minix versions may need <net/gen/netdb.h> here instead */
315 gethostbyname("www.dummysite.com");
319 HAVE_GETHOSTBYNAME="1"
325 if test "$HAVE_GETHOSTBYNAME" != "1"
327 dnl This is for eCos with a stubbed DNS implementation
328 AC_MSG_CHECKING([for gethostbyname for eCos])
334 gethostbyname("www.dummysite.com");
338 HAVE_GETHOSTBYNAME="1"
344 if test "$HAVE_GETHOSTBYNAME" != "1"
346 dnl gethostbyname in the net lib - for BeOS
347 AC_CHECK_LIB(net, gethostbyname,
348 [HAVE_GETHOSTBYNAME="1"
354 if test "$HAVE_GETHOSTBYNAME" != "1"; then
355 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
359 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
361 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
362 AC_CHECK_LIB(resolve, strcasecmp,
363 [LIBS="-lresolve $LIBS"],
367 ac_cv_func_strcasecmp="no"
369 CARES_CHECK_LIBS_CONNECT
371 dnl **********************************************************************
372 dnl In case that function clock_gettime with monotonic timer is available,
373 dnl check for additional required libraries.
374 dnl **********************************************************************
375 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
377 AC_MSG_CHECKING([whether to use libgcc])
378 AC_ARG_ENABLE(libgcc,
379 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
380 [ case "$enableval" in
392 dnl Let's hope this split URL remains working:
393 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
394 dnl genprogc/thread_quick_ref.htm
397 dnl **********************************************************************
398 dnl Back to "normal" configuring
399 dnl **********************************************************************
401 dnl Checks for header files.
404 CURL_CHECK_HEADER_MALLOC
405 CURL_CHECK_HEADER_MEMORY
407 dnl check for a few basic system headers we need
428 arpa/nameser_compat.h \
430 dnl to do if not found
436 #ifdef HAVE_SYS_TYPES_H
437 #include <sys/types.h>
439 #ifdef HAVE_SYS_TIME_H
440 #include <sys/time.h>
442 dnl We do this default-include simply to make sure that the nameser_compat.h
443 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
444 dnl (and others?) is not designed to allow this.
445 #ifdef HAVE_ARPA_NAMESER_H
446 #include <arpa/nameser.h>
449 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
450 #ifdef HAVE_SYS_SOCKET_H
451 #include <sys/socket.h>
453 #ifdef HAVE_NETINET_IN_H
454 #include <netinet/in.h>
459 dnl Checks for typedefs, structures, and compiler characteristics.
463 CURL_CHECK_STRUCT_TIMEVAL
465 AC_CHECK_SIZEOF(size_t)
467 AC_CHECK_SIZEOF(long)
469 AC_CHECK_SIZEOF(time_t)
471 AC_CHECK_TYPE(long long,
472 [AC_DEFINE(HAVE_LONGLONG, 1,
473 [Define to 1 if the compiler supports the 'long long' data type.])]
477 if test "xyes" = "x$longlong"; then
478 AC_MSG_CHECKING([if numberLL works])
482 long long val = 1000LL;
486 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
494 AC_CHECK_TYPE(ssize_t, ,
495 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
497 # check for bool type
498 AC_CHECK_TYPE([bool],[
499 AC_DEFINE(HAVE_BOOL_T, 1,
500 [Define to 1 if bool is an available type.])
502 #ifdef HAVE_SYS_TYPES_H
503 #include <sys/types.h>
505 #ifdef HAVE_STDBOOL_H
510 CARES_CONFIGURE_ARES_SOCKLEN_T
514 TYPE_SOCKADDR_STORAGE
521 CURL_CHECK_FUNC_RECVFROM
523 CURL_CHECK_MSG_NOSIGNAL
525 CARES_CHECK_FUNC_CLOSESOCKET
526 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
527 CARES_CHECK_FUNC_CONNECT
528 CARES_CHECK_FUNC_FCNTL
529 CARES_CHECK_FUNC_FREEADDRINFO
530 CARES_CHECK_FUNC_GETADDRINFO
531 CARES_CHECK_FUNC_GETHOSTBYADDR
532 CARES_CHECK_FUNC_GETHOSTBYNAME
533 CARES_CHECK_FUNC_GETHOSTNAME
534 CARES_CHECK_FUNC_GETSERVBYPORT_R
535 CARES_CHECK_FUNC_INET_NET_PTON
537 dnl CARES_CHECK_FUNC_INET_NTOP
539 CARES_CHECK_FUNC_INET_PTON
540 CARES_CHECK_FUNC_IOCTL
541 CARES_CHECK_FUNC_IOCTLSOCKET
542 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
543 CARES_CHECK_FUNC_SETSOCKOPT
544 CARES_CHECK_FUNC_SOCKET
545 CARES_CHECK_FUNC_STRCASECMP
546 CARES_CHECK_FUNC_STRCMPI
547 CARES_CHECK_FUNC_STRDUP
548 CARES_CHECK_FUNC_STRICMP
549 CARES_CHECK_FUNC_STRNCASECMP
550 CARES_CHECK_FUNC_STRNCMPI
551 CARES_CHECK_FUNC_STRNICMP
552 CARES_CHECK_FUNC_WRITEV
555 dnl check for AF_INET6
556 CARES_CHECK_CONSTANT(
559 #ifdef HAVE_WINDOWS_H
560 #ifndef WIN32_LEAN_AND_MEAN
561 #define WIN32_LEAN_AND_MEAN
564 #ifdef HAVE_WINSOCK2_H
565 #include <winsock2.h>
568 #ifdef HAVE_SYS_TYPES_H
569 #include <sys/types.h>
571 #ifdef HAVE_SYS_SOCKET_H
572 #include <sys/socket.h>
576 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
579 dnl check for PF_INET6
580 CARES_CHECK_CONSTANT(
583 #ifdef HAVE_WINDOWS_H
584 #ifndef WIN32_LEAN_AND_MEAN
585 #define WIN32_LEAN_AND_MEAN
588 #ifdef HAVE_WINSOCK2_H
589 #include <winsock2.h>
592 #ifdef HAVE_SYS_TYPES_H
593 #include <sys/types.h>
595 #ifdef HAVE_SYS_SOCKET_H
596 #include <sys/socket.h>
600 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
604 dnl check for the in6_addr structure
608 #ifdef HAVE_WINDOWS_H
609 #ifndef WIN32_LEAN_AND_MEAN
610 #define WIN32_LEAN_AND_MEAN
613 #ifdef HAVE_WINSOCK2_H
614 #include <winsock2.h>
615 #ifdef HAVE_WS2TCPIP_H
616 #include <ws2tcpip.h>
620 #ifdef HAVE_SYS_TYPES_H
621 #include <sys/types.h>
623 #ifdef HAVE_NETINET_IN_H
624 #include <netinet/in.h>
628 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
631 dnl check for the sockaddr_in6 structure
635 #ifdef HAVE_WINDOWS_H
636 #ifndef WIN32_LEAN_AND_MEAN
637 #define WIN32_LEAN_AND_MEAN
640 #ifdef HAVE_WINSOCK2_H
641 #include <winsock2.h>
642 #ifdef HAVE_WS2TCPIP_H
643 #include <ws2tcpip.h>
647 #ifdef HAVE_SYS_TYPES_H
648 #include <sys/types.h>
650 #ifdef HAVE_NETINET_IN_H
651 #include <netinet/in.h>
655 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
656 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
659 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
660 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
661 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
665 #ifdef HAVE_WINDOWS_H
666 #ifndef WIN32_LEAN_AND_MEAN
667 #define WIN32_LEAN_AND_MEAN
670 #ifdef HAVE_WINSOCK2_H
671 #include <winsock2.h>
672 #ifdef HAVE_WS2TCPIP_H
673 #include <ws2tcpip.h>
677 #ifdef HAVE_SYS_TYPES_H
678 #include <sys/types.h>
680 #ifdef HAVE_NETINET_IN_H
681 #include <netinet/in.h>
686 dnl check for the addrinfo structure
687 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
688 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
689 [Define to 1 if you have struct addrinfo.]),,
692 #ifdef HAVE_WINDOWS_H
693 #ifndef WIN32_LEAN_AND_MEAN
694 #define WIN32_LEAN_AND_MEAN
697 #ifdef HAVE_WINSOCK2_H
698 #include <winsock2.h>
699 #ifdef HAVE_WS2TCPIP_H
700 #include <ws2tcpip.h>
704 #ifdef HAVE_SYS_TYPES_H
705 #include <sys/types.h>
707 #ifdef HAVE_NETINET_IN_H
708 #include <netinet/in.h>
710 #ifdef HAVE_SYS_SOCKET_H
711 #include <sys/socket.h>
721 AC_CHECK_FUNCS([bitncmp \
727 AC_MSG_CHECKING([deeper for $func])
735 eval "ac_cv_func_$func=yes"
736 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$func]), [1],
737 [Define to 1 if you have the $func function.])
739 AC_MSG_RESULT([but still no])
744 AC_CHECK_SIZEOF(struct in6_addr, ,
747 #ifdef HAVE_WINDOWS_H
748 #ifndef WIN32_LEAN_AND_MEAN
749 #define WIN32_LEAN_AND_MEAN
752 #ifdef HAVE_WINSOCK2_H
753 #include <winsock2.h>
754 #ifdef HAVE_WS2TCPIP_H
755 #include <ws2tcpip.h>
759 #ifdef HAVE_SYS_TYPES_H
760 #include <sys/types.h>
762 #ifdef HAVE_SYS_SOCKET_H
763 #include <sys/socket.h>
765 #ifdef HAVE_NETINET_IN_H
766 #include <netinet/in.h>
772 AC_CHECK_SIZEOF(struct in_addr, ,
775 #ifdef HAVE_WINDOWS_H
776 #ifndef WIN32_LEAN_AND_MEAN
777 #define WIN32_LEAN_AND_MEAN
780 #ifdef HAVE_WINSOCK2_H
781 #include <winsock2.h>
782 #ifdef HAVE_WS2TCPIP_H
783 #include <ws2tcpip.h>
787 #ifdef HAVE_SYS_TYPES_H
788 #include <sys/types.h>
790 #ifdef HAVE_SYS_SOCKET_H
791 #include <sys/socket.h>
793 #ifdef HAVE_NETINET_IN_H
794 #include <netinet/in.h>
801 dnl Check if the getnameinfo function is available
802 dnl and get the types of five of its arguments.
803 CURL_CHECK_FUNC_GETNAMEINFO
807 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
808 [define this if ares is built for a big endian system])],
810 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
813 dnl Check for user-specified random device
815 AC_HELP_STRING([--with-random=FILE],
816 [read randomness from FILE (default=/dev/urandom)]),
817 [ RANDOM_FILE="$withval" ],
819 dnl Check for random device. If we're cross compiling, we can't
820 dnl check, and it's better to assume it doesn't exist than it is
821 dnl to fail on AC_CHECK_FILE or later.
822 if test "$cross_compiling" = "no"; then
823 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
825 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
830 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
831 AC_SUBST(RANDOM_FILE)
832 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
833 [a suitable file/device to read random data from])
836 CARES_CHECK_OPTION_NONBLOCKING
837 CARES_CHECK_NONBLOCKING_SOCKET
839 CARES_CONFIGURE_SYMBOL_HIDING
841 CARES_PRIVATE_LIBS="$LIBS"
842 AC_SUBST(CARES_PRIVATE_LIBS)
844 CARES_CFLAG_EXTRAS=""
845 if test X"$want_werror" = Xyes; then
846 CARES_CFLAG_EXTRAS="-Werror"
848 AC_SUBST(CARES_CFLAG_EXTRAS)
850 dnl squeeze whitespace out of some variables
858 squeeze CARES_PRIVATE_LIBS
860 AC_CONFIG_FILES([Makefile libcares.pc])