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"
133 CPPFLAG_CARES_STATICLIB=""
137 use_cppflag_cares_building_library="yes"
138 AC_MSG_CHECKING([if we need CARES_STATICLIB])
139 if test "X$enable_shared" = "Xno"
142 use_cppflag_cares_staticlib="yes"
143 CPPFLAG_CARES_STATICLIB="-DCARES_STATICLIB"
152 AM_CONDITIONAL(USE_CPPFLAG_CARES_BUILDING_LIBRARY, test x$use_cppflag_cares_building_library = xyes)
153 AM_CONDITIONAL(USE_CPPFLAG_CARES_STATICLIB, test x$use_cppflag_cares_staticlib = xyes)
154 AC_SUBST(CPPFLAG_CARES_STATICLIB)
156 dnl **********************************************************************
157 dnl platform/compiler/architecture specific checks/flags
158 dnl **********************************************************************
161 CARES_SET_COMPILER_BASIC_OPTS
162 CARES_SET_COMPILER_DEBUG_OPTS
163 CARES_SET_COMPILER_OPTIMIZE_OPTS
164 CARES_SET_COMPILER_WARNING_OPTS
166 if test "$compiler_id" = "INTEL_UNIX_C"; then
168 if test "$compiler_num" -ge "1000"; then
169 dnl icc 10.X or later
170 CFLAGS="$CFLAGS -shared-intel"
171 elif test "$compiler_num" -ge "900"; then
173 CFLAGS="$CFLAGS -i-dynamic"
178 CARES_CHECK_COMPILER_HALT_ON_ERROR
179 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
180 CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
181 CARES_CHECK_COMPILER_SYMBOL_HIDING
183 CARES_CHECK_NO_UNDEFINED
184 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
186 CARES_CHECK_CURLDEBUG
187 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
189 dnl **********************************************************************
190 dnl Compilation based checks should not be done before this point.
191 dnl **********************************************************************
193 dnl **********************************************************************
194 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
195 dnl and ws2tcpip.h take precedence over any other further checks which
196 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
197 dnl this specific header files. And do them before its results are used.
198 dnl **********************************************************************
200 CURL_CHECK_HEADER_WINDOWS
201 CURL_CHECK_NATIVE_WINDOWS
202 case X-"$ac_cv_native_windows" in
204 CURL_CHECK_HEADER_WINSOCK
205 CURL_CHECK_HEADER_WINSOCK2
206 CURL_CHECK_HEADER_WS2TCPIP
209 ac_cv_header_winsock_h="no"
210 ac_cv_header_winsock2_h="no"
211 ac_cv_header_ws2tcpip_h="no"
215 dnl **********************************************************************
216 dnl Checks for libraries.
217 dnl **********************************************************************
221 dnl gethostbyname without lib or in the nsl lib?
222 AC_CHECK_FUNC(gethostbyname,
223 [HAVE_GETHOSTBYNAME="1"
225 [ AC_CHECK_LIB(nsl, gethostbyname,
226 [HAVE_GETHOSTBYNAME="1"
231 if test "$HAVE_GETHOSTBYNAME" != "1"
233 dnl gethostbyname in the socket lib?
234 AC_CHECK_LIB(socket, gethostbyname,
235 [HAVE_GETHOSTBYNAME="1"
236 LIBS="$LIBS -lsocket"
240 dnl At least one system has been identified to require BOTH nsl and socket
241 dnl libs at the same time to link properly.
242 if test "$HAVE_GETHOSTBYNAME" != "1"
244 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
245 my_ac_save_LIBS=$LIBS
246 LIBS="-lnsl -lsocket $LIBS"
254 HAVE_GETHOSTBYNAME="1"
257 LIBS=$my_ac_save_LIBS
261 if test "$HAVE_GETHOSTBYNAME" != "1"
263 dnl This is for winsock systems
264 if test "$ac_cv_header_windows_h" = "yes"; then
265 if test "$ac_cv_header_winsock_h" = "yes"; then
268 winsock_LIB="-lwinsock"
271 winsock_LIB="-lwsock32"
275 if test "$ac_cv_header_winsock2_h" = "yes"; then
276 winsock_LIB="-lws2_32"
278 if test ! -z "$winsock_LIB"; then
279 my_ac_save_LIBS=$LIBS
280 LIBS="$winsock_LIB $LIBS"
281 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
284 #ifdef HAVE_WINDOWS_H
285 #ifndef WIN32_LEAN_AND_MEAN
286 #define WIN32_LEAN_AND_MEAN
289 #ifdef HAVE_WINSOCK2_H
290 #include <winsock2.h>
292 #ifdef HAVE_WINSOCK_H
298 gethostbyname("www.dummysite.com");
302 HAVE_GETHOSTBYNAME="1"
306 LIBS=$my_ac_save_LIBS
312 if test "$HAVE_GETHOSTBYNAME" != "1"
314 dnl This is for Minix 3.1
315 AC_MSG_CHECKING([for gethostbyname for Minix 3])
318 /* Older Minix versions may need <net/gen/netdb.h> here instead */
321 gethostbyname("www.dummysite.com");
325 HAVE_GETHOSTBYNAME="1"
331 if test "$HAVE_GETHOSTBYNAME" != "1"
333 dnl This is for eCos with a stubbed DNS implementation
334 AC_MSG_CHECKING([for gethostbyname for eCos])
340 gethostbyname("www.dummysite.com");
344 HAVE_GETHOSTBYNAME="1"
350 if test "$HAVE_GETHOSTBYNAME" != "1"
352 dnl gethostbyname in the net lib - for BeOS
353 AC_CHECK_LIB(net, gethostbyname,
354 [HAVE_GETHOSTBYNAME="1"
360 if test "$HAVE_GETHOSTBYNAME" != "1"; then
361 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
365 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
367 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
368 AC_CHECK_LIB(resolve, strcasecmp,
369 [LIBS="-lresolve $LIBS"],
373 ac_cv_func_strcasecmp="no"
375 CARES_CHECK_LIBS_CONNECT
377 dnl **********************************************************************
378 dnl In case that function clock_gettime with monotonic timer is available,
379 dnl check for additional required libraries.
380 dnl **********************************************************************
381 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
383 AC_MSG_CHECKING([whether to use libgcc])
384 AC_ARG_ENABLE(libgcc,
385 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
386 [ case "$enableval" in
398 dnl Let's hope this split URL remains working:
399 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
400 dnl genprogc/thread_quick_ref.htm
403 dnl **********************************************************************
404 dnl Back to "normal" configuring
405 dnl **********************************************************************
407 dnl Checks for header files.
410 CURL_CHECK_HEADER_MALLOC
411 CURL_CHECK_HEADER_MEMORY
413 dnl check for a few basic system headers we need
434 arpa/nameser_compat.h \
436 dnl to do if not found
442 #ifdef HAVE_SYS_TYPES_H
443 #include <sys/types.h>
445 #ifdef HAVE_SYS_TIME_H
446 #include <sys/time.h>
448 dnl We do this default-include simply to make sure that the nameser_compat.h
449 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
450 dnl (and others?) is not designed to allow this.
451 #ifdef HAVE_ARPA_NAMESER_H
452 #include <arpa/nameser.h>
455 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
456 #ifdef HAVE_SYS_SOCKET_H
457 #include <sys/socket.h>
459 #ifdef HAVE_NETINET_IN_H
460 #include <netinet/in.h>
465 dnl Checks for typedefs, structures, and compiler characteristics.
469 CURL_CHECK_STRUCT_TIMEVAL
471 AC_CHECK_SIZEOF(size_t)
472 AC_CHECK_SIZEOF(long)
474 AC_CHECK_SIZEOF(short)
476 AC_CHECK_SIZEOF(time_t)
478 AC_CHECK_TYPE(long long,
479 [AC_DEFINE(HAVE_LONGLONG, 1,
480 [Define to 1 if the compiler supports the 'long long' data type.])]
484 if test "xyes" = "x$longlong"; then
485 AC_MSG_CHECKING([if numberLL works])
489 long long val = 1000LL;
493 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
501 AC_CHECK_TYPE(ssize_t, ,
502 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
504 # check for bool type
505 AC_CHECK_TYPE([bool],[
506 AC_DEFINE(HAVE_BOOL_T, 1,
507 [Define to 1 if bool is an available type.])
509 #ifdef HAVE_SYS_TYPES_H
510 #include <sys/types.h>
512 #ifdef HAVE_STDBOOL_H
517 CARES_CONFIGURE_ARES_SOCKLEN_T
521 TYPE_SOCKADDR_STORAGE
528 CURL_CHECK_FUNC_RECVFROM
530 CURL_CHECK_MSG_NOSIGNAL
532 CARES_CHECK_FUNC_CLOSESOCKET
533 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
534 CARES_CHECK_FUNC_CONNECT
535 CARES_CHECK_FUNC_FCNTL
536 CARES_CHECK_FUNC_FREEADDRINFO
537 CARES_CHECK_FUNC_GETADDRINFO
538 CARES_CHECK_FUNC_GETENV
539 CARES_CHECK_FUNC_GETHOSTBYADDR
540 CARES_CHECK_FUNC_GETHOSTBYNAME
541 CARES_CHECK_FUNC_GETHOSTNAME
542 CARES_CHECK_FUNC_GETSERVBYPORT_R
543 CARES_CHECK_FUNC_INET_NET_PTON
544 CARES_CHECK_FUNC_INET_NTOP
545 CARES_CHECK_FUNC_INET_PTON
546 CARES_CHECK_FUNC_IOCTL
547 CARES_CHECK_FUNC_IOCTLSOCKET
548 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
549 CARES_CHECK_FUNC_SETSOCKOPT
550 CARES_CHECK_FUNC_SOCKET
551 CARES_CHECK_FUNC_STRCASECMP
552 CARES_CHECK_FUNC_STRCMPI
553 CARES_CHECK_FUNC_STRDUP
554 CARES_CHECK_FUNC_STRICMP
555 CARES_CHECK_FUNC_STRNCASECMP
556 CARES_CHECK_FUNC_STRNCMPI
557 CARES_CHECK_FUNC_STRNICMP
558 CARES_CHECK_FUNC_WRITEV
561 dnl check for AF_INET6
562 CARES_CHECK_CONSTANT(
565 #ifdef HAVE_WINDOWS_H
566 #ifndef WIN32_LEAN_AND_MEAN
567 #define WIN32_LEAN_AND_MEAN
570 #ifdef HAVE_WINSOCK2_H
571 #include <winsock2.h>
574 #ifdef HAVE_SYS_TYPES_H
575 #include <sys/types.h>
577 #ifdef HAVE_SYS_SOCKET_H
578 #include <sys/socket.h>
582 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
585 dnl check for PF_INET6
586 CARES_CHECK_CONSTANT(
589 #ifdef HAVE_WINDOWS_H
590 #ifndef WIN32_LEAN_AND_MEAN
591 #define WIN32_LEAN_AND_MEAN
594 #ifdef HAVE_WINSOCK2_H
595 #include <winsock2.h>
598 #ifdef HAVE_SYS_TYPES_H
599 #include <sys/types.h>
601 #ifdef HAVE_SYS_SOCKET_H
602 #include <sys/socket.h>
606 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
610 dnl check for the in6_addr structure
614 #ifdef HAVE_WINDOWS_H
615 #ifndef WIN32_LEAN_AND_MEAN
616 #define WIN32_LEAN_AND_MEAN
619 #ifdef HAVE_WINSOCK2_H
620 #include <winsock2.h>
621 #ifdef HAVE_WS2TCPIP_H
622 #include <ws2tcpip.h>
626 #ifdef HAVE_SYS_TYPES_H
627 #include <sys/types.h>
629 #ifdef HAVE_NETINET_IN_H
630 #include <netinet/in.h>
634 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
637 dnl check for the sockaddr_in6 structure
641 #ifdef HAVE_WINDOWS_H
642 #ifndef WIN32_LEAN_AND_MEAN
643 #define WIN32_LEAN_AND_MEAN
646 #ifdef HAVE_WINSOCK2_H
647 #include <winsock2.h>
648 #ifdef HAVE_WS2TCPIP_H
649 #include <ws2tcpip.h>
653 #ifdef HAVE_SYS_TYPES_H
654 #include <sys/types.h>
656 #ifdef HAVE_NETINET_IN_H
657 #include <netinet/in.h>
661 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
662 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
665 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
666 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
667 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
671 #ifdef HAVE_WINDOWS_H
672 #ifndef WIN32_LEAN_AND_MEAN
673 #define WIN32_LEAN_AND_MEAN
676 #ifdef HAVE_WINSOCK2_H
677 #include <winsock2.h>
678 #ifdef HAVE_WS2TCPIP_H
679 #include <ws2tcpip.h>
683 #ifdef HAVE_SYS_TYPES_H
684 #include <sys/types.h>
686 #ifdef HAVE_NETINET_IN_H
687 #include <netinet/in.h>
692 dnl check for the addrinfo structure
693 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
694 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
695 [Define to 1 if you have struct addrinfo.]),,
698 #ifdef HAVE_WINDOWS_H
699 #ifndef WIN32_LEAN_AND_MEAN
700 #define WIN32_LEAN_AND_MEAN
703 #ifdef HAVE_WINSOCK2_H
704 #include <winsock2.h>
705 #ifdef HAVE_WS2TCPIP_H
706 #include <ws2tcpip.h>
710 #ifdef HAVE_SYS_TYPES_H
711 #include <sys/types.h>
713 #ifdef HAVE_NETINET_IN_H
714 #include <netinet/in.h>
716 #ifdef HAVE_SYS_SOCKET_H
717 #include <sys/socket.h>
727 AC_CHECK_FUNCS([bitncmp \
733 AC_MSG_CHECKING([deeper for $func])
741 eval "ac_cv_func_$func=yes"
742 AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
743 [Define to 1 if you have the $func function.])
745 AC_MSG_RESULT([but still no])
750 AC_CHECK_SIZEOF(struct in6_addr, ,
753 #ifdef HAVE_WINDOWS_H
754 #ifndef WIN32_LEAN_AND_MEAN
755 #define WIN32_LEAN_AND_MEAN
758 #ifdef HAVE_WINSOCK2_H
759 #include <winsock2.h>
760 #ifdef HAVE_WS2TCPIP_H
761 #include <ws2tcpip.h>
765 #ifdef HAVE_SYS_TYPES_H
766 #include <sys/types.h>
768 #ifdef HAVE_SYS_SOCKET_H
769 #include <sys/socket.h>
771 #ifdef HAVE_NETINET_IN_H
772 #include <netinet/in.h>
778 AC_CHECK_SIZEOF(struct in_addr, ,
781 #ifdef HAVE_WINDOWS_H
782 #ifndef WIN32_LEAN_AND_MEAN
783 #define WIN32_LEAN_AND_MEAN
786 #ifdef HAVE_WINSOCK2_H
787 #include <winsock2.h>
788 #ifdef HAVE_WS2TCPIP_H
789 #include <ws2tcpip.h>
793 #ifdef HAVE_SYS_TYPES_H
794 #include <sys/types.h>
796 #ifdef HAVE_SYS_SOCKET_H
797 #include <sys/socket.h>
799 #ifdef HAVE_NETINET_IN_H
800 #include <netinet/in.h>
807 dnl Check if the getnameinfo function is available
808 dnl and get the types of five of its arguments.
809 CURL_CHECK_FUNC_GETNAMEINFO
813 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
814 [define this if ares is built for a big endian system])],
816 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
819 dnl Check for user-specified random device
821 AC_HELP_STRING([--with-random=FILE],
822 [read randomness from FILE (default=/dev/urandom)]),
823 [ RANDOM_FILE="$withval" ],
825 dnl Check for random device. If we're cross compiling, we can't
826 dnl check, and it's better to assume it doesn't exist than it is
827 dnl to fail on AC_CHECK_FILE or later.
828 if test "$cross_compiling" = "no"; then
829 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
831 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
836 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
837 AC_SUBST(RANDOM_FILE)
838 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
839 [a suitable file/device to read random data from])
842 CARES_CHECK_OPTION_NONBLOCKING
843 CARES_CHECK_NONBLOCKING_SOCKET
845 CARES_CONFIGURE_SYMBOL_HIDING
847 CARES_PRIVATE_LIBS="$LIBS"
848 AC_SUBST(CARES_PRIVATE_LIBS)
850 CARES_CFLAG_EXTRAS=""
851 if test X"$want_werror" = Xyes; then
852 CARES_CFLAG_EXTRAS="-Werror"
854 AC_SUBST(CARES_CFLAG_EXTRAS)
856 dnl squeeze whitespace out of some variables
864 squeeze CARES_PRIVATE_LIBS
866 AC_CONFIG_FILES([Makefile libcares.pc])