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])
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 CARES_CHECK_PATH_SEPARATOR_REQUIRED
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
75 dnl Detect the canonical host and target build environment
79 dnl Get system canonical name
80 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
86 dnl This defines _ALL_SOURCE for AIX
87 CARES_CHECK_AIX_ALL_SOURCE
89 dnl Our configure and build reentrant settings
90 CARES_CONFIGURE_THREAD_SAFE
91 CARES_CONFIGURE_REENTRANT
93 dnl check for how to do large files
98 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
102 dnl support building of Windows DLLs
105 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
106 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
108 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
117 AC_MSG_CHECKING([if compiler is icc (to build with PIC)])
131 AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY])
132 use_cppflag_cares_building_library="no"
133 use_cppflag_cares_staticlib="no"
134 CPPFLAG_CARES_STATICLIB=""
138 use_cppflag_cares_building_library="yes"
139 AC_MSG_CHECKING([if we need CARES_STATICLIB])
140 if test "X$enable_shared" = "Xno"
143 use_cppflag_cares_staticlib="yes"
144 CPPFLAG_CARES_STATICLIB="-DCARES_STATICLIB"
153 AM_CONDITIONAL(USE_CPPFLAG_CARES_BUILDING_LIBRARY, test x$use_cppflag_cares_building_library = xyes)
154 AM_CONDITIONAL(USE_CPPFLAG_CARES_STATICLIB, test x$use_cppflag_cares_staticlib = xyes)
155 AC_SUBST(CPPFLAG_CARES_STATICLIB)
157 dnl **********************************************************************
158 dnl platform/compiler/architecture specific checks/flags
159 dnl **********************************************************************
162 CARES_SET_COMPILER_BASIC_OPTS
163 CARES_SET_COMPILER_DEBUG_OPTS
164 CARES_SET_COMPILER_OPTIMIZE_OPTS
165 CARES_SET_COMPILER_WARNING_OPTS
167 if test "$compiler_id" = "INTEL_UNIX_C"; then
169 if test "$compiler_num" -ge "1000"; then
170 dnl icc 10.X or later
171 CFLAGS="$CFLAGS -shared-intel"
172 elif test "$compiler_num" -ge "900"; then
174 CFLAGS="$CFLAGS -i-dynamic"
179 CARES_CHECK_COMPILER_HALT_ON_ERROR
180 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
181 CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
182 CARES_CHECK_COMPILER_SYMBOL_HIDING
184 CARES_CHECK_NO_UNDEFINED
185 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
187 CARES_CHECK_CURLDEBUG
188 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
190 dnl **********************************************************************
191 dnl Compilation based checks should not be done before this point.
192 dnl **********************************************************************
194 dnl **********************************************************************
195 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
196 dnl and ws2tcpip.h take precedence over any other further checks which
197 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
198 dnl this specific header files. And do them before its results are used.
199 dnl **********************************************************************
201 CURL_CHECK_HEADER_WINDOWS
202 CURL_CHECK_NATIVE_WINDOWS
203 case X-"$ac_cv_native_windows" in
205 CURL_CHECK_HEADER_WINSOCK
206 CURL_CHECK_HEADER_WINSOCK2
207 CURL_CHECK_HEADER_WS2TCPIP
210 ac_cv_header_winsock_h="no"
211 ac_cv_header_winsock2_h="no"
212 ac_cv_header_ws2tcpip_h="no"
216 dnl **********************************************************************
217 dnl Checks for libraries.
218 dnl **********************************************************************
222 dnl gethostbyname without lib or in the nsl lib?
223 AC_CHECK_FUNC(gethostbyname,
224 [HAVE_GETHOSTBYNAME="1"
226 [ AC_CHECK_LIB(nsl, gethostbyname,
227 [HAVE_GETHOSTBYNAME="1"
232 if test "$HAVE_GETHOSTBYNAME" != "1"
234 dnl gethostbyname in the socket lib?
235 AC_CHECK_LIB(socket, gethostbyname,
236 [HAVE_GETHOSTBYNAME="1"
237 LIBS="$LIBS -lsocket"
241 dnl At least one system has been identified to require BOTH nsl and socket
242 dnl libs at the same time to link properly.
243 if test "$HAVE_GETHOSTBYNAME" != "1"
245 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
246 my_ac_save_LIBS=$LIBS
247 LIBS="-lnsl -lsocket $LIBS"
255 HAVE_GETHOSTBYNAME="1"
258 LIBS=$my_ac_save_LIBS
262 if test "$HAVE_GETHOSTBYNAME" != "1"
264 dnl This is for winsock systems
265 if test "$ac_cv_header_windows_h" = "yes"; then
266 if test "$ac_cv_header_winsock_h" = "yes"; then
269 winsock_LIB="-lwinsock"
272 winsock_LIB="-lwsock32"
276 if test "$ac_cv_header_winsock2_h" = "yes"; then
277 winsock_LIB="-lws2_32"
279 if test ! -z "$winsock_LIB"; then
280 my_ac_save_LIBS=$LIBS
281 LIBS="$winsock_LIB $LIBS"
282 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
285 #ifdef HAVE_WINDOWS_H
286 #ifndef WIN32_LEAN_AND_MEAN
287 #define WIN32_LEAN_AND_MEAN
290 #ifdef HAVE_WINSOCK2_H
291 #include <winsock2.h>
293 #ifdef HAVE_WINSOCK_H
299 gethostbyname("www.dummysite.com");
303 HAVE_GETHOSTBYNAME="1"
307 LIBS=$my_ac_save_LIBS
313 if test "$HAVE_GETHOSTBYNAME" != "1"
315 dnl This is for Minix 3.1
316 AC_MSG_CHECKING([for gethostbyname for Minix 3])
319 /* Older Minix versions may need <net/gen/netdb.h> here instead */
322 gethostbyname("www.dummysite.com");
326 HAVE_GETHOSTBYNAME="1"
332 if test "$HAVE_GETHOSTBYNAME" != "1"
334 dnl This is for eCos with a stubbed DNS implementation
335 AC_MSG_CHECKING([for gethostbyname for eCos])
341 gethostbyname("www.dummysite.com");
345 HAVE_GETHOSTBYNAME="1"
351 if test "$HAVE_GETHOSTBYNAME" != "1"
353 dnl gethostbyname in the net lib - for BeOS
354 AC_CHECK_LIB(net, gethostbyname,
355 [HAVE_GETHOSTBYNAME="1"
361 if test "$HAVE_GETHOSTBYNAME" != "1"; then
362 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
366 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
368 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
369 AC_CHECK_LIB(resolve, strcasecmp,
370 [LIBS="-lresolve $LIBS"],
374 ac_cv_func_strcasecmp="no"
376 CARES_CHECK_LIBS_CONNECT
378 dnl **********************************************************************
379 dnl In case that function clock_gettime with monotonic timer is available,
380 dnl check for additional required libraries.
381 dnl **********************************************************************
382 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
384 AC_MSG_CHECKING([whether to use libgcc])
385 AC_ARG_ENABLE(libgcc,
386 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
387 [ case "$enableval" in
399 dnl Let's hope this split URL remains working:
400 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
401 dnl genprogc/thread_quick_ref.htm
404 dnl **********************************************************************
405 dnl Back to "normal" configuring
406 dnl **********************************************************************
408 dnl Checks for header files.
411 CURL_CHECK_HEADER_MALLOC
412 CURL_CHECK_HEADER_MEMORY
414 dnl check for a few basic system headers we need
435 arpa/nameser_compat.h \
437 dnl to do if not found
443 #ifdef HAVE_SYS_TYPES_H
444 #include <sys/types.h>
446 #ifdef HAVE_SYS_TIME_H
447 #include <sys/time.h>
449 dnl We do this default-include simply to make sure that the nameser_compat.h
450 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
451 dnl (and others?) is not designed to allow this.
452 #ifdef HAVE_ARPA_NAMESER_H
453 #include <arpa/nameser.h>
456 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
457 #ifdef HAVE_SYS_SOCKET_H
458 #include <sys/socket.h>
460 #ifdef HAVE_NETINET_IN_H
461 #include <netinet/in.h>
466 dnl Checks for typedefs, structures, and compiler characteristics.
470 CURL_CHECK_STRUCT_TIMEVAL
472 AC_CHECK_SIZEOF(size_t)
473 AC_CHECK_SIZEOF(long)
475 AC_CHECK_SIZEOF(short)
477 AC_CHECK_SIZEOF(time_t)
479 AC_CHECK_TYPE(long long,
480 [AC_DEFINE(HAVE_LONGLONG, 1,
481 [Define to 1 if the compiler supports the 'long long' data type.])]
485 if test "xyes" = "x$longlong"; then
486 AC_MSG_CHECKING([if numberLL works])
490 long long val = 1000LL;
494 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
502 AC_CHECK_TYPE(ssize_t, ,
503 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
505 # check for bool type
506 AC_CHECK_TYPE([bool],[
507 AC_DEFINE(HAVE_BOOL_T, 1,
508 [Define to 1 if bool is an available type.])
510 #ifdef HAVE_SYS_TYPES_H
511 #include <sys/types.h>
513 #ifdef HAVE_STDBOOL_H
518 CARES_CONFIGURE_ARES_SOCKLEN_T
522 TYPE_SOCKADDR_STORAGE
529 CURL_CHECK_FUNC_RECVFROM
531 CURL_CHECK_MSG_NOSIGNAL
533 CARES_CHECK_FUNC_CLOSESOCKET
534 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
535 CARES_CHECK_FUNC_CONNECT
536 CARES_CHECK_FUNC_FCNTL
537 CARES_CHECK_FUNC_FREEADDRINFO
538 CARES_CHECK_FUNC_GETADDRINFO
539 CARES_CHECK_FUNC_GETENV
540 CARES_CHECK_FUNC_GETHOSTBYADDR
541 CARES_CHECK_FUNC_GETHOSTBYNAME
542 CARES_CHECK_FUNC_GETHOSTNAME
543 CARES_CHECK_FUNC_GETSERVBYPORT_R
544 CARES_CHECK_FUNC_INET_NET_PTON
545 CARES_CHECK_FUNC_INET_NTOP
546 CARES_CHECK_FUNC_INET_PTON
547 CARES_CHECK_FUNC_IOCTL
548 CARES_CHECK_FUNC_IOCTLSOCKET
549 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
550 CARES_CHECK_FUNC_SETSOCKOPT
551 CARES_CHECK_FUNC_SOCKET
552 CARES_CHECK_FUNC_STRCASECMP
553 CARES_CHECK_FUNC_STRCMPI
554 CARES_CHECK_FUNC_STRDUP
555 CARES_CHECK_FUNC_STRICMP
556 CARES_CHECK_FUNC_STRNCASECMP
557 CARES_CHECK_FUNC_STRNCMPI
558 CARES_CHECK_FUNC_STRNICMP
559 CARES_CHECK_FUNC_WRITEV
562 dnl check for AF_INET6
563 CARES_CHECK_CONSTANT(
566 #ifdef HAVE_WINDOWS_H
567 #ifndef WIN32_LEAN_AND_MEAN
568 #define WIN32_LEAN_AND_MEAN
571 #ifdef HAVE_WINSOCK2_H
572 #include <winsock2.h>
575 #ifdef HAVE_SYS_TYPES_H
576 #include <sys/types.h>
578 #ifdef HAVE_SYS_SOCKET_H
579 #include <sys/socket.h>
583 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
586 dnl check for PF_INET6
587 CARES_CHECK_CONSTANT(
590 #ifdef HAVE_WINDOWS_H
591 #ifndef WIN32_LEAN_AND_MEAN
592 #define WIN32_LEAN_AND_MEAN
595 #ifdef HAVE_WINSOCK2_H
596 #include <winsock2.h>
599 #ifdef HAVE_SYS_TYPES_H
600 #include <sys/types.h>
602 #ifdef HAVE_SYS_SOCKET_H
603 #include <sys/socket.h>
607 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
611 dnl check for the in6_addr structure
615 #ifdef HAVE_WINDOWS_H
616 #ifndef WIN32_LEAN_AND_MEAN
617 #define WIN32_LEAN_AND_MEAN
620 #ifdef HAVE_WINSOCK2_H
621 #include <winsock2.h>
622 #ifdef HAVE_WS2TCPIP_H
623 #include <ws2tcpip.h>
627 #ifdef HAVE_SYS_TYPES_H
628 #include <sys/types.h>
630 #ifdef HAVE_NETINET_IN_H
631 #include <netinet/in.h>
635 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
638 dnl check for the sockaddr_in6 structure
642 #ifdef HAVE_WINDOWS_H
643 #ifndef WIN32_LEAN_AND_MEAN
644 #define WIN32_LEAN_AND_MEAN
647 #ifdef HAVE_WINSOCK2_H
648 #include <winsock2.h>
649 #ifdef HAVE_WS2TCPIP_H
650 #include <ws2tcpip.h>
654 #ifdef HAVE_SYS_TYPES_H
655 #include <sys/types.h>
657 #ifdef HAVE_NETINET_IN_H
658 #include <netinet/in.h>
662 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
663 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
666 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
667 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
668 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
672 #ifdef HAVE_WINDOWS_H
673 #ifndef WIN32_LEAN_AND_MEAN
674 #define WIN32_LEAN_AND_MEAN
677 #ifdef HAVE_WINSOCK2_H
678 #include <winsock2.h>
679 #ifdef HAVE_WS2TCPIP_H
680 #include <ws2tcpip.h>
684 #ifdef HAVE_SYS_TYPES_H
685 #include <sys/types.h>
687 #ifdef HAVE_NETINET_IN_H
688 #include <netinet/in.h>
693 dnl check for the addrinfo structure
694 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
695 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
696 [Define to 1 if you have struct addrinfo.]),,
699 #ifdef HAVE_WINDOWS_H
700 #ifndef WIN32_LEAN_AND_MEAN
701 #define WIN32_LEAN_AND_MEAN
704 #ifdef HAVE_WINSOCK2_H
705 #include <winsock2.h>
706 #ifdef HAVE_WS2TCPIP_H
707 #include <ws2tcpip.h>
711 #ifdef HAVE_SYS_TYPES_H
712 #include <sys/types.h>
714 #ifdef HAVE_NETINET_IN_H
715 #include <netinet/in.h>
717 #ifdef HAVE_SYS_SOCKET_H
718 #include <sys/socket.h>
728 AC_CHECK_FUNCS([bitncmp \
734 AC_MSG_CHECKING([deeper for $func])
742 eval "ac_cv_func_$func=yes"
743 AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
744 [Define to 1 if you have the $func function.])
746 AC_MSG_RESULT([but still no])
751 AC_CHECK_SIZEOF(struct in6_addr, ,
754 #ifdef HAVE_WINDOWS_H
755 #ifndef WIN32_LEAN_AND_MEAN
756 #define WIN32_LEAN_AND_MEAN
759 #ifdef HAVE_WINSOCK2_H
760 #include <winsock2.h>
761 #ifdef HAVE_WS2TCPIP_H
762 #include <ws2tcpip.h>
766 #ifdef HAVE_SYS_TYPES_H
767 #include <sys/types.h>
769 #ifdef HAVE_SYS_SOCKET_H
770 #include <sys/socket.h>
772 #ifdef HAVE_NETINET_IN_H
773 #include <netinet/in.h>
779 AC_CHECK_SIZEOF(struct in_addr, ,
782 #ifdef HAVE_WINDOWS_H
783 #ifndef WIN32_LEAN_AND_MEAN
784 #define WIN32_LEAN_AND_MEAN
787 #ifdef HAVE_WINSOCK2_H
788 #include <winsock2.h>
789 #ifdef HAVE_WS2TCPIP_H
790 #include <ws2tcpip.h>
794 #ifdef HAVE_SYS_TYPES_H
795 #include <sys/types.h>
797 #ifdef HAVE_SYS_SOCKET_H
798 #include <sys/socket.h>
800 #ifdef HAVE_NETINET_IN_H
801 #include <netinet/in.h>
808 dnl Check if the getnameinfo function is available
809 dnl and get the types of five of its arguments.
810 CURL_CHECK_FUNC_GETNAMEINFO
814 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
815 [define this if ares is built for a big endian system])],
817 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
820 dnl Check for user-specified random device
822 AC_HELP_STRING([--with-random=FILE],
823 [read randomness from FILE (default=/dev/urandom)]),
824 [ RANDOM_FILE="$withval" ],
826 dnl Check for random device. If we're cross compiling, we can't
827 dnl check, and it's better to assume it doesn't exist than it is
828 dnl to fail on AC_CHECK_FILE or later.
829 if test "$cross_compiling" = "no"; then
830 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
832 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
837 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
838 AC_SUBST(RANDOM_FILE)
839 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
840 [a suitable file/device to read random data from])
843 CARES_CHECK_OPTION_NONBLOCKING
844 CARES_CHECK_NONBLOCKING_SOCKET
846 CARES_CONFIGURE_SYMBOL_HIDING
848 CARES_PRIVATE_LIBS="$LIBS"
849 AC_SUBST(CARES_PRIVATE_LIBS)
851 CARES_CFLAG_EXTRAS=""
852 if test X"$want_werror" = Xyes; then
853 CARES_CFLAG_EXTRAS="-Werror"
855 AC_SUBST(CARES_CFLAG_EXTRAS)
857 dnl squeeze whitespace out of some variables
865 squeeze CARES_PRIVATE_LIBS
867 AC_CONFIG_FILES([Makefile libcares.pc])