3 dnl Version not hardcoded here. Fetched later from ares_version.h
4 AC_INIT([c-ares], [1.12.0],
5 [c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares])
9 CARES_OVERRIDE_AUTOCONF
11 AC_CONFIG_SRCDIR([ares_ipv6.h])
12 AC_CONFIG_HEADERS([ares_config.h ares_build.h])
13 AC_CONFIG_MACRO_DIR([m4])
15 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
17 CARES_CHECK_OPTION_DEBUG
18 CARES_CHECK_OPTION_OPTIMIZE
19 CARES_CHECK_OPTION_WARNINGS
20 CARES_CHECK_OPTION_WERROR
21 CARES_CHECK_OPTION_CURLDEBUG
22 CARES_CHECK_OPTION_SYMBOL_HIDING
23 CARES_CHECK_OPTION_EXPOSE_STATICS
25 XC_CHECK_PATH_SEPARATOR
27 dnl SED is mandatory for configure process and libtool.
28 dnl Set it now, allowing it to be changed later.
29 AC_PATH_PROG([SED], [sed], [not_found],
30 [$PATH:/usr/bin:/usr/local/bin])
31 if test -z "$SED" || test "$SED" = "not_found"; then
32 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
36 dnl GREP is mandatory for configure process and libtool.
37 dnl Set it now, allowing it to be changed later.
38 AC_PATH_PROG([GREP], [grep], [not_found],
39 [$PATH:/usr/bin:/usr/local/bin])
40 if test -z "$GREP" || test "$GREP" = "not_found"; then
41 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
45 dnl EGREP is mandatory for configure process and libtool.
46 dnl Set it now, allowing it to be changed later.
47 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
48 AC_MSG_CHECKING([for egrep])
50 AC_MSG_RESULT([$EGREP])
52 AC_PATH_PROG([EGREP], [egrep], [not_found],
53 [$PATH:/usr/bin:/usr/local/bin])
55 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
56 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
60 dnl AR is mandatory for configure process and libtool.
61 dnl This is target dependent, so check it as a tool.
62 AC_PATH_TOOL([AR], [ar], [not_found],
63 [$PATH:/usr/bin:/usr/local/bin])
64 if test -z "$AR" || test "$AR" = "not_found"; then
65 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
71 dnl Remove non-configure distributed ares_build.h
72 if test -f ${srcdir}/ares_build.h; then
73 rm -f ${srcdir}/ares_build.h
77 dnl Detect the canonical host and target build environment
81 dnl Get system canonical name
82 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
85 AX_CXX_COMPILE_STDCXX_11([noext],[optional])
89 dnl This defines _ALL_SOURCE for AIX
90 CARES_CHECK_AIX_ALL_SOURCE
92 dnl Our configure and build reentrant settings
93 CARES_CONFIGURE_THREAD_SAFE
94 CARES_CONFIGURE_REENTRANT
96 dnl check for how to do large files
101 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
108 # Automake conditionals based on libtool related checks
111 AM_CONDITIONAL([CARES_LT_SHLIB_USE_VERSION_INFO],
112 [test "x$xc_lt_shlib_use_version_info" = 'xyes'])
113 AM_CONDITIONAL([CARES_LT_SHLIB_USE_NO_UNDEFINED],
114 [test "x$xc_lt_shlib_use_no_undefined" = 'xyes'])
115 AM_CONDITIONAL([CARES_LT_SHLIB_USE_MIMPURE_TEXT],
116 [test "x$xc_lt_shlib_use_mimpure_text" = 'xyes'])
119 # Due to libtool and automake machinery limitations of not allowing
120 # specifying separate CPPFLAGS or CFLAGS when compiling objects for
121 # inclusion of these in shared or static libraries, we are forced to
122 # build using separate configure runs for shared and static libraries
123 # on systems where different CPPFLAGS or CFLAGS are mandatory in order
124 # to compile objects for each kind of library. Notice that relying on
125 # the '-DPIC' CFLAG that libtool provides is not valid given that the
126 # user might for example choose to build static libraries with PIC.
130 # Make our Makefile.am files use the staticlib CPPFLAG only when strictly
131 # targeting a static library and not building its shared counterpart.
134 AM_CONDITIONAL([USE_CPPFLAG_CARES_STATICLIB],
135 [test "x$xc_lt_build_static_only" = 'xyes'])
138 # Make staticlib CPPFLAG variable and its definition visible in output
139 # files unconditionally, providing an empty definition unless strictly
140 # targeting a static library and not building its shared counterpart.
143 CPPFLAG_CARES_STATICLIB=
144 if test "x$xc_lt_build_static_only" = 'xyes'; then
145 CPPFLAG_CARES_STATICLIB='-DCARES_STATICLIB'
147 AC_SUBST([CPPFLAG_CARES_STATICLIB])
149 dnl **********************************************************************
150 dnl platform/compiler/architecture specific checks/flags
151 dnl **********************************************************************
154 CARES_SET_COMPILER_BASIC_OPTS
155 CARES_SET_COMPILER_DEBUG_OPTS
156 CARES_SET_COMPILER_OPTIMIZE_OPTS
157 CARES_SET_COMPILER_WARNING_OPTS
159 if test "$compiler_id" = "INTEL_UNIX_C"; then
161 if test "$compiler_num" -ge "1000"; then
162 dnl icc 10.X or later
163 CFLAGS="$CFLAGS -shared-intel"
164 elif test "$compiler_num" -ge "900"; then
166 CFLAGS="$CFLAGS -i-dynamic"
171 CARES_CHECK_COMPILER_HALT_ON_ERROR
172 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
173 CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
174 CARES_CHECK_COMPILER_SYMBOL_HIDING
176 CARES_CHECK_CURLDEBUG
177 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
179 dnl **********************************************************************
180 dnl Compilation based checks should not be done before this point.
181 dnl **********************************************************************
183 dnl **********************************************************************
184 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
185 dnl and ws2tcpip.h take precedence over any other further checks which
186 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
187 dnl this specific header files. And do them before its results are used.
188 dnl **********************************************************************
190 CURL_CHECK_HEADER_WINDOWS
191 CURL_CHECK_NATIVE_WINDOWS
192 case X-"$ac_cv_native_windows" in
194 CURL_CHECK_HEADER_WINSOCK
195 CURL_CHECK_HEADER_WINSOCK2
196 CURL_CHECK_HEADER_WS2TCPIP
199 ac_cv_header_winsock_h="no"
200 ac_cv_header_winsock2_h="no"
201 ac_cv_header_ws2tcpip_h="no"
205 dnl **********************************************************************
206 dnl Checks for libraries.
207 dnl **********************************************************************
211 dnl gethostbyname without lib or in the nsl lib?
212 AC_CHECK_FUNC(gethostbyname,
213 [HAVE_GETHOSTBYNAME="1"
215 [ AC_CHECK_LIB(nsl, gethostbyname,
216 [HAVE_GETHOSTBYNAME="1"
221 if test "$HAVE_GETHOSTBYNAME" != "1"
223 dnl gethostbyname in the socket lib?
224 AC_CHECK_LIB(socket, gethostbyname,
225 [HAVE_GETHOSTBYNAME="1"
226 LIBS="$LIBS -lsocket"
230 dnl At least one system has been identified to require BOTH nsl and socket
231 dnl libs at the same time to link properly.
232 if test "$HAVE_GETHOSTBYNAME" != "1"
234 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
235 my_ac_save_LIBS=$LIBS
236 LIBS="-lnsl -lsocket $LIBS"
244 HAVE_GETHOSTBYNAME="1"
247 LIBS=$my_ac_save_LIBS
251 if test "$HAVE_GETHOSTBYNAME" != "1"
253 dnl This is for winsock systems
254 if test "$ac_cv_header_windows_h" = "yes"; then
255 if test "$ac_cv_header_winsock_h" = "yes"; then
258 winsock_LIB="-lwinsock"
261 winsock_LIB="-lwsock32"
265 if test "$ac_cv_header_winsock2_h" = "yes"; then
266 winsock_LIB="-lws2_32"
268 if test ! -z "$winsock_LIB"; then
269 my_ac_save_LIBS=$LIBS
270 LIBS="$winsock_LIB $LIBS"
271 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
274 #ifdef HAVE_WINDOWS_H
275 #ifndef WIN32_LEAN_AND_MEAN
276 #define WIN32_LEAN_AND_MEAN
279 #ifdef HAVE_WINSOCK2_H
280 #include <winsock2.h>
282 #ifdef HAVE_WINSOCK_H
288 gethostbyname("www.dummysite.com");
292 HAVE_GETHOSTBYNAME="1"
296 LIBS=$my_ac_save_LIBS
302 if test "$HAVE_GETHOSTBYNAME" != "1"
304 dnl This is for Minix 3.1
305 AC_MSG_CHECKING([for gethostbyname for Minix 3])
308 /* Older Minix versions may need <net/gen/netdb.h> here instead */
311 gethostbyname("www.dummysite.com");
315 HAVE_GETHOSTBYNAME="1"
321 if test "$HAVE_GETHOSTBYNAME" != "1"
323 dnl This is for eCos with a stubbed DNS implementation
324 AC_MSG_CHECKING([for gethostbyname for eCos])
330 gethostbyname("www.dummysite.com");
334 HAVE_GETHOSTBYNAME="1"
340 if test "$HAVE_GETHOSTBYNAME" != "1"
342 dnl gethostbyname in the net lib - for BeOS
343 AC_CHECK_LIB(net, gethostbyname,
344 [HAVE_GETHOSTBYNAME="1"
350 if test "$HAVE_GETHOSTBYNAME" != "1"; then
351 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
354 dnl resolv lib for iPhone
355 AS_IF([test "x$host_vendor" = "xapple"], [
356 AC_MSG_CHECKING([for iPhone target])
359 #include "TargetConditionals.h"
361 #if TARGET_OS_IPHONE == 0
362 #error Not an iPhone target
368 AC_SEARCH_LIBS([res_servicename], [resolv], [
369 AC_DEFINE([CARES_USE_LIBRESOLV], [1], [Use resolver library to configure cares])
371 AC_MSG_ERROR([Unable to find libresolv which is required for iPhone targets])
379 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
381 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
382 AC_CHECK_LIB(resolve, strcasecmp,
383 [LIBS="-lresolve $LIBS"],
387 ac_cv_func_strcasecmp="no"
389 CARES_CHECK_LIBS_CONNECT
391 dnl **********************************************************************
392 dnl In case that function clock_gettime with monotonic timer is available,
393 dnl check for additional required libraries.
394 dnl **********************************************************************
395 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
397 AC_MSG_CHECKING([whether to use libgcc])
398 AC_ARG_ENABLE(libgcc,
399 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
400 [ case "$enableval" in
412 dnl Let's hope this split URL remains working:
413 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
414 dnl genprogc/thread_quick_ref.htm
417 dnl **********************************************************************
418 dnl Back to "normal" configuring
419 dnl **********************************************************************
421 dnl Checks for header files.
424 CURL_CHECK_HEADER_MALLOC
425 CURL_CHECK_HEADER_MEMORY
427 dnl check for a few basic system headers we need
448 arpa/nameser_compat.h \
450 dnl to do if not found
456 #ifdef HAVE_SYS_TYPES_H
457 #include <sys/types.h>
459 #ifdef HAVE_SYS_TIME_H
460 #include <sys/time.h>
462 dnl We do this default-include simply to make sure that the nameser_compat.h
463 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
464 dnl (and others?) is not designed to allow this.
465 #ifdef HAVE_ARPA_NAMESER_H
466 #include <arpa/nameser.h>
469 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
470 #ifdef HAVE_SYS_SOCKET_H
471 #include <sys/socket.h>
473 #ifdef HAVE_NETINET_IN_H
474 #include <netinet/in.h>
479 dnl Checks for typedefs, structures, and compiler characteristics.
483 CURL_CHECK_STRUCT_TIMEVAL
485 AC_CHECK_TYPE(long long,
486 [AC_DEFINE(HAVE_LONGLONG, 1,
487 [Define to 1 if the compiler supports the 'long long' data type.])]
491 if test "xyes" = "x$longlong"; then
492 AC_MSG_CHECKING([if numberLL works])
496 long long val = 1000LL;
500 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
508 AC_CHECK_TYPE(ssize_t, ,
509 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
511 # check for bool type
512 AC_CHECK_TYPE([bool],[
513 AC_DEFINE(HAVE_BOOL_T, 1,
514 [Define to 1 if bool is an available type.])
516 #ifdef HAVE_SYS_TYPES_H
517 #include <sys/types.h>
519 #ifdef HAVE_STDBOOL_H
524 CARES_CONFIGURE_ARES_SOCKLEN_T
528 TYPE_SOCKADDR_STORAGE
535 CURL_CHECK_FUNC_RECVFROM
537 CURL_CHECK_MSG_NOSIGNAL
539 CARES_CHECK_FUNC_CLOSESOCKET
540 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
541 CARES_CHECK_FUNC_CONNECT
542 CARES_CHECK_FUNC_FCNTL
543 CARES_CHECK_FUNC_FREEADDRINFO
544 CARES_CHECK_FUNC_GETADDRINFO
545 CARES_CHECK_FUNC_GETENV
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_NET_PTON
551 CARES_CHECK_FUNC_INET_NTOP
552 CARES_CHECK_FUNC_INET_PTON
553 CARES_CHECK_FUNC_IOCTL
554 CARES_CHECK_FUNC_IOCTLSOCKET
555 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
556 CARES_CHECK_FUNC_SETSOCKOPT
557 CARES_CHECK_FUNC_SOCKET
558 CARES_CHECK_FUNC_STRCASECMP
559 CARES_CHECK_FUNC_STRCMPI
560 CARES_CHECK_FUNC_STRDUP
561 CARES_CHECK_FUNC_STRICMP
562 CARES_CHECK_FUNC_STRNCASECMP
563 CARES_CHECK_FUNC_STRNCMPI
564 CARES_CHECK_FUNC_STRNICMP
565 CARES_CHECK_FUNC_WRITEV
568 dnl check for AF_INET6
569 CARES_CHECK_CONSTANT(
572 #ifdef HAVE_WINDOWS_H
573 #ifndef WIN32_LEAN_AND_MEAN
574 #define WIN32_LEAN_AND_MEAN
577 #ifdef HAVE_WINSOCK2_H
578 #include <winsock2.h>
581 #ifdef HAVE_SYS_TYPES_H
582 #include <sys/types.h>
584 #ifdef HAVE_SYS_SOCKET_H
585 #include <sys/socket.h>
589 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
592 dnl check for PF_INET6
593 CARES_CHECK_CONSTANT(
596 #ifdef HAVE_WINDOWS_H
597 #ifndef WIN32_LEAN_AND_MEAN
598 #define WIN32_LEAN_AND_MEAN
601 #ifdef HAVE_WINSOCK2_H
602 #include <winsock2.h>
605 #ifdef HAVE_SYS_TYPES_H
606 #include <sys/types.h>
608 #ifdef HAVE_SYS_SOCKET_H
609 #include <sys/socket.h>
613 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
617 dnl check for the in6_addr structure
621 #ifdef HAVE_WINDOWS_H
622 #ifndef WIN32_LEAN_AND_MEAN
623 #define WIN32_LEAN_AND_MEAN
626 #ifdef HAVE_WINSOCK2_H
627 #include <winsock2.h>
628 #ifdef HAVE_WS2TCPIP_H
629 #include <ws2tcpip.h>
633 #ifdef HAVE_SYS_TYPES_H
634 #include <sys/types.h>
636 #ifdef HAVE_NETINET_IN_H
637 #include <netinet/in.h>
641 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
644 dnl check for the sockaddr_in6 structure
648 #ifdef HAVE_WINDOWS_H
649 #ifndef WIN32_LEAN_AND_MEAN
650 #define WIN32_LEAN_AND_MEAN
653 #ifdef HAVE_WINSOCK2_H
654 #include <winsock2.h>
655 #ifdef HAVE_WS2TCPIP_H
656 #include <ws2tcpip.h>
660 #ifdef HAVE_SYS_TYPES_H
661 #include <sys/types.h>
663 #ifdef HAVE_NETINET_IN_H
664 #include <netinet/in.h>
668 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
669 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
672 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
673 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
674 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
678 #ifdef HAVE_WINDOWS_H
679 #ifndef WIN32_LEAN_AND_MEAN
680 #define WIN32_LEAN_AND_MEAN
683 #ifdef HAVE_WINSOCK2_H
684 #include <winsock2.h>
685 #ifdef HAVE_WS2TCPIP_H
686 #include <ws2tcpip.h>
690 #ifdef HAVE_SYS_TYPES_H
691 #include <sys/types.h>
693 #ifdef HAVE_NETINET_IN_H
694 #include <netinet/in.h>
699 dnl check for the addrinfo structure
700 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
701 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
702 [Define to 1 if you have struct addrinfo.]),,
705 #ifdef HAVE_WINDOWS_H
706 #ifndef WIN32_LEAN_AND_MEAN
707 #define WIN32_LEAN_AND_MEAN
710 #ifdef HAVE_WINSOCK2_H
711 #include <winsock2.h>
712 #ifdef HAVE_WS2TCPIP_H
713 #include <ws2tcpip.h>
717 #ifdef HAVE_SYS_TYPES_H
718 #include <sys/types.h>
720 #ifdef HAVE_NETINET_IN_H
721 #include <netinet/in.h>
723 #ifdef HAVE_SYS_SOCKET_H
724 #include <sys/socket.h>
734 AC_CHECK_FUNCS([bitncmp \
740 AC_MSG_CHECKING([deeper for $func])
748 eval "ac_cv_func_$func=yes"
749 AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
750 [Define to 1 if you have the $func function.])
752 AC_MSG_RESULT([but still no])
757 dnl Check if the getnameinfo function is available
758 dnl and get the types of five of its arguments.
759 CURL_CHECK_FUNC_GETNAMEINFO
763 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
764 [define this if ares is built for a big endian system])],
766 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
769 dnl Check for user-specified random device
771 AC_HELP_STRING([--with-random=FILE],
772 [read randomness from FILE (default=/dev/urandom)]),
773 [ RANDOM_FILE="$withval" ],
775 dnl Check for random device. If we're cross compiling, we can't
776 dnl check, and it's better to assume it doesn't exist than it is
777 dnl to fail on AC_CHECK_FILE or later.
778 if test "$cross_compiling" = "no"; then
779 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
781 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
786 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
787 AC_SUBST(RANDOM_FILE)
788 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
789 [a suitable file/device to read random data from])
792 CARES_CHECK_OPTION_NONBLOCKING
793 CARES_CHECK_NONBLOCKING_SOCKET
795 CARES_CONFIGURE_SYMBOL_HIDING
797 CARES_PRIVATE_LIBS="$LIBS"
798 AC_SUBST(CARES_PRIVATE_LIBS)
800 CARES_CFLAG_EXTRAS=""
801 if test X"$want_werror" = Xyes; then
802 CARES_CFLAG_EXTRAS="-Werror"
804 AC_SUBST(CARES_CFLAG_EXTRAS)
806 dnl squeeze whitespace out of some variables
814 squeeze CARES_PRIVATE_LIBS
818 AC_MSG_CHECKING([whether to build tests])
820 AC_HELP_STRING([--enable-tests], [build test suite]),
821 [ build_tests="$enableval" ],
822 [ if test "x$HAVE_CXX11" = "x1" && test "x$cross_compiling" = "xno" ; then
830 if test "x$build_tests" = "xyes" ; then
831 if test "x$HAVE_CXX11" = "0" ; then
832 AC_MSG_ERROR([*** Building tests requires a CXX11 compiler])
834 if test "x$cross_compiling" = "xyes" ; then
835 AC_MSG_ERROR([*** Tests not supported when cross compiling])
838 AC_MSG_RESULT([$build_tests])
840 if test "x$build_tests" = "xyes" ; then
841 AC_CONFIG_SUBDIRS([test])
844 AC_CONFIG_FILES([Makefile libcares.pc])
846 XC_AMEND_DISTCLEAN(['.'])