3 dnl Version not hardcoded here. Fetched later from ares_version.h
4 AC_INIT([c-ares], [1.10.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])
16 CARES_CHECK_OPTION_DEBUG
17 CARES_CHECK_OPTION_OPTIMIZE
18 CARES_CHECK_OPTION_WARNINGS
19 CARES_CHECK_OPTION_WERROR
20 CARES_CHECK_OPTION_CURLDEBUG
21 CARES_CHECK_OPTION_SYMBOL_HIDING
23 XC_CHECK_PATH_SEPARATOR
25 dnl SED is mandatory for configure process and libtool.
26 dnl Set it now, allowing it to be changed later.
27 AC_PATH_PROG([SED], [sed], [not_found],
28 [$PATH:/usr/bin:/usr/local/bin])
29 if test -z "$SED" || test "$SED" = "not_found"; then
30 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
34 dnl GREP is mandatory for configure process and libtool.
35 dnl Set it now, allowing it to be changed later.
36 AC_PATH_PROG([GREP], [grep], [not_found],
37 [$PATH:/usr/bin:/usr/local/bin])
38 if test -z "$GREP" || test "$GREP" = "not_found"; then
39 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
43 dnl EGREP is mandatory for configure process and libtool.
44 dnl Set it now, allowing it to be changed later.
45 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
46 AC_MSG_CHECKING([for egrep])
48 AC_MSG_RESULT([$EGREP])
50 AC_PATH_PROG([EGREP], [egrep], [not_found],
51 [$PATH:/usr/bin:/usr/local/bin])
53 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
54 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
58 dnl AR is mandatory for configure process and libtool.
59 dnl This is target dependent, so check it as a tool.
60 AC_PATH_TOOL([AR], [ar], [not_found],
61 [$PATH:/usr/bin:/usr/local/bin])
62 if test -z "$AR" || test "$AR" = "not_found"; then
63 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
67 dnl Remove non-configure distributed ares_build.h
68 if test -f ${srcdir}/ares_build.h; then
69 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])
103 # Automake conditionals based on libtool related checks
106 AM_CONDITIONAL([CARES_LT_SHLIB_USE_VERSION_INFO],
107 [test "x$xc_lt_shlib_use_version_info" = 'xyes'])
108 AM_CONDITIONAL([CARES_LT_SHLIB_USE_NO_UNDEFINED],
109 [test "x$xc_lt_shlib_use_no_undefined" = 'xyes'])
110 AM_CONDITIONAL([CARES_LT_SHLIB_USE_MIMPURE_TEXT],
111 [test "x$xc_lt_shlib_use_mimpure_text" = 'xyes'])
114 # Due to libtool and automake machinery limitations of not allowing
115 # specifying separate CPPFLAGS or CFLAGS when compiling objects for
116 # inclusion of these in shared or static libraries, we are forced to
117 # build using separate configure runs for shared and static libraries
118 # on systems where different CPPFLAGS or CFLAGS are mandatory in order
119 # to compile objects for each kind of library. Notice that relying on
120 # the '-DPIC' CFLAG that libtool provides is not valid given that the
121 # user might for example choose to build static libraries with PIC.
125 # Make our Makefile.am files use the staticlib CPPFLAG only when strictly
126 # targeting a static library and not building its shared counterpart.
129 AM_CONDITIONAL([USE_CPPFLAG_CARES_STATICLIB],
130 [test "x$xc_lt_build_static_only" = 'xyes'])
133 # Make staticlib CPPFLAG variable and its definition visible in output
134 # files unconditionally, providing an empty definition unless strictly
135 # targeting a static library and not building its shared counterpart.
138 CPPFLAG_CARES_STATICLIB=
139 if test "x$xc_lt_build_static_only" = 'xyes'; then
140 CPPFLAG_CARES_STATICLIB='-DCARES_STATICLIB'
142 AC_SUBST([CPPFLAG_CARES_STATICLIB])
144 dnl **********************************************************************
145 dnl platform/compiler/architecture specific checks/flags
146 dnl **********************************************************************
149 CARES_SET_COMPILER_BASIC_OPTS
150 CARES_SET_COMPILER_DEBUG_OPTS
151 CARES_SET_COMPILER_OPTIMIZE_OPTS
152 CARES_SET_COMPILER_WARNING_OPTS
154 if test "$compiler_id" = "INTEL_UNIX_C"; then
156 if test "$compiler_num" -ge "1000"; then
157 dnl icc 10.X or later
158 CFLAGS="$CFLAGS -shared-intel"
159 elif test "$compiler_num" -ge "900"; then
161 CFLAGS="$CFLAGS -i-dynamic"
166 CARES_CHECK_COMPILER_HALT_ON_ERROR
167 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
168 CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
169 CARES_CHECK_COMPILER_SYMBOL_HIDING
171 CARES_CHECK_CURLDEBUG
172 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
174 dnl **********************************************************************
175 dnl Compilation based checks should not be done before this point.
176 dnl **********************************************************************
178 dnl **********************************************************************
179 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
180 dnl and ws2tcpip.h take precedence over any other further checks which
181 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
182 dnl this specific header files. And do them before its results are used.
183 dnl **********************************************************************
185 CURL_CHECK_HEADER_WINDOWS
186 CURL_CHECK_NATIVE_WINDOWS
187 case X-"$ac_cv_native_windows" in
189 CURL_CHECK_HEADER_WINSOCK
190 CURL_CHECK_HEADER_WINSOCK2
191 CURL_CHECK_HEADER_WS2TCPIP
194 ac_cv_header_winsock_h="no"
195 ac_cv_header_winsock2_h="no"
196 ac_cv_header_ws2tcpip_h="no"
200 dnl **********************************************************************
201 dnl Checks for libraries.
202 dnl **********************************************************************
206 dnl gethostbyname without lib or in the nsl lib?
207 AC_CHECK_FUNC(gethostbyname,
208 [HAVE_GETHOSTBYNAME="1"
210 [ AC_CHECK_LIB(nsl, gethostbyname,
211 [HAVE_GETHOSTBYNAME="1"
216 if test "$HAVE_GETHOSTBYNAME" != "1"
218 dnl gethostbyname in the socket lib?
219 AC_CHECK_LIB(socket, gethostbyname,
220 [HAVE_GETHOSTBYNAME="1"
221 LIBS="$LIBS -lsocket"
225 dnl At least one system has been identified to require BOTH nsl and socket
226 dnl libs at the same time to link properly.
227 if test "$HAVE_GETHOSTBYNAME" != "1"
229 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
230 my_ac_save_LIBS=$LIBS
231 LIBS="-lnsl -lsocket $LIBS"
239 HAVE_GETHOSTBYNAME="1"
242 LIBS=$my_ac_save_LIBS
246 if test "$HAVE_GETHOSTBYNAME" != "1"
248 dnl This is for winsock systems
249 if test "$ac_cv_header_windows_h" = "yes"; then
250 if test "$ac_cv_header_winsock_h" = "yes"; then
253 winsock_LIB="-lwinsock"
256 winsock_LIB="-lwsock32"
260 if test "$ac_cv_header_winsock2_h" = "yes"; then
261 winsock_LIB="-lws2_32"
263 if test ! -z "$winsock_LIB"; then
264 my_ac_save_LIBS=$LIBS
265 LIBS="$winsock_LIB $LIBS"
266 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
269 #ifdef HAVE_WINDOWS_H
270 #ifndef WIN32_LEAN_AND_MEAN
271 #define WIN32_LEAN_AND_MEAN
274 #ifdef HAVE_WINSOCK2_H
275 #include <winsock2.h>
277 #ifdef HAVE_WINSOCK_H
283 gethostbyname("www.dummysite.com");
287 HAVE_GETHOSTBYNAME="1"
291 LIBS=$my_ac_save_LIBS
297 if test "$HAVE_GETHOSTBYNAME" != "1"
299 dnl This is for Minix 3.1
300 AC_MSG_CHECKING([for gethostbyname for Minix 3])
303 /* Older Minix versions may need <net/gen/netdb.h> here instead */
306 gethostbyname("www.dummysite.com");
310 HAVE_GETHOSTBYNAME="1"
316 if test "$HAVE_GETHOSTBYNAME" != "1"
318 dnl This is for eCos with a stubbed DNS implementation
319 AC_MSG_CHECKING([for gethostbyname for eCos])
325 gethostbyname("www.dummysite.com");
329 HAVE_GETHOSTBYNAME="1"
335 if test "$HAVE_GETHOSTBYNAME" != "1"
337 dnl gethostbyname in the net lib - for BeOS
338 AC_CHECK_LIB(net, gethostbyname,
339 [HAVE_GETHOSTBYNAME="1"
345 if test "$HAVE_GETHOSTBYNAME" != "1"; then
346 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
350 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
352 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
353 AC_CHECK_LIB(resolve, strcasecmp,
354 [LIBS="-lresolve $LIBS"],
358 ac_cv_func_strcasecmp="no"
360 CARES_CHECK_LIBS_CONNECT
362 dnl **********************************************************************
363 dnl In case that function clock_gettime with monotonic timer is available,
364 dnl check for additional required libraries.
365 dnl **********************************************************************
366 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
368 AC_MSG_CHECKING([whether to use libgcc])
369 AC_ARG_ENABLE(libgcc,
370 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
371 [ case "$enableval" in
383 dnl Let's hope this split URL remains working:
384 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
385 dnl genprogc/thread_quick_ref.htm
388 dnl **********************************************************************
389 dnl Back to "normal" configuring
390 dnl **********************************************************************
392 dnl Checks for header files.
395 CURL_CHECK_HEADER_MALLOC
396 CURL_CHECK_HEADER_MEMORY
398 dnl check for a few basic system headers we need
419 arpa/nameser_compat.h \
421 dnl to do if not found
427 #ifdef HAVE_SYS_TYPES_H
428 #include <sys/types.h>
430 #ifdef HAVE_SYS_TIME_H
431 #include <sys/time.h>
433 dnl We do this default-include simply to make sure that the nameser_compat.h
434 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
435 dnl (and others?) is not designed to allow this.
436 #ifdef HAVE_ARPA_NAMESER_H
437 #include <arpa/nameser.h>
440 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
441 #ifdef HAVE_SYS_SOCKET_H
442 #include <sys/socket.h>
444 #ifdef HAVE_NETINET_IN_H
445 #include <netinet/in.h>
450 dnl Checks for typedefs, structures, and compiler characteristics.
454 CURL_CHECK_STRUCT_TIMEVAL
456 AC_CHECK_SIZEOF(size_t)
457 AC_CHECK_SIZEOF(long)
459 AC_CHECK_SIZEOF(short)
461 AC_CHECK_SIZEOF(time_t)
463 AC_CHECK_TYPE(long long,
464 [AC_DEFINE(HAVE_LONGLONG, 1,
465 [Define to 1 if the compiler supports the 'long long' data type.])]
469 if test "xyes" = "x$longlong"; then
470 AC_MSG_CHECKING([if numberLL works])
474 long long val = 1000LL;
478 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
486 AC_CHECK_TYPE(ssize_t, ,
487 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
489 # check for bool type
490 AC_CHECK_TYPE([bool],[
491 AC_DEFINE(HAVE_BOOL_T, 1,
492 [Define to 1 if bool is an available type.])
494 #ifdef HAVE_SYS_TYPES_H
495 #include <sys/types.h>
497 #ifdef HAVE_STDBOOL_H
502 CARES_CONFIGURE_ARES_SOCKLEN_T
506 TYPE_SOCKADDR_STORAGE
513 CURL_CHECK_FUNC_RECVFROM
515 CURL_CHECK_MSG_NOSIGNAL
517 CARES_CHECK_FUNC_CLOSESOCKET
518 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
519 CARES_CHECK_FUNC_CONNECT
520 CARES_CHECK_FUNC_FCNTL
521 CARES_CHECK_FUNC_FREEADDRINFO
522 CARES_CHECK_FUNC_GETADDRINFO
523 CARES_CHECK_FUNC_GETENV
524 CARES_CHECK_FUNC_GETHOSTBYADDR
525 CARES_CHECK_FUNC_GETHOSTBYNAME
526 CARES_CHECK_FUNC_GETHOSTNAME
527 CARES_CHECK_FUNC_GETSERVBYPORT_R
528 CARES_CHECK_FUNC_INET_NET_PTON
529 CARES_CHECK_FUNC_INET_NTOP
530 CARES_CHECK_FUNC_INET_PTON
531 CARES_CHECK_FUNC_IOCTL
532 CARES_CHECK_FUNC_IOCTLSOCKET
533 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
534 CARES_CHECK_FUNC_SETSOCKOPT
535 CARES_CHECK_FUNC_SOCKET
536 CARES_CHECK_FUNC_STRCASECMP
537 CARES_CHECK_FUNC_STRCMPI
538 CARES_CHECK_FUNC_STRDUP
539 CARES_CHECK_FUNC_STRICMP
540 CARES_CHECK_FUNC_STRNCASECMP
541 CARES_CHECK_FUNC_STRNCMPI
542 CARES_CHECK_FUNC_STRNICMP
543 CARES_CHECK_FUNC_WRITEV
546 dnl check for AF_INET6
547 CARES_CHECK_CONSTANT(
550 #ifdef HAVE_WINDOWS_H
551 #ifndef WIN32_LEAN_AND_MEAN
552 #define WIN32_LEAN_AND_MEAN
555 #ifdef HAVE_WINSOCK2_H
556 #include <winsock2.h>
559 #ifdef HAVE_SYS_TYPES_H
560 #include <sys/types.h>
562 #ifdef HAVE_SYS_SOCKET_H
563 #include <sys/socket.h>
567 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
570 dnl check for PF_INET6
571 CARES_CHECK_CONSTANT(
574 #ifdef HAVE_WINDOWS_H
575 #ifndef WIN32_LEAN_AND_MEAN
576 #define WIN32_LEAN_AND_MEAN
579 #ifdef HAVE_WINSOCK2_H
580 #include <winsock2.h>
583 #ifdef HAVE_SYS_TYPES_H
584 #include <sys/types.h>
586 #ifdef HAVE_SYS_SOCKET_H
587 #include <sys/socket.h>
591 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
595 dnl check for the in6_addr structure
599 #ifdef HAVE_WINDOWS_H
600 #ifndef WIN32_LEAN_AND_MEAN
601 #define WIN32_LEAN_AND_MEAN
604 #ifdef HAVE_WINSOCK2_H
605 #include <winsock2.h>
606 #ifdef HAVE_WS2TCPIP_H
607 #include <ws2tcpip.h>
611 #ifdef HAVE_SYS_TYPES_H
612 #include <sys/types.h>
614 #ifdef HAVE_NETINET_IN_H
615 #include <netinet/in.h>
619 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
622 dnl check for the sockaddr_in6 structure
626 #ifdef HAVE_WINDOWS_H
627 #ifndef WIN32_LEAN_AND_MEAN
628 #define WIN32_LEAN_AND_MEAN
631 #ifdef HAVE_WINSOCK2_H
632 #include <winsock2.h>
633 #ifdef HAVE_WS2TCPIP_H
634 #include <ws2tcpip.h>
638 #ifdef HAVE_SYS_TYPES_H
639 #include <sys/types.h>
641 #ifdef HAVE_NETINET_IN_H
642 #include <netinet/in.h>
646 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
647 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
650 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
651 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
652 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
656 #ifdef HAVE_WINDOWS_H
657 #ifndef WIN32_LEAN_AND_MEAN
658 #define WIN32_LEAN_AND_MEAN
661 #ifdef HAVE_WINSOCK2_H
662 #include <winsock2.h>
663 #ifdef HAVE_WS2TCPIP_H
664 #include <ws2tcpip.h>
668 #ifdef HAVE_SYS_TYPES_H
669 #include <sys/types.h>
671 #ifdef HAVE_NETINET_IN_H
672 #include <netinet/in.h>
677 dnl check for the addrinfo structure
678 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
679 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
680 [Define to 1 if you have struct addrinfo.]),,
683 #ifdef HAVE_WINDOWS_H
684 #ifndef WIN32_LEAN_AND_MEAN
685 #define WIN32_LEAN_AND_MEAN
688 #ifdef HAVE_WINSOCK2_H
689 #include <winsock2.h>
690 #ifdef HAVE_WS2TCPIP_H
691 #include <ws2tcpip.h>
695 #ifdef HAVE_SYS_TYPES_H
696 #include <sys/types.h>
698 #ifdef HAVE_NETINET_IN_H
699 #include <netinet/in.h>
701 #ifdef HAVE_SYS_SOCKET_H
702 #include <sys/socket.h>
712 AC_CHECK_FUNCS([bitncmp \
718 AC_MSG_CHECKING([deeper for $func])
726 eval "ac_cv_func_$func=yes"
727 AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
728 [Define to 1 if you have the $func function.])
730 AC_MSG_RESULT([but still no])
735 AC_CHECK_SIZEOF(struct in6_addr, ,
738 #ifdef HAVE_WINDOWS_H
739 #ifndef WIN32_LEAN_AND_MEAN
740 #define WIN32_LEAN_AND_MEAN
743 #ifdef HAVE_WINSOCK2_H
744 #include <winsock2.h>
745 #ifdef HAVE_WS2TCPIP_H
746 #include <ws2tcpip.h>
750 #ifdef HAVE_SYS_TYPES_H
751 #include <sys/types.h>
753 #ifdef HAVE_SYS_SOCKET_H
754 #include <sys/socket.h>
756 #ifdef HAVE_NETINET_IN_H
757 #include <netinet/in.h>
763 AC_CHECK_SIZEOF(struct in_addr, ,
766 #ifdef HAVE_WINDOWS_H
767 #ifndef WIN32_LEAN_AND_MEAN
768 #define WIN32_LEAN_AND_MEAN
771 #ifdef HAVE_WINSOCK2_H
772 #include <winsock2.h>
773 #ifdef HAVE_WS2TCPIP_H
774 #include <ws2tcpip.h>
778 #ifdef HAVE_SYS_TYPES_H
779 #include <sys/types.h>
781 #ifdef HAVE_SYS_SOCKET_H
782 #include <sys/socket.h>
784 #ifdef HAVE_NETINET_IN_H
785 #include <netinet/in.h>
792 dnl Check if the getnameinfo function is available
793 dnl and get the types of five of its arguments.
794 CURL_CHECK_FUNC_GETNAMEINFO
798 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
799 [define this if ares is built for a big endian system])],
801 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
804 dnl Check for user-specified random device
806 AC_HELP_STRING([--with-random=FILE],
807 [read randomness from FILE (default=/dev/urandom)]),
808 [ RANDOM_FILE="$withval" ],
810 dnl Check for random device. If we're cross compiling, we can't
811 dnl check, and it's better to assume it doesn't exist than it is
812 dnl to fail on AC_CHECK_FILE or later.
813 if test "$cross_compiling" = "no"; then
814 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
816 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
821 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
822 AC_SUBST(RANDOM_FILE)
823 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
824 [a suitable file/device to read random data from])
827 CARES_CHECK_OPTION_NONBLOCKING
828 CARES_CHECK_NONBLOCKING_SOCKET
830 CARES_CONFIGURE_SYMBOL_HIDING
832 CARES_PRIVATE_LIBS="$LIBS"
833 AC_SUBST(CARES_PRIVATE_LIBS)
835 CARES_CFLAG_EXTRAS=""
836 if test X"$want_werror" = Xyes; then
837 CARES_CFLAG_EXTRAS="-Werror"
839 AC_SUBST(CARES_CFLAG_EXTRAS)
841 dnl squeeze whitespace out of some variables
849 squeeze CARES_PRIVATE_LIBS
853 AC_CONFIG_FILES([Makefile libcares.pc])