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 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 AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY])
115 use_cppflag_cares_building_library="no"
116 use_cppflag_cares_staticlib="no"
117 CPPFLAG_CARES_STATICLIB=""
121 use_cppflag_cares_building_library="yes"
122 AC_MSG_CHECKING([if we need CARES_STATICLIB])
123 if test "X$enable_shared" = "Xno"
126 use_cppflag_cares_staticlib="yes"
127 CPPFLAG_CARES_STATICLIB="-DCARES_STATICLIB"
136 AM_CONDITIONAL(USE_CPPFLAG_CARES_BUILDING_LIBRARY, test x$use_cppflag_cares_building_library = xyes)
137 AM_CONDITIONAL(USE_CPPFLAG_CARES_STATICLIB, test x$use_cppflag_cares_staticlib = xyes)
138 AC_SUBST(CPPFLAG_CARES_STATICLIB)
140 dnl **********************************************************************
141 dnl platform/compiler/architecture specific checks/flags
142 dnl **********************************************************************
145 CARES_SET_COMPILER_BASIC_OPTS
146 CARES_SET_COMPILER_DEBUG_OPTS
147 CARES_SET_COMPILER_OPTIMIZE_OPTS
148 CARES_SET_COMPILER_WARNING_OPTS
150 if test "$compiler_id" = "INTEL_UNIX_C"; then
152 if test "$compiler_num" -ge "1000"; then
153 dnl icc 10.X or later
154 CFLAGS="$CFLAGS -shared-intel"
155 elif test "$compiler_num" -ge "900"; then
157 CFLAGS="$CFLAGS -i-dynamic"
162 CARES_CHECK_COMPILER_HALT_ON_ERROR
163 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
164 CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
165 CARES_CHECK_COMPILER_SYMBOL_HIDING
167 CARES_CHECK_CURLDEBUG
168 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
170 dnl **********************************************************************
171 dnl Compilation based checks should not be done before this point.
172 dnl **********************************************************************
174 dnl **********************************************************************
175 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
176 dnl and ws2tcpip.h take precedence over any other further checks which
177 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
178 dnl this specific header files. And do them before its results are used.
179 dnl **********************************************************************
181 CURL_CHECK_HEADER_WINDOWS
182 CURL_CHECK_NATIVE_WINDOWS
183 case X-"$ac_cv_native_windows" in
185 CURL_CHECK_HEADER_WINSOCK
186 CURL_CHECK_HEADER_WINSOCK2
187 CURL_CHECK_HEADER_WS2TCPIP
190 ac_cv_header_winsock_h="no"
191 ac_cv_header_winsock2_h="no"
192 ac_cv_header_ws2tcpip_h="no"
196 dnl **********************************************************************
197 dnl Checks for libraries.
198 dnl **********************************************************************
202 dnl gethostbyname without lib or in the nsl lib?
203 AC_CHECK_FUNC(gethostbyname,
204 [HAVE_GETHOSTBYNAME="1"
206 [ AC_CHECK_LIB(nsl, gethostbyname,
207 [HAVE_GETHOSTBYNAME="1"
212 if test "$HAVE_GETHOSTBYNAME" != "1"
214 dnl gethostbyname in the socket lib?
215 AC_CHECK_LIB(socket, gethostbyname,
216 [HAVE_GETHOSTBYNAME="1"
217 LIBS="$LIBS -lsocket"
221 dnl At least one system has been identified to require BOTH nsl and socket
222 dnl libs at the same time to link properly.
223 if test "$HAVE_GETHOSTBYNAME" != "1"
225 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
226 my_ac_save_LIBS=$LIBS
227 LIBS="-lnsl -lsocket $LIBS"
235 HAVE_GETHOSTBYNAME="1"
238 LIBS=$my_ac_save_LIBS
242 if test "$HAVE_GETHOSTBYNAME" != "1"
244 dnl This is for winsock systems
245 if test "$ac_cv_header_windows_h" = "yes"; then
246 if test "$ac_cv_header_winsock_h" = "yes"; then
249 winsock_LIB="-lwinsock"
252 winsock_LIB="-lwsock32"
256 if test "$ac_cv_header_winsock2_h" = "yes"; then
257 winsock_LIB="-lws2_32"
259 if test ! -z "$winsock_LIB"; then
260 my_ac_save_LIBS=$LIBS
261 LIBS="$winsock_LIB $LIBS"
262 AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
265 #ifdef HAVE_WINDOWS_H
266 #ifndef WIN32_LEAN_AND_MEAN
267 #define WIN32_LEAN_AND_MEAN
270 #ifdef HAVE_WINSOCK2_H
271 #include <winsock2.h>
273 #ifdef HAVE_WINSOCK_H
279 gethostbyname("www.dummysite.com");
283 HAVE_GETHOSTBYNAME="1"
287 LIBS=$my_ac_save_LIBS
293 if test "$HAVE_GETHOSTBYNAME" != "1"
295 dnl This is for Minix 3.1
296 AC_MSG_CHECKING([for gethostbyname for Minix 3])
299 /* Older Minix versions may need <net/gen/netdb.h> here instead */
302 gethostbyname("www.dummysite.com");
306 HAVE_GETHOSTBYNAME="1"
312 if test "$HAVE_GETHOSTBYNAME" != "1"
314 dnl This is for eCos with a stubbed DNS implementation
315 AC_MSG_CHECKING([for gethostbyname for eCos])
321 gethostbyname("www.dummysite.com");
325 HAVE_GETHOSTBYNAME="1"
331 if test "$HAVE_GETHOSTBYNAME" != "1"
333 dnl gethostbyname in the net lib - for BeOS
334 AC_CHECK_LIB(net, gethostbyname,
335 [HAVE_GETHOSTBYNAME="1"
341 if test "$HAVE_GETHOSTBYNAME" != "1"; then
342 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
346 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
348 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
349 AC_CHECK_LIB(resolve, strcasecmp,
350 [LIBS="-lresolve $LIBS"],
354 ac_cv_func_strcasecmp="no"
356 CARES_CHECK_LIBS_CONNECT
358 dnl **********************************************************************
359 dnl In case that function clock_gettime with monotonic timer is available,
360 dnl check for additional required libraries.
361 dnl **********************************************************************
362 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
364 AC_MSG_CHECKING([whether to use libgcc])
365 AC_ARG_ENABLE(libgcc,
366 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
367 [ case "$enableval" in
379 dnl Let's hope this split URL remains working:
380 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
381 dnl genprogc/thread_quick_ref.htm
384 dnl **********************************************************************
385 dnl Back to "normal" configuring
386 dnl **********************************************************************
388 dnl Checks for header files.
391 CURL_CHECK_HEADER_MALLOC
392 CURL_CHECK_HEADER_MEMORY
394 dnl check for a few basic system headers we need
415 arpa/nameser_compat.h \
417 dnl to do if not found
423 #ifdef HAVE_SYS_TYPES_H
424 #include <sys/types.h>
426 #ifdef HAVE_SYS_TIME_H
427 #include <sys/time.h>
429 dnl We do this default-include simply to make sure that the nameser_compat.h
430 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
431 dnl (and others?) is not designed to allow this.
432 #ifdef HAVE_ARPA_NAMESER_H
433 #include <arpa/nameser.h>
436 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
437 #ifdef HAVE_SYS_SOCKET_H
438 #include <sys/socket.h>
440 #ifdef HAVE_NETINET_IN_H
441 #include <netinet/in.h>
446 dnl Checks for typedefs, structures, and compiler characteristics.
450 CURL_CHECK_STRUCT_TIMEVAL
452 AC_CHECK_SIZEOF(size_t)
453 AC_CHECK_SIZEOF(long)
455 AC_CHECK_SIZEOF(short)
457 AC_CHECK_SIZEOF(time_t)
459 AC_CHECK_TYPE(long long,
460 [AC_DEFINE(HAVE_LONGLONG, 1,
461 [Define to 1 if the compiler supports the 'long long' data type.])]
465 if test "xyes" = "x$longlong"; then
466 AC_MSG_CHECKING([if numberLL works])
470 long long val = 1000LL;
474 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
482 AC_CHECK_TYPE(ssize_t, ,
483 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
485 # check for bool type
486 AC_CHECK_TYPE([bool],[
487 AC_DEFINE(HAVE_BOOL_T, 1,
488 [Define to 1 if bool is an available type.])
490 #ifdef HAVE_SYS_TYPES_H
491 #include <sys/types.h>
493 #ifdef HAVE_STDBOOL_H
498 CARES_CONFIGURE_ARES_SOCKLEN_T
502 TYPE_SOCKADDR_STORAGE
509 CURL_CHECK_FUNC_RECVFROM
511 CURL_CHECK_MSG_NOSIGNAL
513 CARES_CHECK_FUNC_CLOSESOCKET
514 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
515 CARES_CHECK_FUNC_CONNECT
516 CARES_CHECK_FUNC_FCNTL
517 CARES_CHECK_FUNC_FREEADDRINFO
518 CARES_CHECK_FUNC_GETADDRINFO
519 CARES_CHECK_FUNC_GETENV
520 CARES_CHECK_FUNC_GETHOSTBYADDR
521 CARES_CHECK_FUNC_GETHOSTBYNAME
522 CARES_CHECK_FUNC_GETHOSTNAME
523 CARES_CHECK_FUNC_GETSERVBYPORT_R
524 CARES_CHECK_FUNC_INET_NET_PTON
525 CARES_CHECK_FUNC_INET_NTOP
526 CARES_CHECK_FUNC_INET_PTON
527 CARES_CHECK_FUNC_IOCTL
528 CARES_CHECK_FUNC_IOCTLSOCKET
529 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
530 CARES_CHECK_FUNC_SETSOCKOPT
531 CARES_CHECK_FUNC_SOCKET
532 CARES_CHECK_FUNC_STRCASECMP
533 CARES_CHECK_FUNC_STRCMPI
534 CARES_CHECK_FUNC_STRDUP
535 CARES_CHECK_FUNC_STRICMP
536 CARES_CHECK_FUNC_STRNCASECMP
537 CARES_CHECK_FUNC_STRNCMPI
538 CARES_CHECK_FUNC_STRNICMP
539 CARES_CHECK_FUNC_WRITEV
542 dnl check for AF_INET6
543 CARES_CHECK_CONSTANT(
546 #ifdef HAVE_WINDOWS_H
547 #ifndef WIN32_LEAN_AND_MEAN
548 #define WIN32_LEAN_AND_MEAN
551 #ifdef HAVE_WINSOCK2_H
552 #include <winsock2.h>
555 #ifdef HAVE_SYS_TYPES_H
556 #include <sys/types.h>
558 #ifdef HAVE_SYS_SOCKET_H
559 #include <sys/socket.h>
563 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
566 dnl check for PF_INET6
567 CARES_CHECK_CONSTANT(
570 #ifdef HAVE_WINDOWS_H
571 #ifndef WIN32_LEAN_AND_MEAN
572 #define WIN32_LEAN_AND_MEAN
575 #ifdef HAVE_WINSOCK2_H
576 #include <winsock2.h>
579 #ifdef HAVE_SYS_TYPES_H
580 #include <sys/types.h>
582 #ifdef HAVE_SYS_SOCKET_H
583 #include <sys/socket.h>
587 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
591 dnl check for the in6_addr structure
595 #ifdef HAVE_WINDOWS_H
596 #ifndef WIN32_LEAN_AND_MEAN
597 #define WIN32_LEAN_AND_MEAN
600 #ifdef HAVE_WINSOCK2_H
601 #include <winsock2.h>
602 #ifdef HAVE_WS2TCPIP_H
603 #include <ws2tcpip.h>
607 #ifdef HAVE_SYS_TYPES_H
608 #include <sys/types.h>
610 #ifdef HAVE_NETINET_IN_H
611 #include <netinet/in.h>
615 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
618 dnl check for the sockaddr_in6 structure
622 #ifdef HAVE_WINDOWS_H
623 #ifndef WIN32_LEAN_AND_MEAN
624 #define WIN32_LEAN_AND_MEAN
627 #ifdef HAVE_WINSOCK2_H
628 #include <winsock2.h>
629 #ifdef HAVE_WS2TCPIP_H
630 #include <ws2tcpip.h>
634 #ifdef HAVE_SYS_TYPES_H
635 #include <sys/types.h>
637 #ifdef HAVE_NETINET_IN_H
638 #include <netinet/in.h>
642 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
643 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
646 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
647 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
648 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
652 #ifdef HAVE_WINDOWS_H
653 #ifndef WIN32_LEAN_AND_MEAN
654 #define WIN32_LEAN_AND_MEAN
657 #ifdef HAVE_WINSOCK2_H
658 #include <winsock2.h>
659 #ifdef HAVE_WS2TCPIP_H
660 #include <ws2tcpip.h>
664 #ifdef HAVE_SYS_TYPES_H
665 #include <sys/types.h>
667 #ifdef HAVE_NETINET_IN_H
668 #include <netinet/in.h>
673 dnl check for the addrinfo structure
674 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
675 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
676 [Define to 1 if you have struct addrinfo.]),,
679 #ifdef HAVE_WINDOWS_H
680 #ifndef WIN32_LEAN_AND_MEAN
681 #define WIN32_LEAN_AND_MEAN
684 #ifdef HAVE_WINSOCK2_H
685 #include <winsock2.h>
686 #ifdef HAVE_WS2TCPIP_H
687 #include <ws2tcpip.h>
691 #ifdef HAVE_SYS_TYPES_H
692 #include <sys/types.h>
694 #ifdef HAVE_NETINET_IN_H
695 #include <netinet/in.h>
697 #ifdef HAVE_SYS_SOCKET_H
698 #include <sys/socket.h>
708 AC_CHECK_FUNCS([bitncmp \
714 AC_MSG_CHECKING([deeper for $func])
722 eval "ac_cv_func_$func=yes"
723 AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
724 [Define to 1 if you have the $func function.])
726 AC_MSG_RESULT([but still no])
731 AC_CHECK_SIZEOF(struct in6_addr, ,
734 #ifdef HAVE_WINDOWS_H
735 #ifndef WIN32_LEAN_AND_MEAN
736 #define WIN32_LEAN_AND_MEAN
739 #ifdef HAVE_WINSOCK2_H
740 #include <winsock2.h>
741 #ifdef HAVE_WS2TCPIP_H
742 #include <ws2tcpip.h>
746 #ifdef HAVE_SYS_TYPES_H
747 #include <sys/types.h>
749 #ifdef HAVE_SYS_SOCKET_H
750 #include <sys/socket.h>
752 #ifdef HAVE_NETINET_IN_H
753 #include <netinet/in.h>
759 AC_CHECK_SIZEOF(struct in_addr, ,
762 #ifdef HAVE_WINDOWS_H
763 #ifndef WIN32_LEAN_AND_MEAN
764 #define WIN32_LEAN_AND_MEAN
767 #ifdef HAVE_WINSOCK2_H
768 #include <winsock2.h>
769 #ifdef HAVE_WS2TCPIP_H
770 #include <ws2tcpip.h>
774 #ifdef HAVE_SYS_TYPES_H
775 #include <sys/types.h>
777 #ifdef HAVE_SYS_SOCKET_H
778 #include <sys/socket.h>
780 #ifdef HAVE_NETINET_IN_H
781 #include <netinet/in.h>
788 dnl Check if the getnameinfo function is available
789 dnl and get the types of five of its arguments.
790 CURL_CHECK_FUNC_GETNAMEINFO
794 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
795 [define this if ares is built for a big endian system])],
797 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
800 dnl Check for user-specified random device
802 AC_HELP_STRING([--with-random=FILE],
803 [read randomness from FILE (default=/dev/urandom)]),
804 [ RANDOM_FILE="$withval" ],
806 dnl Check for random device. If we're cross compiling, we can't
807 dnl check, and it's better to assume it doesn't exist than it is
808 dnl to fail on AC_CHECK_FILE or later.
809 if test "$cross_compiling" = "no"; then
810 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
812 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
817 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
818 AC_SUBST(RANDOM_FILE)
819 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
820 [a suitable file/device to read random data from])
823 CARES_CHECK_OPTION_NONBLOCKING
824 CARES_CHECK_NONBLOCKING_SOCKET
826 CARES_CONFIGURE_SYMBOL_HIDING
828 CARES_PRIVATE_LIBS="$LIBS"
829 AC_SUBST(CARES_PRIVATE_LIBS)
831 CARES_CFLAG_EXTRAS=""
832 if test X"$want_werror" = Xyes; then
833 CARES_CFLAG_EXTRAS="-Werror"
835 AC_SUBST(CARES_CFLAG_EXTRAS)
837 dnl squeeze whitespace out of some variables
845 squeeze CARES_PRIVATE_LIBS
849 AC_CONFIG_FILES([Makefile libcares.pc])