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])
8 CARES_OVERRIDE_AUTOCONF
10 AC_CONFIG_SRCDIR([ares_ipv6.h])
11 AM_CONFIG_HEADER([ares_config.h ares_build.h])
12 AC_CONFIG_MACRO_DIR([m4])
15 CARES_CHECK_OPTION_DEBUG
16 CARES_CHECK_OPTION_OPTIMIZE
17 CARES_CHECK_OPTION_WARNINGS
18 CARES_CHECK_OPTION_WERROR
19 CARES_CHECK_OPTION_CURLDEBUG
20 CARES_CHECK_OPTION_SYMBOL_HIDING
22 CARES_CHECK_PATH_SEPARATOR_REQUIRED
24 dnl SED is mandatory for configure process and libtool.
25 dnl Set it now, allowing it to be changed later.
26 AC_PATH_PROG([SED], [sed], [not_found],
27 [$PATH:/usr/bin:/usr/local/bin])
28 if test -z "$SED" || test "$SED" = "not_found"; then
29 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
33 dnl GREP is mandatory for configure process and libtool.
34 dnl Set it now, allowing it to be changed later.
35 AC_PATH_PROG([GREP], [grep], [not_found],
36 [$PATH:/usr/bin:/usr/local/bin])
37 if test -z "$GREP" || test "$GREP" = "not_found"; then
38 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
42 dnl EGREP is mandatory for configure process and libtool.
43 dnl Set it now, allowing it to be changed later.
44 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
45 AC_MSG_CHECKING([for egrep])
47 AC_MSG_RESULT([$EGREP])
49 AC_PATH_PROG([EGREP], [egrep], [not_found],
50 [$PATH:/usr/bin:/usr/local/bin])
52 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
53 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
57 dnl AR is mandatory for configure process and libtool.
58 dnl This is target dependent, so check it as a tool.
59 AC_PATH_TOOL([AR], [ar], [not_found],
60 [$PATH:/usr/bin:/usr/local/bin])
61 if test -z "$AR" || test "$AR" = "not_found"; then
62 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
66 dnl Remove non-configure distributed ares_build.h
67 if test -f ${srcdir}/ares_build.h; then
68 rm -f ${srcdir}/ares_build.h
74 dnl Detect the canonical host and target build environment
78 dnl Get system canonical name
79 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
85 dnl This defines _ALL_SOURCE for AIX
86 CARES_CHECK_AIX_ALL_SOURCE
88 dnl Our configure and build reentrant settings
89 CARES_CONFIGURE_THREAD_SAFE
90 CARES_CONFIGURE_REENTRANT
92 dnl check for how to do large files
97 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
101 dnl support building of Windows DLLs
104 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
105 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
107 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
116 AC_MSG_CHECKING([if compiler is icc (to build with PIC)])
130 AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY])
131 use_cppflag_cares_building_library="no"
132 use_cppflag_cares_staticlib="no"
136 use_cppflag_cares_building_library="yes"
137 AC_MSG_CHECKING([if we need CARES_STATICLIB])
138 if test "X$enable_shared" = "Xno"
141 use_cppflag_cares_staticlib="yes"
150 AM_CONDITIONAL(USE_CPPFLAG_CARES_BUILDING_LIBRARY, test x$use_cppflag_cares_building_library = xyes)
151 AM_CONDITIONAL(USE_CPPFLAG_CARES_STATICLIB, test x$use_cppflag_cares_staticlib = xyes)
153 dnl **********************************************************************
154 dnl platform/compiler/architecture specific checks/flags
155 dnl **********************************************************************
158 CARES_SET_COMPILER_BASIC_OPTS
159 CARES_SET_COMPILER_DEBUG_OPTS
160 CARES_SET_COMPILER_OPTIMIZE_OPTS
161 CARES_SET_COMPILER_WARNING_OPTS
163 if test "$compiler_id" = "INTEL_UNIX_C"; then
165 if test "$compiler_num" -ge "1000"; then
166 dnl icc 10.X or later
167 CFLAGS="$CFLAGS -shared-intel"
168 elif test "$compiler_num" -ge "900"; then
170 CFLAGS="$CFLAGS -i-dynamic"
175 CARES_CHECK_COMPILER_HALT_ON_ERROR
176 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
177 CARES_CHECK_COMPILER_SYMBOL_HIDING
179 CARES_CHECK_NO_UNDEFINED
180 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
182 CARES_CHECK_CURLDEBUG
183 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
185 dnl **********************************************************************
186 dnl Compilation based checks should not be done before this point.
187 dnl **********************************************************************
189 dnl **********************************************************************
190 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
191 dnl and ws2tcpip.h take precedence over any other further checks which
192 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
193 dnl this specific header files. And do them before its results are used.
194 dnl **********************************************************************
196 CURL_CHECK_HEADER_WINDOWS
197 CURL_CHECK_NATIVE_WINDOWS
198 case X-"$ac_cv_native_windows" in
200 CURL_CHECK_HEADER_WINSOCK
201 CURL_CHECK_HEADER_WINSOCK2
202 CURL_CHECK_HEADER_WS2TCPIP
205 ac_cv_header_winsock_h="no"
206 ac_cv_header_winsock2_h="no"
207 ac_cv_header_ws2tcpip_h="no"
211 dnl **********************************************************************
212 dnl Checks for libraries.
213 dnl **********************************************************************
217 dnl gethostbyname without lib or in the nsl lib?
218 AC_CHECK_FUNC(gethostbyname,
219 [HAVE_GETHOSTBYNAME="1"
221 [ AC_CHECK_LIB(nsl, gethostbyname,
222 [HAVE_GETHOSTBYNAME="1"
227 if test "$HAVE_GETHOSTBYNAME" != "1"
229 dnl gethostbyname in the socket lib?
230 AC_CHECK_LIB(socket, gethostbyname,
231 [HAVE_GETHOSTBYNAME="1"
232 LIBS="$LIBS -lsocket"
236 dnl At least one system has been identified to require BOTH nsl and socket
237 dnl libs at the same time to link properly.
238 if test "$HAVE_GETHOSTBYNAME" != "1"
240 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
241 my_ac_save_LIBS=$LIBS
242 LIBS="-lnsl -lsocket $LIBS"
250 HAVE_GETHOSTBYNAME="1"
253 LIBS=$my_ac_save_LIBS
257 if test "$HAVE_GETHOSTBYNAME" != "1"
259 dnl This is for winsock systems
260 if test "$ac_cv_header_windows_h" = "yes"; then
261 if test "$ac_cv_header_winsock_h" = "yes"; then
264 winsock_LIB="-lwinsock"
267 winsock_LIB="-lwsock32"
271 if test "$ac_cv_header_winsock2_h" = "yes"; then
272 winsock_LIB="-lws2_32"
274 if test ! -z "$winsock_LIB"; then
275 my_ac_save_LIBS=$LIBS
276 LIBS="$winsock_LIB $LIBS"
277 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
280 #ifdef HAVE_WINDOWS_H
281 #ifndef WIN32_LEAN_AND_MEAN
282 #define WIN32_LEAN_AND_MEAN
285 #ifdef HAVE_WINSOCK2_H
286 #include <winsock2.h>
288 #ifdef HAVE_WINSOCK_H
294 gethostbyname("www.dummysite.com");
298 HAVE_GETHOSTBYNAME="1"
302 LIBS=$my_ac_save_LIBS
308 if test "$HAVE_GETHOSTBYNAME" != "1"
310 dnl This is for Minix 3.1
311 AC_MSG_CHECKING([for gethostbyname for Minix 3])
314 /* Older Minix versions may need <net/gen/netdb.h> here instead */
317 gethostbyname("www.dummysite.com");
321 HAVE_GETHOSTBYNAME="1"
327 if test "$HAVE_GETHOSTBYNAME" != "1"
329 dnl This is for eCos with a stubbed DNS implementation
330 AC_MSG_CHECKING([for gethostbyname for eCos])
336 gethostbyname("www.dummysite.com");
340 HAVE_GETHOSTBYNAME="1"
346 if test "$HAVE_GETHOSTBYNAME" != "1"
348 dnl gethostbyname in the net lib - for BeOS
349 AC_CHECK_LIB(net, gethostbyname,
350 [HAVE_GETHOSTBYNAME="1"
356 if test "$HAVE_GETHOSTBYNAME" != "1"; then
357 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
361 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
363 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
364 AC_CHECK_LIB(resolve, strcasecmp,
365 [LIBS="-lresolve $LIBS"],
369 ac_cv_func_strcasecmp="no"
371 CARES_CHECK_LIBS_CONNECT
373 dnl **********************************************************************
374 dnl In case that function clock_gettime with monotonic timer is available,
375 dnl check for additional required libraries.
376 dnl **********************************************************************
377 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
379 AC_MSG_CHECKING([whether to use libgcc])
380 AC_ARG_ENABLE(libgcc,
381 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
382 [ case "$enableval" in
394 dnl Let's hope this split URL remains working:
395 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
396 dnl genprogc/thread_quick_ref.htm
399 dnl **********************************************************************
400 dnl Back to "normal" configuring
401 dnl **********************************************************************
403 dnl Checks for header files.
406 CURL_CHECK_HEADER_MALLOC
407 CURL_CHECK_HEADER_MEMORY
409 dnl check for a few basic system headers we need
430 arpa/nameser_compat.h \
432 dnl to do if not found
438 #ifdef HAVE_SYS_TYPES_H
439 #include <sys/types.h>
441 #ifdef HAVE_SYS_TIME_H
442 #include <sys/time.h>
444 dnl We do this default-include simply to make sure that the nameser_compat.h
445 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
446 dnl (and others?) is not designed to allow this.
447 #ifdef HAVE_ARPA_NAMESER_H
448 #include <arpa/nameser.h>
451 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
452 #ifdef HAVE_SYS_SOCKET_H
453 #include <sys/socket.h>
455 #ifdef HAVE_NETINET_IN_H
456 #include <netinet/in.h>
461 dnl Checks for typedefs, structures, and compiler characteristics.
465 CURL_CHECK_STRUCT_TIMEVAL
467 AC_CHECK_SIZEOF(size_t)
468 AC_CHECK_SIZEOF(long)
470 AC_CHECK_SIZEOF(short)
472 AC_CHECK_SIZEOF(time_t)
474 AC_CHECK_TYPE(long long,
475 [AC_DEFINE(HAVE_LONGLONG, 1,
476 [Define to 1 if the compiler supports the 'long long' data type.])]
480 if test "xyes" = "x$longlong"; then
481 AC_MSG_CHECKING([if numberLL works])
485 long long val = 1000LL;
489 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
497 AC_CHECK_TYPE(ssize_t, ,
498 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
500 # check for bool type
501 AC_CHECK_TYPE([bool],[
502 AC_DEFINE(HAVE_BOOL_T, 1,
503 [Define to 1 if bool is an available type.])
505 #ifdef HAVE_SYS_TYPES_H
506 #include <sys/types.h>
508 #ifdef HAVE_STDBOOL_H
513 CARES_CONFIGURE_ARES_SOCKLEN_T
517 TYPE_SOCKADDR_STORAGE
524 CURL_CHECK_FUNC_RECVFROM
526 CURL_CHECK_MSG_NOSIGNAL
528 CARES_CHECK_FUNC_CLOSESOCKET
529 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
530 CARES_CHECK_FUNC_CONNECT
531 CARES_CHECK_FUNC_FCNTL
532 CARES_CHECK_FUNC_FREEADDRINFO
533 CARES_CHECK_FUNC_GETADDRINFO
534 CARES_CHECK_FUNC_GETENV
535 CARES_CHECK_FUNC_GETHOSTBYADDR
536 CARES_CHECK_FUNC_GETHOSTBYNAME
537 CARES_CHECK_FUNC_GETHOSTNAME
538 CARES_CHECK_FUNC_GETSERVBYPORT_R
539 CARES_CHECK_FUNC_INET_NET_PTON
540 CARES_CHECK_FUNC_INET_NTOP
541 CARES_CHECK_FUNC_INET_PTON
542 CARES_CHECK_FUNC_IOCTL
543 CARES_CHECK_FUNC_IOCTLSOCKET
544 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
545 CARES_CHECK_FUNC_SETSOCKOPT
546 CARES_CHECK_FUNC_SOCKET
547 CARES_CHECK_FUNC_STRCASECMP
548 CARES_CHECK_FUNC_STRCMPI
549 CARES_CHECK_FUNC_STRDUP
550 CARES_CHECK_FUNC_STRICMP
551 CARES_CHECK_FUNC_STRNCASECMP
552 CARES_CHECK_FUNC_STRNCMPI
553 CARES_CHECK_FUNC_STRNICMP
554 CARES_CHECK_FUNC_WRITEV
557 dnl check for AF_INET6
558 CARES_CHECK_CONSTANT(
561 #ifdef HAVE_WINDOWS_H
562 #ifndef WIN32_LEAN_AND_MEAN
563 #define WIN32_LEAN_AND_MEAN
566 #ifdef HAVE_WINSOCK2_H
567 #include <winsock2.h>
570 #ifdef HAVE_SYS_TYPES_H
571 #include <sys/types.h>
573 #ifdef HAVE_SYS_SOCKET_H
574 #include <sys/socket.h>
578 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
581 dnl check for PF_INET6
582 CARES_CHECK_CONSTANT(
585 #ifdef HAVE_WINDOWS_H
586 #ifndef WIN32_LEAN_AND_MEAN
587 #define WIN32_LEAN_AND_MEAN
590 #ifdef HAVE_WINSOCK2_H
591 #include <winsock2.h>
594 #ifdef HAVE_SYS_TYPES_H
595 #include <sys/types.h>
597 #ifdef HAVE_SYS_SOCKET_H
598 #include <sys/socket.h>
602 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
606 dnl check for the in6_addr structure
610 #ifdef HAVE_WINDOWS_H
611 #ifndef WIN32_LEAN_AND_MEAN
612 #define WIN32_LEAN_AND_MEAN
615 #ifdef HAVE_WINSOCK2_H
616 #include <winsock2.h>
617 #ifdef HAVE_WS2TCPIP_H
618 #include <ws2tcpip.h>
622 #ifdef HAVE_SYS_TYPES_H
623 #include <sys/types.h>
625 #ifdef HAVE_NETINET_IN_H
626 #include <netinet/in.h>
630 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
633 dnl check for the sockaddr_in6 structure
637 #ifdef HAVE_WINDOWS_H
638 #ifndef WIN32_LEAN_AND_MEAN
639 #define WIN32_LEAN_AND_MEAN
642 #ifdef HAVE_WINSOCK2_H
643 #include <winsock2.h>
644 #ifdef HAVE_WS2TCPIP_H
645 #include <ws2tcpip.h>
649 #ifdef HAVE_SYS_TYPES_H
650 #include <sys/types.h>
652 #ifdef HAVE_NETINET_IN_H
653 #include <netinet/in.h>
657 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
658 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
661 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
662 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
663 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
667 #ifdef HAVE_WINDOWS_H
668 #ifndef WIN32_LEAN_AND_MEAN
669 #define WIN32_LEAN_AND_MEAN
672 #ifdef HAVE_WINSOCK2_H
673 #include <winsock2.h>
674 #ifdef HAVE_WS2TCPIP_H
675 #include <ws2tcpip.h>
679 #ifdef HAVE_SYS_TYPES_H
680 #include <sys/types.h>
682 #ifdef HAVE_NETINET_IN_H
683 #include <netinet/in.h>
688 dnl check for the addrinfo structure
689 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
690 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
691 [Define to 1 if you have struct addrinfo.]),,
694 #ifdef HAVE_WINDOWS_H
695 #ifndef WIN32_LEAN_AND_MEAN
696 #define WIN32_LEAN_AND_MEAN
699 #ifdef HAVE_WINSOCK2_H
700 #include <winsock2.h>
701 #ifdef HAVE_WS2TCPIP_H
702 #include <ws2tcpip.h>
706 #ifdef HAVE_SYS_TYPES_H
707 #include <sys/types.h>
709 #ifdef HAVE_NETINET_IN_H
710 #include <netinet/in.h>
712 #ifdef HAVE_SYS_SOCKET_H
713 #include <sys/socket.h>
723 AC_CHECK_FUNCS([bitncmp \
729 AC_MSG_CHECKING([deeper for $func])
737 eval "ac_cv_func_$func=yes"
738 AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
739 [Define to 1 if you have the $func function.])
741 AC_MSG_RESULT([but still no])
746 AC_CHECK_SIZEOF(struct in6_addr, ,
749 #ifdef HAVE_WINDOWS_H
750 #ifndef WIN32_LEAN_AND_MEAN
751 #define WIN32_LEAN_AND_MEAN
754 #ifdef HAVE_WINSOCK2_H
755 #include <winsock2.h>
756 #ifdef HAVE_WS2TCPIP_H
757 #include <ws2tcpip.h>
761 #ifdef HAVE_SYS_TYPES_H
762 #include <sys/types.h>
764 #ifdef HAVE_SYS_SOCKET_H
765 #include <sys/socket.h>
767 #ifdef HAVE_NETINET_IN_H
768 #include <netinet/in.h>
774 AC_CHECK_SIZEOF(struct in_addr, ,
777 #ifdef HAVE_WINDOWS_H
778 #ifndef WIN32_LEAN_AND_MEAN
779 #define WIN32_LEAN_AND_MEAN
782 #ifdef HAVE_WINSOCK2_H
783 #include <winsock2.h>
784 #ifdef HAVE_WS2TCPIP_H
785 #include <ws2tcpip.h>
789 #ifdef HAVE_SYS_TYPES_H
790 #include <sys/types.h>
792 #ifdef HAVE_SYS_SOCKET_H
793 #include <sys/socket.h>
795 #ifdef HAVE_NETINET_IN_H
796 #include <netinet/in.h>
803 dnl Check if the getnameinfo function is available
804 dnl and get the types of five of its arguments.
805 CURL_CHECK_FUNC_GETNAMEINFO
809 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
810 [define this if ares is built for a big endian system])],
812 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
815 dnl Check for user-specified random device
817 AC_HELP_STRING([--with-random=FILE],
818 [read randomness from FILE (default=/dev/urandom)]),
819 [ RANDOM_FILE="$withval" ],
821 dnl Check for random device. If we're cross compiling, we can't
822 dnl check, and it's better to assume it doesn't exist than it is
823 dnl to fail on AC_CHECK_FILE or later.
824 if test "$cross_compiling" = "no"; then
825 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
827 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
832 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
833 AC_SUBST(RANDOM_FILE)
834 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
835 [a suitable file/device to read random data from])
838 CARES_CHECK_OPTION_NONBLOCKING
839 CARES_CHECK_NONBLOCKING_SOCKET
841 CARES_CONFIGURE_SYMBOL_HIDING
843 CARES_PRIVATE_LIBS="$LIBS"
844 AC_SUBST(CARES_PRIVATE_LIBS)
846 CARES_CFLAG_EXTRAS=""
847 if test X"$want_werror" = Xyes; then
848 CARES_CFLAG_EXTRAS="-Werror"
850 AC_SUBST(CARES_CFLAG_EXTRAS)
852 dnl squeeze whitespace out of some variables
860 squeeze CARES_PRIVATE_LIBS
862 AC_CONFIG_FILES([Makefile libcares.pc])