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