blob: b89ce35fe11ed95ffc620b2d02d73de19d999a8e [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001AC_PREREQ(2.57)
2
3dnl Version not hardcoded here. Fetched later from ares_version.h
4AC_INIT([c-ares], [1.12.0],
5 [c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares])
6
7XC_OVR_ZZ50
8XC_OVR_ZZ60
9CARES_OVERRIDE_AUTOCONF
10
11AC_CONFIG_SRCDIR([ares_ipv6.h])
12AC_CONFIG_HEADERS([ares_config.h ares_build.h])
13AC_CONFIG_MACRO_DIR([m4])
14AM_MAINTAINER_MODE
15m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
16
17CARES_CHECK_OPTION_DEBUG
18CARES_CHECK_OPTION_OPTIMIZE
19CARES_CHECK_OPTION_WARNINGS
20CARES_CHECK_OPTION_WERROR
21CARES_CHECK_OPTION_CURLDEBUG
22CARES_CHECK_OPTION_SYMBOL_HIDING
23CARES_CHECK_OPTION_EXPOSE_STATICS
24
25XC_CHECK_PATH_SEPARATOR
26
27dnl SED is mandatory for configure process and libtool.
28dnl Set it now, allowing it to be changed later.
29AC_PATH_PROG([SED], [sed], [not_found],
30 [$PATH:/usr/bin:/usr/local/bin])
31if test -z "$SED" || test "$SED" = "not_found"; then
32 AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
33fi
34AC_SUBST([SED])
35
36dnl GREP is mandatory for configure process and libtool.
37dnl Set it now, allowing it to be changed later.
38AC_PATH_PROG([GREP], [grep], [not_found],
39 [$PATH:/usr/bin:/usr/local/bin])
40if test -z "$GREP" || test "$GREP" = "not_found"; then
41 AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
42fi
43AC_SUBST([GREP])
44
45dnl EGREP is mandatory for configure process and libtool.
46dnl Set it now, allowing it to be changed later.
47if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
48 AC_MSG_CHECKING([for egrep])
49 EGREP="$GREP -E"
50 AC_MSG_RESULT([$EGREP])
51else
52 AC_PATH_PROG([EGREP], [egrep], [not_found],
53 [$PATH:/usr/bin:/usr/local/bin])
54fi
55if test -z "$EGREP" || test "$EGREP" = "not_found"; then
56 AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
57fi
58AC_SUBST([EGREP])
59
60dnl AR is mandatory for configure process and libtool.
61dnl This is target dependent, so check it as a tool.
62AC_PATH_TOOL([AR], [ar], [not_found],
63 [$PATH:/usr/bin:/usr/local/bin])
64if test -z "$AR" || test "$AR" = "not_found"; then
65 AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
66fi
67AC_SUBST([AR])
68
69AX_CODE_COVERAGE
70
71dnl Remove non-configure distributed ares_build.h
72if test -f ${srcdir}/ares_build.h; then
73 rm -f ${srcdir}/ares_build.h
74fi
75
76dnl
77dnl Detect the canonical host and target build environment
78dnl
79
80AC_CANONICAL_HOST
81dnl Get system canonical name
82AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
83
84XC_CHECK_PROG_CC
85AX_CXX_COMPILE_STDCXX_11([noext],[optional])
86
87XC_AUTOMAKE
88
89dnl This defines _ALL_SOURCE for AIX
90CARES_CHECK_AIX_ALL_SOURCE
91
92dnl Our configure and build reentrant settings
93CARES_CONFIGURE_THREAD_SAFE
94CARES_CONFIGURE_REENTRANT
95
96dnl check for how to do large files
97AC_SYS_LARGEFILE
98
99case $host_os in
100 solaris*)
101 AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
102 ;;
103esac
104
105XC_LIBTOOL
106
107#
108# Automake conditionals based on libtool related checks
109#
110
111AM_CONDITIONAL([CARES_LT_SHLIB_USE_VERSION_INFO],
112 [test "x$xc_lt_shlib_use_version_info" = 'xyes'])
113AM_CONDITIONAL([CARES_LT_SHLIB_USE_NO_UNDEFINED],
114 [test "x$xc_lt_shlib_use_no_undefined" = 'xyes'])
115AM_CONDITIONAL([CARES_LT_SHLIB_USE_MIMPURE_TEXT],
116 [test "x$xc_lt_shlib_use_mimpure_text" = 'xyes'])
117
118#
119# Due to libtool and automake machinery limitations of not allowing
120# specifying separate CPPFLAGS or CFLAGS when compiling objects for
121# inclusion of these in shared or static libraries, we are forced to
122# build using separate configure runs for shared and static libraries
123# on systems where different CPPFLAGS or CFLAGS are mandatory in order
124# to compile objects for each kind of library. Notice that relying on
125# the '-DPIC' CFLAG that libtool provides is not valid given that the
126# user might for example choose to build static libraries with PIC.
127#
128
129#
130# Make our Makefile.am files use the staticlib CPPFLAG only when strictly
131# targeting a static library and not building its shared counterpart.
132#
133
134AM_CONDITIONAL([USE_CPPFLAG_CARES_STATICLIB],
135 [test "x$xc_lt_build_static_only" = 'xyes'])
136
137#
138# Make staticlib CPPFLAG variable and its definition visible in output
139# files unconditionally, providing an empty definition unless strictly
140# targeting a static library and not building its shared counterpart.
141#
142
143CPPFLAG_CARES_STATICLIB=
144if test "x$xc_lt_build_static_only" = 'xyes'; then
145 CPPFLAG_CARES_STATICLIB='-DCARES_STATICLIB'
146fi
147AC_SUBST([CPPFLAG_CARES_STATICLIB])
148
149dnl **********************************************************************
150dnl platform/compiler/architecture specific checks/flags
151dnl **********************************************************************
152
153CARES_CHECK_COMPILER
154CARES_SET_COMPILER_BASIC_OPTS
155CARES_SET_COMPILER_DEBUG_OPTS
156CARES_SET_COMPILER_OPTIMIZE_OPTS
157CARES_SET_COMPILER_WARNING_OPTS
158
159if test "$compiler_id" = "INTEL_UNIX_C"; then
160 #
161 if test "$compiler_num" -ge "1000"; then
162 dnl icc 10.X or later
163 CFLAGS="$CFLAGS -shared-intel"
164 elif test "$compiler_num" -ge "900"; then
165 dnl icc 9.X specific
166 CFLAGS="$CFLAGS -i-dynamic"
167 fi
168 #
169fi
170
171CARES_CHECK_COMPILER_HALT_ON_ERROR
172CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
173CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
174CARES_CHECK_COMPILER_SYMBOL_HIDING
175
176CARES_CHECK_CURLDEBUG
177AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
178
179dnl **********************************************************************
180dnl Compilation based checks should not be done before this point.
181dnl **********************************************************************
182
183dnl **********************************************************************
184dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
185dnl and ws2tcpip.h take precedence over any other further checks which
186dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
187dnl this specific header files. And do them before its results are used.
188dnl **********************************************************************
189
190CURL_CHECK_HEADER_WINDOWS
191CURL_CHECK_NATIVE_WINDOWS
192case X-"$ac_cv_native_windows" in
193 X-yes)
194 CURL_CHECK_HEADER_WINSOCK
195 CURL_CHECK_HEADER_WINSOCK2
196 CURL_CHECK_HEADER_WS2TCPIP
197 ;;
198 *)
199 ac_cv_header_winsock_h="no"
200 ac_cv_header_winsock2_h="no"
201 ac_cv_header_ws2tcpip_h="no"
202 ;;
203esac
204
205dnl **********************************************************************
206dnl Checks for libraries.
207dnl **********************************************************************
208
209CARES_CHECK_LIB_XNET
210
211dnl gethostbyname without lib or in the nsl lib?
212AC_CHECK_FUNC(gethostbyname,
213 [HAVE_GETHOSTBYNAME="1"
214 ],
215 [ AC_CHECK_LIB(nsl, gethostbyname,
216 [HAVE_GETHOSTBYNAME="1"
217 LIBS="$LIBS -lnsl"
218 ])
219 ])
220
221if test "$HAVE_GETHOSTBYNAME" != "1"
222then
223 dnl gethostbyname in the socket lib?
224 AC_CHECK_LIB(socket, gethostbyname,
225 [HAVE_GETHOSTBYNAME="1"
226 LIBS="$LIBS -lsocket"
227 ])
228fi
229
230dnl At least one system has been identified to require BOTH nsl and socket
231dnl libs at the same time to link properly.
232if test "$HAVE_GETHOSTBYNAME" != "1"
233then
234 AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
235 my_ac_save_LIBS=$LIBS
236 LIBS="-lnsl -lsocket $LIBS"
237 AC_LINK_IFELSE([
238 AC_LANG_PROGRAM([[
239 ]],[[
240 gethostbyname();
241 ]])
242 ],[
243 AC_MSG_RESULT([yes])
244 HAVE_GETHOSTBYNAME="1"
245 ],[
246 AC_MSG_RESULT([no])
247 LIBS=$my_ac_save_LIBS
248 ])
249fi
250
251if test "$HAVE_GETHOSTBYNAME" != "1"
252then
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
256 case $host in
257 *-*-mingw32ce*)
258 winsock_LIB="-lwinsock"
259 ;;
260 *)
261 winsock_LIB="-lwsock32"
262 ;;
263 esac
264 fi
265 if test "$ac_cv_header_winsock2_h" = "yes"; then
266 winsock_LIB="-lws2_32"
267 fi
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])
272 AC_LINK_IFELSE([
273 AC_LANG_PROGRAM([[
274#ifdef HAVE_WINDOWS_H
275#ifndef WIN32_LEAN_AND_MEAN
276#define WIN32_LEAN_AND_MEAN
277#endif
278#include <windows.h>
279#ifdef HAVE_WINSOCK2_H
280#include <winsock2.h>
281#else
282#ifdef HAVE_WINSOCK_H
283#include <winsock.h>
284#endif
285#endif
286#endif
287 ]],[[
288 gethostbyname("www.dummysite.com");
289 ]])
290 ],[
291 AC_MSG_RESULT([yes])
292 HAVE_GETHOSTBYNAME="1"
293 ],[
294 AC_MSG_RESULT([no])
295 winsock_LIB=""
296 LIBS=$my_ac_save_LIBS
297 ])
298 fi
299 fi
300fi
301
302if test "$HAVE_GETHOSTBYNAME" != "1"
303then
304 dnl This is for Minix 3.1
305 AC_MSG_CHECKING([for gethostbyname for Minix 3])
306 AC_LINK_IFELSE([
307 AC_LANG_PROGRAM([[
308/* Older Minix versions may need <net/gen/netdb.h> here instead */
309#include <netdb.h>
310 ]],[[
311 gethostbyname("www.dummysite.com");
312 ]])
313 ],[
314 AC_MSG_RESULT([yes])
315 HAVE_GETHOSTBYNAME="1"
316 ],[
317 AC_MSG_RESULT([no])
318 ])
319fi
320
321if test "$HAVE_GETHOSTBYNAME" != "1"
322then
323 dnl This is for eCos with a stubbed DNS implementation
324 AC_MSG_CHECKING([for gethostbyname for eCos])
325 AC_LINK_IFELSE([
326 AC_LANG_PROGRAM([[
327#include <stdio.h>
328#include <netdb.h>
329 ]],[[
330 gethostbyname("www.dummysite.com");
331 ]])
332 ],[
333 AC_MSG_RESULT([yes])
334 HAVE_GETHOSTBYNAME="1"
335 ],[
336 AC_MSG_RESULT([no])
337 ])
338fi
339
340if test "$HAVE_GETHOSTBYNAME" != "1"
341then
342 dnl gethostbyname in the net lib - for BeOS
343 AC_CHECK_LIB(net, gethostbyname,
344 [HAVE_GETHOSTBYNAME="1"
345 LIBS="$LIBS -lnet"
346 ])
347fi
348
349
350if test "$HAVE_GETHOSTBYNAME" != "1"; then
351 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
352fi
353
354dnl resolv lib for iPhone
355AS_IF([test "x$host_vendor" = "xapple"], [
356 AC_MSG_CHECKING([for iPhone target])
357 AC_COMPILE_IFELSE([
358 AC_LANG_PROGRAM([[
359#include "TargetConditionals.h"
360 ]], [[
361#if TARGET_OS_IPHONE == 0
362#error Not an iPhone target
363#endif
364return 0;
365 ]])
366 ],[
367 AC_MSG_RESULT([yes])
368 AC_SEARCH_LIBS([res_servicename], [resolv], [
369 AC_DEFINE([CARES_USE_LIBRESOLV], [1], [Use resolver library to configure cares])
370 ], [
371 AC_MSG_ERROR([Unable to find libresolv which is required for iPhone targets])
372 ])
373 ],[
374 AC_MSG_RESULT([no])
375 ])
376])
377
378dnl resolve lib?
379AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
380
381if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
382 AC_CHECK_LIB(resolve, strcasecmp,
383 [LIBS="-lresolve $LIBS"],
384 ,
385 -lnsl)
386fi
387ac_cv_func_strcasecmp="no"
388
389CARES_CHECK_LIBS_CONNECT
390
391dnl **********************************************************************
392dnl In case that function clock_gettime with monotonic timer is available,
393dnl check for additional required libraries.
394dnl **********************************************************************
395CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
396
397AC_MSG_CHECKING([whether to use libgcc])
398AC_ARG_ENABLE(libgcc,
399AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
400[ case "$enableval" in
401 yes)
402 LIBS="$LIBS -lgcc"
403 AC_MSG_RESULT(yes)
404 ;;
405 *) AC_MSG_RESULT(no)
406 ;;
407 esac ],
408 AC_MSG_RESULT(no)
409)
410
411
412dnl Let's hope this split URL remains working:
413dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
414dnl genprogc/thread_quick_ref.htm
415
416
417dnl **********************************************************************
418dnl Back to "normal" configuring
419dnl **********************************************************************
420
421dnl Checks for header files.
422AC_HEADER_STDC
423
424CURL_CHECK_HEADER_MALLOC
425CURL_CHECK_HEADER_MEMORY
426
427dnl check for a few basic system headers we need
428AC_CHECK_HEADERS(
429 sys/types.h \
430 sys/time.h \
431 sys/select.h \
432 sys/socket.h \
433 sys/ioctl.h \
434 sys/param.h \
435 sys/uio.h \
436 assert.h \
437 netdb.h \
438 netinet/in.h \
439 netinet/tcp.h \
440 net/if.h \
441 errno.h \
442 socket.h \
443 strings.h \
444 stdbool.h \
445 time.h \
446 limits.h \
447 arpa/nameser.h \
448 arpa/nameser_compat.h \
449 arpa/inet.h,
450dnl to do if not found
451[],
452dnl to do if found
453[],
454dnl default includes
455[
456#ifdef HAVE_SYS_TYPES_H
457#include <sys/types.h>
458#endif
459#ifdef HAVE_SYS_TIME_H
460#include <sys/time.h>
461#endif
462dnl We do this default-include simply to make sure that the nameser_compat.h
463dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
464dnl (and others?) is not designed to allow this.
465#ifdef HAVE_ARPA_NAMESER_H
466#include <arpa/nameser.h>
467#endif
468
469dnl *Sigh* these are needed in order for net/if.h to get properly detected.
470#ifdef HAVE_SYS_SOCKET_H
471#include <sys/socket.h>
472#endif
473#ifdef HAVE_NETINET_IN_H
474#include <netinet/in.h>
475#endif
476]
477)
478
479dnl Checks for typedefs, structures, and compiler characteristics.
480AC_C_CONST
481AC_TYPE_SIZE_T
482AC_HEADER_TIME
483CURL_CHECK_STRUCT_TIMEVAL
484
485AC_CHECK_TYPE(long long,
486 [AC_DEFINE(HAVE_LONGLONG, 1,
487 [Define to 1 if the compiler supports the 'long long' data type.])]
488 longlong="yes"
489)
490
491if test "xyes" = "x$longlong"; then
492 AC_MSG_CHECKING([if numberLL works])
493 AC_COMPILE_IFELSE([
494 AC_LANG_PROGRAM([[
495 ]],[[
496 long long val = 1000LL;
497 ]])
498 ],[
499 AC_MSG_RESULT([yes])
500 AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
501 ],[
502 AC_MSG_RESULT([no])
503 ])
504fi
505
506
507# check for ssize_t
508AC_CHECK_TYPE(ssize_t, ,
509 AC_DEFINE(ssize_t, int, [the signed version of size_t]))
510
511# check for bool type
512AC_CHECK_TYPE([bool],[
513 AC_DEFINE(HAVE_BOOL_T, 1,
514 [Define to 1 if bool is an available type.])
515], ,[
516#ifdef HAVE_SYS_TYPES_H
517#include <sys/types.h>
518#endif
519#ifdef HAVE_STDBOOL_H
520#include <stdbool.h>
521#endif
522])
523
524CARES_CONFIGURE_ARES_SOCKLEN_T
525
526TYPE_IN_ADDR_T
527
528TYPE_SOCKADDR_STORAGE
529
530TYPE_SIG_ATOMIC_T
531
532AC_TYPE_SIGNAL
533
534CURL_CHECK_FUNC_RECV
535CURL_CHECK_FUNC_RECVFROM
536CURL_CHECK_FUNC_SEND
537CURL_CHECK_MSG_NOSIGNAL
538
539CARES_CHECK_FUNC_CLOSESOCKET
540CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
541CARES_CHECK_FUNC_CONNECT
542CARES_CHECK_FUNC_FCNTL
543CARES_CHECK_FUNC_FREEADDRINFO
544CARES_CHECK_FUNC_GETADDRINFO
545CARES_CHECK_FUNC_GETENV
546CARES_CHECK_FUNC_GETHOSTBYADDR
547CARES_CHECK_FUNC_GETHOSTBYNAME
548CARES_CHECK_FUNC_GETHOSTNAME
549CARES_CHECK_FUNC_GETSERVBYPORT_R
550CARES_CHECK_FUNC_INET_NET_PTON
551CARES_CHECK_FUNC_INET_NTOP
552CARES_CHECK_FUNC_INET_PTON
553CARES_CHECK_FUNC_IOCTL
554CARES_CHECK_FUNC_IOCTLSOCKET
555CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
556CARES_CHECK_FUNC_SETSOCKOPT
557CARES_CHECK_FUNC_SOCKET
558CARES_CHECK_FUNC_STRCASECMP
559CARES_CHECK_FUNC_STRCMPI
560CARES_CHECK_FUNC_STRDUP
561CARES_CHECK_FUNC_STRICMP
562CARES_CHECK_FUNC_STRNCASECMP
563CARES_CHECK_FUNC_STRNCMPI
564CARES_CHECK_FUNC_STRNICMP
565CARES_CHECK_FUNC_WRITEV
566
567
568dnl check for AF_INET6
569CARES_CHECK_CONSTANT(
570 [
571#undef inline
572#ifdef HAVE_WINDOWS_H
573#ifndef WIN32_LEAN_AND_MEAN
574#define WIN32_LEAN_AND_MEAN
575#endif
576#include <windows.h>
577#ifdef HAVE_WINSOCK2_H
578#include <winsock2.h>
579#endif
580#else
581#ifdef HAVE_SYS_TYPES_H
582#include <sys/types.h>
583#endif
584#ifdef HAVE_SYS_SOCKET_H
585#include <sys/socket.h>
586#endif
587#endif
588 ], [PF_INET6],
589 AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
590)
591
592dnl check for PF_INET6
593CARES_CHECK_CONSTANT(
594 [
595#undef inline
596#ifdef HAVE_WINDOWS_H
597#ifndef WIN32_LEAN_AND_MEAN
598#define WIN32_LEAN_AND_MEAN
599#endif
600#include <windows.h>
601#ifdef HAVE_WINSOCK2_H
602#include <winsock2.h>
603#endif
604#else
605#ifdef HAVE_SYS_TYPES_H
606#include <sys/types.h>
607#endif
608#ifdef HAVE_SYS_SOCKET_H
609#include <sys/socket.h>
610#endif
611#endif
612 ], [AF_INET6],
613 AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
614)
615
616
617dnl check for the in6_addr structure
618CARES_CHECK_STRUCT(
619 [
620#undef inline
621#ifdef HAVE_WINDOWS_H
622#ifndef WIN32_LEAN_AND_MEAN
623#define WIN32_LEAN_AND_MEAN
624#endif
625#include <windows.h>
626#ifdef HAVE_WINSOCK2_H
627#include <winsock2.h>
628#ifdef HAVE_WS2TCPIP_H
629#include <ws2tcpip.h>
630#endif
631#endif
632#else
633#ifdef HAVE_SYS_TYPES_H
634#include <sys/types.h>
635#endif
636#ifdef HAVE_NETINET_IN_H
637#include <netinet/in.h>
638#endif
639#endif
640 ], [in6_addr],
641 AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
642)
643
644dnl check for the sockaddr_in6 structure
645CARES_CHECK_STRUCT(
646 [
647#undef inline
648#ifdef HAVE_WINDOWS_H
649#ifndef WIN32_LEAN_AND_MEAN
650#define WIN32_LEAN_AND_MEAN
651#endif
652#include <windows.h>
653#ifdef HAVE_WINSOCK2_H
654#include <winsock2.h>
655#ifdef HAVE_WS2TCPIP_H
656#include <ws2tcpip.h>
657#endif
658#endif
659#else
660#ifdef HAVE_SYS_TYPES_H
661#include <sys/types.h>
662#endif
663#ifdef HAVE_NETINET_IN_H
664#include <netinet/in.h>
665#endif
666#endif
667 ], [sockaddr_in6],
668 AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
669 [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
670)
671
672AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
673 AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
674 [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
675 , ,
676 [
677#undef inline
678#ifdef HAVE_WINDOWS_H
679#ifndef WIN32_LEAN_AND_MEAN
680#define WIN32_LEAN_AND_MEAN
681#endif
682#include <windows.h>
683#ifdef HAVE_WINSOCK2_H
684#include <winsock2.h>
685#ifdef HAVE_WS2TCPIP_H
686#include <ws2tcpip.h>
687#endif
688#endif
689#else
690#ifdef HAVE_SYS_TYPES_H
691#include <sys/types.h>
692#endif
693#ifdef HAVE_NETINET_IN_H
694#include <netinet/in.h>
695#endif
696#endif
697 ])
698
699dnl check for the addrinfo structure
700AC_CHECK_MEMBER(struct addrinfo.ai_flags,
701 AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
702 [Define to 1 if you have struct addrinfo.]),,
703 [
704#undef inline
705#ifdef HAVE_WINDOWS_H
706#ifndef WIN32_LEAN_AND_MEAN
707#define WIN32_LEAN_AND_MEAN
708#endif
709#include <windows.h>
710#ifdef HAVE_WINSOCK2_H
711#include <winsock2.h>
712#ifdef HAVE_WS2TCPIP_H
713#include <ws2tcpip.h>
714#endif
715#endif
716#else
717#ifdef HAVE_SYS_TYPES_H
718#include <sys/types.h>
719#endif
720#ifdef HAVE_NETINET_IN_H
721#include <netinet/in.h>
722#endif
723#ifdef HAVE_SYS_SOCKET_H
724#include <sys/socket.h>
725#endif
726#ifdef HAVE_NETDB_H
727#include <netdb.h>
728#endif
729#endif
730 ]
731)
732
733
734AC_CHECK_FUNCS([bitncmp \
735 gettimeofday \
736 if_indextoname
737],[
738],[
739 func="$ac_func"
740 AC_MSG_CHECKING([deeper for $func])
741 AC_LINK_IFELSE([
742 AC_LANG_PROGRAM([[
743 ]],[[
744 $func ();
745 ]])
746 ],[
747 AC_MSG_RESULT([yes])
748 eval "ac_cv_func_$func=yes"
749 AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
750 [Define to 1 if you have the $func function.])
751 ],[
752 AC_MSG_RESULT([but still no])
753 ])
754])
755
756
757dnl Check if the getnameinfo function is available
758dnl and get the types of five of its arguments.
759CURL_CHECK_FUNC_GETNAMEINFO
760
761
762AC_C_BIGENDIAN(
763 [AC_DEFINE(ARES_BIG_ENDIAN, 1,
764 [define this if ares is built for a big endian system])],
765 ,
766 [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
767)
768
769dnl Check for user-specified random device
770AC_ARG_WITH(random,
771AC_HELP_STRING([--with-random=FILE],
772 [read randomness from FILE (default=/dev/urandom)]),
773 [ RANDOM_FILE="$withval" ],
774 [
775 dnl Check for random device. If we're cross compiling, we can't
776 dnl check, and it's better to assume it doesn't exist than it is
777 dnl to fail on AC_CHECK_FILE or later.
778 if test "$cross_compiling" = "no"; then
779 AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
780 else
781 AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
782 fi
783
784 ]
785)
786if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
787 AC_SUBST(RANDOM_FILE)
788 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
789 [a suitable file/device to read random data from])
790fi
791
792CARES_CHECK_OPTION_NONBLOCKING
793CARES_CHECK_NONBLOCKING_SOCKET
794
795CARES_CONFIGURE_SYMBOL_HIDING
796
797CARES_PRIVATE_LIBS="$LIBS"
798AC_SUBST(CARES_PRIVATE_LIBS)
799
800CARES_CFLAG_EXTRAS=""
801if test X"$want_werror" = Xyes; then
802 CARES_CFLAG_EXTRAS="-Werror"
803fi
804AC_SUBST(CARES_CFLAG_EXTRAS)
805
806dnl squeeze whitespace out of some variables
807
808squeeze CFLAGS
809squeeze CPPFLAGS
810squeeze DEFS
811squeeze LDFLAGS
812squeeze LIBS
813
814squeeze CARES_PRIVATE_LIBS
815
816XC_CHECK_BUILD_FLAGS
817
818AC_MSG_CHECKING([whether to build tests])
819AC_ARG_ENABLE(tests,
820 AC_HELP_STRING([--enable-tests], [build test suite]),
821 [ build_tests="$enableval" ],
822 [ if test "x$HAVE_CXX11" = "x1" && test "x$cross_compiling" = "xno" ; then
823 build_tests="yes"
824 else
825 build_tests="no"
826 fi
827 ]
828)
829
830if test "x$build_tests" = "xyes" ; then
831 if test "x$HAVE_CXX11" = "0" ; then
832 AC_MSG_ERROR([*** Building tests requires a CXX11 compiler])
833 fi
834 if test "x$cross_compiling" = "xyes" ; then
835 AC_MSG_ERROR([*** Tests not supported when cross compiling])
836 fi
837fi
838AC_MSG_RESULT([$build_tests])
839
840if test "x$build_tests" = "xyes" ; then
841 AC_CONFIG_SUBDIRS([test])
842fi
843
844AC_CONFIG_FILES([Makefile libcares.pc])
845AC_OUTPUT
846XC_AMEND_DISTCLEAN(['.'])