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