Merge branch 'upstream' into tizen
[platform/upstream/c-ares.git] / configure.ac
1 AC_PREREQ(2.57)
2
3 dnl Version not hardcoded here. Fetched later from ares_version.h
4 AC_INIT([c-ares], [1.12.0],
5   [c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares])
6
7 XC_OVR_ZZ50
8 XC_OVR_ZZ60
9 CARES_OVERRIDE_AUTOCONF
10
11 AC_CONFIG_SRCDIR([ares_ipv6.h])
12 AC_CONFIG_HEADERS([ares_config.h ares_build.h])
13 AC_CONFIG_MACRO_DIR([m4])
14 AM_MAINTAINER_MODE
15 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
16
17 CARES_CHECK_OPTION_DEBUG
18 CARES_CHECK_OPTION_OPTIMIZE
19 CARES_CHECK_OPTION_WARNINGS
20 CARES_CHECK_OPTION_WERROR
21 CARES_CHECK_OPTION_CURLDEBUG
22 CARES_CHECK_OPTION_SYMBOL_HIDING
23 CARES_CHECK_OPTION_EXPOSE_STATICS
24
25 XC_CHECK_PATH_SEPARATOR
26
27 dnl SED is mandatory for configure process and libtool.
28 dnl Set it now, allowing it to be changed later.
29 AC_PATH_PROG([SED], [sed], [not_found],
30   [$PATH:/usr/bin:/usr/local/bin])
31 if test -z "$SED" || test "$SED" = "not_found"; then
32   AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
33 fi
34 AC_SUBST([SED])
35
36 dnl GREP is mandatory for configure process and libtool.
37 dnl Set it now, allowing it to be changed later.
38 AC_PATH_PROG([GREP], [grep], [not_found],
39   [$PATH:/usr/bin:/usr/local/bin])
40 if test -z "$GREP" || test "$GREP" = "not_found"; then
41   AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
42 fi
43 AC_SUBST([GREP])
44
45 dnl EGREP is mandatory for configure process and libtool.
46 dnl Set it now, allowing it to be changed later.
47 if 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])
51 else
52   AC_PATH_PROG([EGREP], [egrep], [not_found],
53     [$PATH:/usr/bin:/usr/local/bin])
54 fi
55 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
56   AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
57 fi
58 AC_SUBST([EGREP])
59
60 dnl AR is mandatory for configure process and libtool.
61 dnl This is target dependent, so check it as a tool.
62 AC_PATH_TOOL([AR], [ar], [not_found],
63   [$PATH:/usr/bin:/usr/local/bin])
64 if test -z "$AR" || test "$AR" = "not_found"; then
65   AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
66 fi
67 AC_SUBST([AR])
68
69 AX_CODE_COVERAGE
70
71 dnl Remove non-configure distributed ares_build.h
72 if test -f ${srcdir}/ares_build.h; then
73   rm -f ${srcdir}/ares_build.h
74 fi
75
76 dnl
77 dnl Detect the canonical host and target build environment
78 dnl
79
80 AC_CANONICAL_HOST
81 dnl Get system canonical name
82 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
83
84 XC_CHECK_PROG_CC
85 AX_CXX_COMPILE_STDCXX_11([noext],[optional])
86
87 XC_AUTOMAKE
88
89 dnl This defines _ALL_SOURCE for AIX
90 CARES_CHECK_AIX_ALL_SOURCE
91
92 dnl Our configure and build reentrant settings
93 CARES_CONFIGURE_THREAD_SAFE
94 CARES_CONFIGURE_REENTRANT
95
96 dnl check for how to do large files
97 AC_SYS_LARGEFILE
98
99 case $host_os in
100   solaris*)
101     AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
102     ;;
103 esac
104
105 XC_LIBTOOL
106
107 #
108 # Automake conditionals based on libtool related checks
109 #
110
111 AM_CONDITIONAL([CARES_LT_SHLIB_USE_VERSION_INFO],
112   [test "x$xc_lt_shlib_use_version_info" = 'xyes'])
113 AM_CONDITIONAL([CARES_LT_SHLIB_USE_NO_UNDEFINED],
114   [test "x$xc_lt_shlib_use_no_undefined" = 'xyes'])
115 AM_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
134 AM_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
143 CPPFLAG_CARES_STATICLIB=
144 if test "x$xc_lt_build_static_only" = 'xyes'; then
145   CPPFLAG_CARES_STATICLIB='-DCARES_STATICLIB'
146 fi
147 AC_SUBST([CPPFLAG_CARES_STATICLIB])
148
149 dnl **********************************************************************
150 dnl platform/compiler/architecture specific checks/flags
151 dnl **********************************************************************
152
153 CARES_CHECK_COMPILER
154 CARES_SET_COMPILER_BASIC_OPTS
155 CARES_SET_COMPILER_DEBUG_OPTS
156 CARES_SET_COMPILER_OPTIMIZE_OPTS
157 CARES_SET_COMPILER_WARNING_OPTS
158
159 if 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   #
169 fi
170
171 CARES_CHECK_COMPILER_HALT_ON_ERROR
172 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
173 CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
174 CARES_CHECK_COMPILER_SYMBOL_HIDING
175
176 CARES_CHECK_CURLDEBUG
177 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
178
179 dnl **********************************************************************
180 dnl Compilation based checks should not be done before this point.
181 dnl **********************************************************************
182
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 **********************************************************************
189
190 CURL_CHECK_HEADER_WINDOWS
191 CURL_CHECK_NATIVE_WINDOWS
192 case 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     ;;
203 esac
204
205 dnl **********************************************************************
206 dnl Checks for libraries.
207 dnl **********************************************************************
208
209 CARES_CHECK_LIB_XNET
210
211 dnl gethostbyname without lib or in the nsl lib?
212 AC_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
221 if test "$HAVE_GETHOSTBYNAME" != "1"
222 then
223   dnl gethostbyname in the socket lib?
224   AC_CHECK_LIB(socket, gethostbyname,
225                [HAVE_GETHOSTBYNAME="1"
226                LIBS="$LIBS -lsocket"
227                ])
228 fi
229
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"
233 then
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   ])
249 fi
250
251 if test "$HAVE_GETHOSTBYNAME" != "1"
252 then
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
300 fi
301
302 if test "$HAVE_GETHOSTBYNAME" != "1"
303 then
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   ])
319 fi
320
321 if test "$HAVE_GETHOSTBYNAME" != "1"
322 then
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   ])
338 fi
339
340 if test "$HAVE_GETHOSTBYNAME" != "1"
341 then
342   dnl gethostbyname in the net lib - for BeOS
343   AC_CHECK_LIB(net, gethostbyname,
344                [HAVE_GETHOSTBYNAME="1"
345                LIBS="$LIBS -lnet"
346                ])
347 fi
348
349
350 if test "$HAVE_GETHOSTBYNAME" != "1"; then
351   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
352 fi
353
354 dnl resolv lib for iPhone
355 AS_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
364 return 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
378 dnl resolve lib?
379 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
380
381 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
382   AC_CHECK_LIB(resolve, strcasecmp,
383               [LIBS="-lresolve $LIBS"],
384                ,
385                -lnsl)
386 fi
387 ac_cv_func_strcasecmp="no"
388
389 CARES_CHECK_LIBS_CONNECT
390
391 dnl **********************************************************************
392 dnl In case that function clock_gettime with monotonic timer is available,
393 dnl check for additional required libraries.
394 dnl **********************************************************************
395 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
396
397 AC_MSG_CHECKING([whether to use libgcc])
398 AC_ARG_ENABLE(libgcc,
399 AC_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
412 dnl Let's hope this split URL remains working:
413 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
414 dnl genprogc/thread_quick_ref.htm
415
416
417 dnl **********************************************************************
418 dnl Back to "normal" configuring
419 dnl **********************************************************************
420
421 dnl Checks for header files.
422 AC_HEADER_STDC
423
424 CURL_CHECK_HEADER_MALLOC
425 CURL_CHECK_HEADER_MEMORY
426
427 dnl check for a few basic system headers we need
428 AC_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,
450 dnl to do if not found
451 [],
452 dnl to do if found
453 [],
454 dnl 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
462 dnl We do this default-include simply to make sure that the nameser_compat.h
463 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
464 dnl (and others?) is not designed to allow this.
465 #ifdef HAVE_ARPA_NAMESER_H
466 #include <arpa/nameser.h>
467 #endif
468
469 dnl *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
479 dnl Checks for typedefs, structures, and compiler characteristics.
480 AC_C_CONST
481 AC_TYPE_SIZE_T
482 AC_HEADER_TIME
483 CURL_CHECK_STRUCT_TIMEVAL
484
485 AC_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
491 if 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   ])
504 fi
505
506
507 # check for ssize_t
508 AC_CHECK_TYPE(ssize_t, ,
509    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
510
511 # check for bool type
512 AC_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
524 CARES_CONFIGURE_ARES_SOCKLEN_T
525
526 TYPE_IN_ADDR_T
527
528 TYPE_SOCKADDR_STORAGE
529
530 TYPE_SIG_ATOMIC_T
531
532 AC_TYPE_SIGNAL
533
534 CURL_CHECK_FUNC_RECV
535 CURL_CHECK_FUNC_RECVFROM
536 CURL_CHECK_FUNC_SEND
537 CURL_CHECK_MSG_NOSIGNAL
538
539 CARES_CHECK_FUNC_CLOSESOCKET
540 CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
541 CARES_CHECK_FUNC_CONNECT
542 CARES_CHECK_FUNC_FCNTL
543 CARES_CHECK_FUNC_FREEADDRINFO
544 CARES_CHECK_FUNC_GETADDRINFO
545 CARES_CHECK_FUNC_GETENV
546 CARES_CHECK_FUNC_GETHOSTBYADDR
547 CARES_CHECK_FUNC_GETHOSTBYNAME
548 CARES_CHECK_FUNC_GETHOSTNAME
549 CARES_CHECK_FUNC_GETSERVBYPORT_R
550 CARES_CHECK_FUNC_INET_NET_PTON
551 CARES_CHECK_FUNC_INET_NTOP
552 CARES_CHECK_FUNC_INET_PTON
553 CARES_CHECK_FUNC_IOCTL
554 CARES_CHECK_FUNC_IOCTLSOCKET
555 CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
556 CARES_CHECK_FUNC_SETSOCKOPT
557 CARES_CHECK_FUNC_SOCKET
558 CARES_CHECK_FUNC_STRCASECMP
559 CARES_CHECK_FUNC_STRCMPI
560 CARES_CHECK_FUNC_STRDUP
561 CARES_CHECK_FUNC_STRICMP
562 CARES_CHECK_FUNC_STRNCASECMP
563 CARES_CHECK_FUNC_STRNCMPI
564 CARES_CHECK_FUNC_STRNICMP
565 CARES_CHECK_FUNC_WRITEV
566
567
568 dnl check for AF_INET6
569 CARES_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
592 dnl check for PF_INET6
593 CARES_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
617 dnl check for the in6_addr structure
618 CARES_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
644 dnl check for the sockaddr_in6 structure
645 CARES_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
672 AC_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
699 dnl check for the addrinfo structure
700 AC_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
734 AC_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
757 dnl Check if the getnameinfo function is available
758 dnl and get the types of five of its arguments.
759 CURL_CHECK_FUNC_GETNAMEINFO
760
761
762 AC_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
769 dnl Check for user-specified random device
770 AC_ARG_WITH(random,
771 AC_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 )
786 if 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])
790 fi
791
792 CARES_CHECK_OPTION_NONBLOCKING
793 CARES_CHECK_NONBLOCKING_SOCKET
794
795 CARES_CONFIGURE_SYMBOL_HIDING
796
797 CARES_PRIVATE_LIBS="$LIBS"
798 AC_SUBST(CARES_PRIVATE_LIBS)
799
800 CARES_CFLAG_EXTRAS=""
801 if test X"$want_werror" = Xyes; then
802   CARES_CFLAG_EXTRAS="-Werror"
803 fi
804 AC_SUBST(CARES_CFLAG_EXTRAS)
805
806 dnl squeeze whitespace out of some variables
807
808 squeeze CFLAGS
809 squeeze CPPFLAGS
810 squeeze DEFS
811 squeeze LDFLAGS
812 squeeze LIBS
813
814 squeeze CARES_PRIVATE_LIBS
815
816 XC_CHECK_BUILD_FLAGS
817
818 AC_MSG_CHECKING([whether to build tests])
819 AC_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
830 if 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
837 fi
838 AC_MSG_RESULT([$build_tests])
839
840 if test "x$build_tests" = "xyes" ; then
841   AC_CONFIG_SUBDIRS([test])
842 fi
843
844 AC_CONFIG_FILES([Makefile libcares.pc])
845 AC_OUTPUT
846 XC_AMEND_DISTCLEAN(['.'])