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])
7 CARES_OVERRIDE_AUTOCONF
9 AC_CONFIG_SRCDIR([ares_ipv6.h])
10 AM_CONFIG_HEADER([ares_config.h ares_build.h])
13 CARES_CHECK_OPTION_DEBUG
14 CARES_CHECK_OPTION_OPTIMIZE
15 CARES_CHECK_OPTION_WARNINGS
16 CARES_CHECK_OPTION_WERROR
17 CARES_CHECK_OPTION_CURLDEBUG
18 CARES_CHECK_OPTION_SYMBOL_HIDING
20 CARES_CHECK_PATH_SEPARATOR_REQUIRED
22 dnl SED is mandatory for configure process and libtool.
23 dnl Set it now, allowing it to be changed later.
24 AC_PATH_PROG([SED], [sed], [not_found],
25 [$PATH:/usr/bin:/usr/local/bin])
26 if test -z "$SED" || test "$SED" = "not_found"; then
27 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
31 dnl GREP is mandatory for configure process and libtool.
32 dnl Set it now, allowing it to be changed later.
33 AC_PATH_PROG([GREP], [grep], [not_found],
34 [$PATH:/usr/bin:/usr/local/bin])
35 if test -z "$GREP" || test "$GREP" = "not_found"; then
36 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
40 dnl EGREP is mandatory for configure process and libtool.
41 dnl Set it now, allowing it to be changed later.
42 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
43 AC_MSG_CHECKING([for egrep])
45 AC_MSG_RESULT([$EGREP])
47 AC_PATH_PROG([EGREP], [egrep], [not_found],
48 [$PATH:/usr/bin:/usr/local/bin])
50 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
51 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
55 dnl AR is mandatory for configure process and libtool.
56 dnl This is target dependent, so check it as a tool.
57 AC_PATH_TOOL([AR], [ar], [not_found],
58 [$PATH:/usr/bin:/usr/local/bin])
59 if test -z "$AR" || test "$AR" = "not_found"; then
60 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
64 dnl Remove non-configure distributed ares_build.h
65 if test -f ${srcdir}/ares_build.h; then
66 rm -f ${srcdir}/ares_build.h
72 dnl Detect the canonical host and target build environment
76 dnl Get system canonical name
77 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
83 dnl This defines _ALL_SOURCE for AIX
84 CARES_CHECK_AIX_ALL_SOURCE
86 dnl Our configure and build reentrant settings
87 CARES_CONFIGURE_THREAD_SAFE
88 CARES_CONFIGURE_REENTRANT
90 dnl check for how to do large files
95 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
99 dnl support building of Windows DLLs
102 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
103 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
105 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
114 AC_MSG_CHECKING([if compiler is icc (to build with PIC)])
128 AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY])
131 AC_DEFINE(CARES_BUILDING_LIBRARY, 1, [when building c-ares library])
133 AC_MSG_CHECKING([if we need CARES_STATICLIB])
134 if test "X$enable_shared" = "Xno"
136 AC_DEFINE(CARES_STATICLIB, 1, [when not building a shared library])
147 dnl **********************************************************************
148 dnl platform/compiler/architecture specific checks/flags
149 dnl **********************************************************************
152 CARES_SET_COMPILER_BASIC_OPTS
153 CARES_SET_COMPILER_DEBUG_OPTS
154 CARES_SET_COMPILER_OPTIMIZE_OPTS
155 CARES_SET_COMPILER_WARNING_OPTS
157 if test "$compiler_id" = "INTEL_UNIX_C"; then
159 if test "$compiler_num" -ge "1000"; then
160 dnl icc 10.X or later
161 CFLAGS="$CFLAGS -shared-intel"
162 elif test "$compiler_num" -ge "900"; then
164 CFLAGS="$CFLAGS -i-dynamic"
169 CARES_CHECK_COMPILER_HALT_ON_ERROR
170 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
171 CARES_CHECK_COMPILER_SYMBOL_HIDING
173 CARES_CHECK_NO_UNDEFINED
174 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
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()])
355 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
357 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
358 AC_CHECK_LIB(resolve, strcasecmp,
359 [LIBS="-lresolve $LIBS"],
363 ac_cv_func_strcasecmp="no"
365 CARES_CHECK_LIBS_CONNECT
367 dnl **********************************************************************
368 dnl In case that function clock_gettime with monotonic timer is available,
369 dnl check for additional required libraries.
370 dnl **********************************************************************
371 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
373 AC_MSG_CHECKING([whether to use libgcc])
374 AC_ARG_ENABLE(libgcc,
375 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
376 [ case "$enableval" in
388 dnl Let's hope this split URL remains working:
389 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
390 dnl genprogc/thread_quick_ref.htm
393 dnl **********************************************************************
394 dnl Back to "normal" configuring
395 dnl **********************************************************************
397 dnl Checks for header files.
400 CURL_CHECK_HEADER_MALLOC
401 CURL_CHECK_HEADER_MEMORY
403 dnl check for a few basic system headers we need
424 arpa/nameser_compat.h \
426 dnl to do if not found
432 #ifdef HAVE_SYS_TYPES_H
433 #include <sys/types.h>
435 #ifdef HAVE_SYS_TIME_H
436 #include <sys/time.h>
438 dnl We do this default-include simply to make sure that the nameser_compat.h
439 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
440 dnl (and others?) is not designed to allow this.
441 #ifdef HAVE_ARPA_NAMESER_H
442 #include <arpa/nameser.h>
445 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
446 #ifdef HAVE_SYS_SOCKET_H
447 #include <sys/socket.h>
449 #ifdef HAVE_NETINET_IN_H
450 #include <netinet/in.h>
455 dnl Checks for typedefs, structures, and compiler characteristics.
459 CURL_CHECK_STRUCT_TIMEVAL
461 AC_CHECK_SIZEOF(size_t)
463 AC_CHECK_SIZEOF(long)
465 AC_CHECK_SIZEOF(time_t)
467 AC_CHECK_TYPE(long long,
468 [AC_DEFINE(HAVE_LONGLONG, 1,
469 [Define to 1 if the compiler supports the 'long long' data type.])]
473 if test "xyes" = "x$longlong"; then
474 AC_MSG_CHECKING([if numberLL works])
478 long long val = 1000LL;
482 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
490 AC_CHECK_TYPE(ssize_t, ,
491 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
493 # check for bool type
494 AC_CHECK_TYPE([bool],[
495 AC_DEFINE(HAVE_BOOL_T, 1,
496 [Define to 1 if bool is an available type.])
498 #ifdef HAVE_SYS_TYPES_H
499 #include <sys/types.h>
501 #ifdef HAVE_STDBOOL_H
506 CARES_CONFIGURE_ARES_SOCKLEN_T
510 TYPE_SOCKADDR_STORAGE
517 CURL_CHECK_FUNC_RECVFROM
519 CURL_CHECK_MSG_NOSIGNAL
521 CARES_CHECK_FUNC_CLOSESOCKET
522 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
523 CARES_CHECK_FUNC_CONNECT
524 CARES_CHECK_FUNC_FCNTL
525 CARES_CHECK_FUNC_FREEADDRINFO
526 CARES_CHECK_FUNC_GETADDRINFO
527 CARES_CHECK_FUNC_GETHOSTBYADDR
528 CARES_CHECK_FUNC_GETHOSTBYNAME
529 CARES_CHECK_FUNC_GETHOSTNAME
530 CARES_CHECK_FUNC_GETSERVBYPORT_R
531 CARES_CHECK_FUNC_INET_NET_PTON
532 CARES_CHECK_FUNC_INET_NTOP
533 CARES_CHECK_FUNC_INET_PTON
534 CARES_CHECK_FUNC_IOCTL
535 CARES_CHECK_FUNC_IOCTLSOCKET
536 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
537 CARES_CHECK_FUNC_SETSOCKOPT
538 CARES_CHECK_FUNC_SOCKET
539 CARES_CHECK_FUNC_STRCASECMP
540 CARES_CHECK_FUNC_STRCMPI
541 CARES_CHECK_FUNC_STRDUP
542 CARES_CHECK_FUNC_STRICMP
543 CARES_CHECK_FUNC_STRNCASECMP
544 CARES_CHECK_FUNC_STRNCMPI
545 CARES_CHECK_FUNC_STRNICMP
546 CARES_CHECK_FUNC_WRITEV
549 dnl check for AF_INET6
550 CARES_CHECK_CONSTANT(
553 #ifdef HAVE_WINDOWS_H
554 #ifndef WIN32_LEAN_AND_MEAN
555 #define WIN32_LEAN_AND_MEAN
558 #ifdef HAVE_WINSOCK2_H
559 #include <winsock2.h>
562 #ifdef HAVE_SYS_TYPES_H
563 #include <sys/types.h>
565 #ifdef HAVE_SYS_SOCKET_H
566 #include <sys/socket.h>
570 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
573 dnl check for PF_INET6
574 CARES_CHECK_CONSTANT(
577 #ifdef HAVE_WINDOWS_H
578 #ifndef WIN32_LEAN_AND_MEAN
579 #define WIN32_LEAN_AND_MEAN
582 #ifdef HAVE_WINSOCK2_H
583 #include <winsock2.h>
586 #ifdef HAVE_SYS_TYPES_H
587 #include <sys/types.h>
589 #ifdef HAVE_SYS_SOCKET_H
590 #include <sys/socket.h>
594 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
598 dnl check for the in6_addr structure
602 #ifdef HAVE_WINDOWS_H
603 #ifndef WIN32_LEAN_AND_MEAN
604 #define WIN32_LEAN_AND_MEAN
607 #ifdef HAVE_WINSOCK2_H
608 #include <winsock2.h>
609 #ifdef HAVE_WS2TCPIP_H
610 #include <ws2tcpip.h>
614 #ifdef HAVE_SYS_TYPES_H
615 #include <sys/types.h>
617 #ifdef HAVE_NETINET_IN_H
618 #include <netinet/in.h>
622 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
625 dnl check for the sockaddr_in6 structure
629 #ifdef HAVE_WINDOWS_H
630 #ifndef WIN32_LEAN_AND_MEAN
631 #define WIN32_LEAN_AND_MEAN
634 #ifdef HAVE_WINSOCK2_H
635 #include <winsock2.h>
636 #ifdef HAVE_WS2TCPIP_H
637 #include <ws2tcpip.h>
641 #ifdef HAVE_SYS_TYPES_H
642 #include <sys/types.h>
644 #ifdef HAVE_NETINET_IN_H
645 #include <netinet/in.h>
649 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
650 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
653 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
654 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
655 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
659 #ifdef HAVE_WINDOWS_H
660 #ifndef WIN32_LEAN_AND_MEAN
661 #define WIN32_LEAN_AND_MEAN
664 #ifdef HAVE_WINSOCK2_H
665 #include <winsock2.h>
666 #ifdef HAVE_WS2TCPIP_H
667 #include <ws2tcpip.h>
671 #ifdef HAVE_SYS_TYPES_H
672 #include <sys/types.h>
674 #ifdef HAVE_NETINET_IN_H
675 #include <netinet/in.h>
680 dnl check for the addrinfo structure
681 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
682 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
683 [Define to 1 if you have struct addrinfo.]),,
686 #ifdef HAVE_WINDOWS_H
687 #ifndef WIN32_LEAN_AND_MEAN
688 #define WIN32_LEAN_AND_MEAN
691 #ifdef HAVE_WINSOCK2_H
692 #include <winsock2.h>
693 #ifdef HAVE_WS2TCPIP_H
694 #include <ws2tcpip.h>
698 #ifdef HAVE_SYS_TYPES_H
699 #include <sys/types.h>
701 #ifdef HAVE_NETINET_IN_H
702 #include <netinet/in.h>
704 #ifdef HAVE_SYS_SOCKET_H
705 #include <sys/socket.h>
715 AC_CHECK_FUNCS([bitncmp \
721 AC_MSG_CHECKING([deeper for $func])
729 eval "ac_cv_func_$func=yes"
730 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$func]), [1],
731 [Define to 1 if you have the $func function.])
733 AC_MSG_RESULT([but still no])
738 AC_CHECK_SIZEOF(struct in6_addr, ,
741 #ifdef HAVE_WINDOWS_H
742 #ifndef WIN32_LEAN_AND_MEAN
743 #define WIN32_LEAN_AND_MEAN
746 #ifdef HAVE_WINSOCK2_H
747 #include <winsock2.h>
748 #ifdef HAVE_WS2TCPIP_H
749 #include <ws2tcpip.h>
753 #ifdef HAVE_SYS_TYPES_H
754 #include <sys/types.h>
756 #ifdef HAVE_SYS_SOCKET_H
757 #include <sys/socket.h>
759 #ifdef HAVE_NETINET_IN_H
760 #include <netinet/in.h>
766 AC_CHECK_SIZEOF(struct in_addr, ,
769 #ifdef HAVE_WINDOWS_H
770 #ifndef WIN32_LEAN_AND_MEAN
771 #define WIN32_LEAN_AND_MEAN
774 #ifdef HAVE_WINSOCK2_H
775 #include <winsock2.h>
776 #ifdef HAVE_WS2TCPIP_H
777 #include <ws2tcpip.h>
781 #ifdef HAVE_SYS_TYPES_H
782 #include <sys/types.h>
784 #ifdef HAVE_SYS_SOCKET_H
785 #include <sys/socket.h>
787 #ifdef HAVE_NETINET_IN_H
788 #include <netinet/in.h>
795 dnl Check if the getnameinfo function is available
796 dnl and get the types of five of its arguments.
797 CURL_CHECK_FUNC_GETNAMEINFO
801 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
802 [define this if ares is built for a big endian system])],
804 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
807 dnl Check for user-specified random device
809 AC_HELP_STRING([--with-random=FILE],
810 [read randomness from FILE (default=/dev/urandom)]),
811 [ RANDOM_FILE="$withval" ],
813 dnl Check for random device. If we're cross compiling, we can't
814 dnl check, and it's better to assume it doesn't exist than it is
815 dnl to fail on AC_CHECK_FILE or later.
816 if test "$cross_compiling" = "no"; then
817 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
819 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
824 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
825 AC_SUBST(RANDOM_FILE)
826 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
827 [a suitable file/device to read random data from])
830 CARES_CHECK_OPTION_NONBLOCKING
831 CARES_CHECK_NONBLOCKING_SOCKET
833 CARES_CONFIGURE_SYMBOL_HIDING
835 CARES_PRIVATE_LIBS="$LIBS"
836 AC_SUBST(CARES_PRIVATE_LIBS)
838 CARES_CFLAG_EXTRAS=""
839 if test X"$want_werror" = Xyes; then
840 CARES_CFLAG_EXTRAS="-Werror"
842 AC_SUBST(CARES_CFLAG_EXTRAS)
844 dnl squeeze whitespace out of some variables
852 squeeze CARES_PRIVATE_LIBS
854 AC_CONFIG_FILES([Makefile libcares.pc])