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
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])
100 dnl support building of Windows DLLs
103 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
104 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
106 x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
115 AC_MSG_CHECKING([if compiler is icc (to build with PIC)])
129 AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY])
130 use_cppflag_cares_building_library="no"
131 use_cppflag_cares_staticlib="no"
132 CPPFLAG_CARES_STATICLIB=""
136 use_cppflag_cares_building_library="yes"
137 AC_MSG_CHECKING([if we need CARES_STATICLIB])
138 if test "X$enable_shared" = "Xno"
141 use_cppflag_cares_staticlib="yes"
142 CPPFLAG_CARES_STATICLIB="-DCARES_STATICLIB"
151 AM_CONDITIONAL(USE_CPPFLAG_CARES_BUILDING_LIBRARY, test x$use_cppflag_cares_building_library = xyes)
152 AM_CONDITIONAL(USE_CPPFLAG_CARES_STATICLIB, test x$use_cppflag_cares_staticlib = xyes)
153 AC_SUBST(CPPFLAG_CARES_STATICLIB)
155 dnl **********************************************************************
156 dnl platform/compiler/architecture specific checks/flags
157 dnl **********************************************************************
160 CARES_SET_COMPILER_BASIC_OPTS
161 CARES_SET_COMPILER_DEBUG_OPTS
162 CARES_SET_COMPILER_OPTIMIZE_OPTS
163 CARES_SET_COMPILER_WARNING_OPTS
165 if test "$compiler_id" = "INTEL_UNIX_C"; then
167 if test "$compiler_num" -ge "1000"; then
168 dnl icc 10.X or later
169 CFLAGS="$CFLAGS -shared-intel"
170 elif test "$compiler_num" -ge "900"; then
172 CFLAGS="$CFLAGS -i-dynamic"
177 CARES_CHECK_COMPILER_HALT_ON_ERROR
178 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
179 CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
180 CARES_CHECK_COMPILER_SYMBOL_HIDING
182 CARES_CHECK_NO_UNDEFINED
183 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
185 CARES_CHECK_CURLDEBUG
186 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
188 dnl **********************************************************************
189 dnl Compilation based checks should not be done before this point.
190 dnl **********************************************************************
192 dnl **********************************************************************
193 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
194 dnl and ws2tcpip.h take precedence over any other further checks which
195 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
196 dnl this specific header files. And do them before its results are used.
197 dnl **********************************************************************
199 CURL_CHECK_HEADER_WINDOWS
200 CURL_CHECK_NATIVE_WINDOWS
201 case X-"$ac_cv_native_windows" in
203 CURL_CHECK_HEADER_WINSOCK
204 CURL_CHECK_HEADER_WINSOCK2
205 CURL_CHECK_HEADER_WS2TCPIP
208 ac_cv_header_winsock_h="no"
209 ac_cv_header_winsock2_h="no"
210 ac_cv_header_ws2tcpip_h="no"
214 dnl **********************************************************************
215 dnl Checks for libraries.
216 dnl **********************************************************************
220 dnl gethostbyname without lib or in the nsl lib?
221 AC_CHECK_FUNC(gethostbyname,
222 [HAVE_GETHOSTBYNAME="1"
224 [ AC_CHECK_LIB(nsl, gethostbyname,
225 [HAVE_GETHOSTBYNAME="1"
230 if test "$HAVE_GETHOSTBYNAME" != "1"
232 dnl gethostbyname in the socket lib?
233 AC_CHECK_LIB(socket, gethostbyname,
234 [HAVE_GETHOSTBYNAME="1"
235 LIBS="$LIBS -lsocket"
239 dnl At least one system has been identified to require BOTH nsl and socket
240 dnl libs at the same time to link properly.
241 if test "$HAVE_GETHOSTBYNAME" != "1"
243 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
244 my_ac_save_LIBS=$LIBS
245 LIBS="-lnsl -lsocket $LIBS"
253 HAVE_GETHOSTBYNAME="1"
256 LIBS=$my_ac_save_LIBS
260 if test "$HAVE_GETHOSTBYNAME" != "1"
262 dnl This is for winsock systems
263 if test "$ac_cv_header_windows_h" = "yes"; then
264 if test "$ac_cv_header_winsock_h" = "yes"; then
267 winsock_LIB="-lwinsock"
270 winsock_LIB="-lwsock32"
274 if test "$ac_cv_header_winsock2_h" = "yes"; then
275 winsock_LIB="-lws2_32"
277 if test ! -z "$winsock_LIB"; then
278 my_ac_save_LIBS=$LIBS
279 LIBS="$winsock_LIB $LIBS"
280 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
283 #ifdef HAVE_WINDOWS_H
284 #ifndef WIN32_LEAN_AND_MEAN
285 #define WIN32_LEAN_AND_MEAN
288 #ifdef HAVE_WINSOCK2_H
289 #include <winsock2.h>
291 #ifdef HAVE_WINSOCK_H
297 gethostbyname("www.dummysite.com");
301 HAVE_GETHOSTBYNAME="1"
305 LIBS=$my_ac_save_LIBS
311 if test "$HAVE_GETHOSTBYNAME" != "1"
313 dnl This is for Minix 3.1
314 AC_MSG_CHECKING([for gethostbyname for Minix 3])
317 /* Older Minix versions may need <net/gen/netdb.h> here instead */
320 gethostbyname("www.dummysite.com");
324 HAVE_GETHOSTBYNAME="1"
330 if test "$HAVE_GETHOSTBYNAME" != "1"
332 dnl This is for eCos with a stubbed DNS implementation
333 AC_MSG_CHECKING([for gethostbyname for eCos])
339 gethostbyname("www.dummysite.com");
343 HAVE_GETHOSTBYNAME="1"
349 if test "$HAVE_GETHOSTBYNAME" != "1"
351 dnl gethostbyname in the net lib - for BeOS
352 AC_CHECK_LIB(net, gethostbyname,
353 [HAVE_GETHOSTBYNAME="1"
359 if test "$HAVE_GETHOSTBYNAME" != "1"; then
360 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
364 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
366 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
367 AC_CHECK_LIB(resolve, strcasecmp,
368 [LIBS="-lresolve $LIBS"],
372 ac_cv_func_strcasecmp="no"
374 CARES_CHECK_LIBS_CONNECT
376 dnl **********************************************************************
377 dnl In case that function clock_gettime with monotonic timer is available,
378 dnl check for additional required libraries.
379 dnl **********************************************************************
380 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
382 AC_MSG_CHECKING([whether to use libgcc])
383 AC_ARG_ENABLE(libgcc,
384 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
385 [ case "$enableval" in
397 dnl Let's hope this split URL remains working:
398 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
399 dnl genprogc/thread_quick_ref.htm
402 dnl **********************************************************************
403 dnl Back to "normal" configuring
404 dnl **********************************************************************
406 dnl Checks for header files.
409 CURL_CHECK_HEADER_MALLOC
410 CURL_CHECK_HEADER_MEMORY
412 dnl check for a few basic system headers we need
433 arpa/nameser_compat.h \
435 dnl to do if not found
441 #ifdef HAVE_SYS_TYPES_H
442 #include <sys/types.h>
444 #ifdef HAVE_SYS_TIME_H
445 #include <sys/time.h>
447 dnl We do this default-include simply to make sure that the nameser_compat.h
448 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
449 dnl (and others?) is not designed to allow this.
450 #ifdef HAVE_ARPA_NAMESER_H
451 #include <arpa/nameser.h>
454 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
455 #ifdef HAVE_SYS_SOCKET_H
456 #include <sys/socket.h>
458 #ifdef HAVE_NETINET_IN_H
459 #include <netinet/in.h>
464 dnl Checks for typedefs, structures, and compiler characteristics.
468 CURL_CHECK_STRUCT_TIMEVAL
470 AC_CHECK_SIZEOF(size_t)
471 AC_CHECK_SIZEOF(long)
473 AC_CHECK_SIZEOF(short)
475 AC_CHECK_SIZEOF(time_t)
477 AC_CHECK_TYPE(long long,
478 [AC_DEFINE(HAVE_LONGLONG, 1,
479 [Define to 1 if the compiler supports the 'long long' data type.])]
483 if test "xyes" = "x$longlong"; then
484 AC_MSG_CHECKING([if numberLL works])
488 long long val = 1000LL;
492 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
500 AC_CHECK_TYPE(ssize_t, ,
501 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
503 # check for bool type
504 AC_CHECK_TYPE([bool],[
505 AC_DEFINE(HAVE_BOOL_T, 1,
506 [Define to 1 if bool is an available type.])
508 #ifdef HAVE_SYS_TYPES_H
509 #include <sys/types.h>
511 #ifdef HAVE_STDBOOL_H
516 CARES_CONFIGURE_ARES_SOCKLEN_T
520 TYPE_SOCKADDR_STORAGE
527 CURL_CHECK_FUNC_RECVFROM
529 CURL_CHECK_MSG_NOSIGNAL
531 CARES_CHECK_FUNC_CLOSESOCKET
532 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
533 CARES_CHECK_FUNC_CONNECT
534 CARES_CHECK_FUNC_FCNTL
535 CARES_CHECK_FUNC_FREEADDRINFO
536 CARES_CHECK_FUNC_GETADDRINFO
537 CARES_CHECK_FUNC_GETENV
538 CARES_CHECK_FUNC_GETHOSTBYADDR
539 CARES_CHECK_FUNC_GETHOSTBYNAME
540 CARES_CHECK_FUNC_GETHOSTNAME
541 CARES_CHECK_FUNC_GETSERVBYPORT_R
542 CARES_CHECK_FUNC_INET_NET_PTON
543 CARES_CHECK_FUNC_INET_NTOP
544 CARES_CHECK_FUNC_INET_PTON
545 CARES_CHECK_FUNC_IOCTL
546 CARES_CHECK_FUNC_IOCTLSOCKET
547 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
548 CARES_CHECK_FUNC_SETSOCKOPT
549 CARES_CHECK_FUNC_SOCKET
550 CARES_CHECK_FUNC_STRCASECMP
551 CARES_CHECK_FUNC_STRCMPI
552 CARES_CHECK_FUNC_STRDUP
553 CARES_CHECK_FUNC_STRICMP
554 CARES_CHECK_FUNC_STRNCASECMP
555 CARES_CHECK_FUNC_STRNCMPI
556 CARES_CHECK_FUNC_STRNICMP
557 CARES_CHECK_FUNC_WRITEV
560 dnl check for AF_INET6
561 CARES_CHECK_CONSTANT(
564 #ifdef HAVE_WINDOWS_H
565 #ifndef WIN32_LEAN_AND_MEAN
566 #define WIN32_LEAN_AND_MEAN
569 #ifdef HAVE_WINSOCK2_H
570 #include <winsock2.h>
573 #ifdef HAVE_SYS_TYPES_H
574 #include <sys/types.h>
576 #ifdef HAVE_SYS_SOCKET_H
577 #include <sys/socket.h>
581 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
584 dnl check for PF_INET6
585 CARES_CHECK_CONSTANT(
588 #ifdef HAVE_WINDOWS_H
589 #ifndef WIN32_LEAN_AND_MEAN
590 #define WIN32_LEAN_AND_MEAN
593 #ifdef HAVE_WINSOCK2_H
594 #include <winsock2.h>
597 #ifdef HAVE_SYS_TYPES_H
598 #include <sys/types.h>
600 #ifdef HAVE_SYS_SOCKET_H
601 #include <sys/socket.h>
605 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
609 dnl check for the in6_addr structure
613 #ifdef HAVE_WINDOWS_H
614 #ifndef WIN32_LEAN_AND_MEAN
615 #define WIN32_LEAN_AND_MEAN
618 #ifdef HAVE_WINSOCK2_H
619 #include <winsock2.h>
620 #ifdef HAVE_WS2TCPIP_H
621 #include <ws2tcpip.h>
625 #ifdef HAVE_SYS_TYPES_H
626 #include <sys/types.h>
628 #ifdef HAVE_NETINET_IN_H
629 #include <netinet/in.h>
633 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
636 dnl check for the sockaddr_in6 structure
640 #ifdef HAVE_WINDOWS_H
641 #ifndef WIN32_LEAN_AND_MEAN
642 #define WIN32_LEAN_AND_MEAN
645 #ifdef HAVE_WINSOCK2_H
646 #include <winsock2.h>
647 #ifdef HAVE_WS2TCPIP_H
648 #include <ws2tcpip.h>
652 #ifdef HAVE_SYS_TYPES_H
653 #include <sys/types.h>
655 #ifdef HAVE_NETINET_IN_H
656 #include <netinet/in.h>
660 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
661 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
664 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
665 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
666 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
670 #ifdef HAVE_WINDOWS_H
671 #ifndef WIN32_LEAN_AND_MEAN
672 #define WIN32_LEAN_AND_MEAN
675 #ifdef HAVE_WINSOCK2_H
676 #include <winsock2.h>
677 #ifdef HAVE_WS2TCPIP_H
678 #include <ws2tcpip.h>
682 #ifdef HAVE_SYS_TYPES_H
683 #include <sys/types.h>
685 #ifdef HAVE_NETINET_IN_H
686 #include <netinet/in.h>
691 dnl check for the addrinfo structure
692 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
693 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
694 [Define to 1 if you have struct addrinfo.]),,
697 #ifdef HAVE_WINDOWS_H
698 #ifndef WIN32_LEAN_AND_MEAN
699 #define WIN32_LEAN_AND_MEAN
702 #ifdef HAVE_WINSOCK2_H
703 #include <winsock2.h>
704 #ifdef HAVE_WS2TCPIP_H
705 #include <ws2tcpip.h>
709 #ifdef HAVE_SYS_TYPES_H
710 #include <sys/types.h>
712 #ifdef HAVE_NETINET_IN_H
713 #include <netinet/in.h>
715 #ifdef HAVE_SYS_SOCKET_H
716 #include <sys/socket.h>
726 AC_CHECK_FUNCS([bitncmp \
732 AC_MSG_CHECKING([deeper for $func])
740 eval "ac_cv_func_$func=yes"
741 AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
742 [Define to 1 if you have the $func function.])
744 AC_MSG_RESULT([but still no])
749 AC_CHECK_SIZEOF(struct in6_addr, ,
752 #ifdef HAVE_WINDOWS_H
753 #ifndef WIN32_LEAN_AND_MEAN
754 #define WIN32_LEAN_AND_MEAN
757 #ifdef HAVE_WINSOCK2_H
758 #include <winsock2.h>
759 #ifdef HAVE_WS2TCPIP_H
760 #include <ws2tcpip.h>
764 #ifdef HAVE_SYS_TYPES_H
765 #include <sys/types.h>
767 #ifdef HAVE_SYS_SOCKET_H
768 #include <sys/socket.h>
770 #ifdef HAVE_NETINET_IN_H
771 #include <netinet/in.h>
777 AC_CHECK_SIZEOF(struct in_addr, ,
780 #ifdef HAVE_WINDOWS_H
781 #ifndef WIN32_LEAN_AND_MEAN
782 #define WIN32_LEAN_AND_MEAN
785 #ifdef HAVE_WINSOCK2_H
786 #include <winsock2.h>
787 #ifdef HAVE_WS2TCPIP_H
788 #include <ws2tcpip.h>
792 #ifdef HAVE_SYS_TYPES_H
793 #include <sys/types.h>
795 #ifdef HAVE_SYS_SOCKET_H
796 #include <sys/socket.h>
798 #ifdef HAVE_NETINET_IN_H
799 #include <netinet/in.h>
806 dnl Check if the getnameinfo function is available
807 dnl and get the types of five of its arguments.
808 CURL_CHECK_FUNC_GETNAMEINFO
812 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
813 [define this if ares is built for a big endian system])],
815 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
818 dnl Check for user-specified random device
820 AC_HELP_STRING([--with-random=FILE],
821 [read randomness from FILE (default=/dev/urandom)]),
822 [ RANDOM_FILE="$withval" ],
824 dnl Check for random device. If we're cross compiling, we can't
825 dnl check, and it's better to assume it doesn't exist than it is
826 dnl to fail on AC_CHECK_FILE or later.
827 if test "$cross_compiling" = "no"; then
828 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
830 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
835 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
836 AC_SUBST(RANDOM_FILE)
837 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
838 [a suitable file/device to read random data from])
841 CARES_CHECK_OPTION_NONBLOCKING
842 CARES_CHECK_NONBLOCKING_SOCKET
844 CARES_CONFIGURE_SYMBOL_HIDING
846 CARES_PRIVATE_LIBS="$LIBS"
847 AC_SUBST(CARES_PRIVATE_LIBS)
849 CARES_CFLAG_EXTRAS=""
850 if test X"$want_werror" = Xyes; then
851 CARES_CFLAG_EXTRAS="-Werror"
853 AC_SUBST(CARES_CFLAG_EXTRAS)
855 dnl squeeze whitespace out of some variables
863 squeeze CARES_PRIVATE_LIBS
867 AC_CONFIG_FILES([Makefile libcares.pc])