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