Make sure that configure process tests are done with the same _REENTRANT
[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 dnl SED is mandatory for configure process and libtool.
12 dnl Set it now and prevent it from being changed later.
13 AC_PATH_PROG([SED], [sed], [not_found],
14   [$PATH:/usr/bin:/usr/local/bin])
15 if test -z "$SED" || test "$SED" = "not_found"; then
16   AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
17 fi
18 ac_cv_prog_sed="$SED"
19 ac_cv_prog_SED="$SED"
20 AC_SUBST([SED])
21
22 dnl GREP is mandatory for configure process and libtool.
23 dnl Set it now and prevent it from being changed later.
24 AC_PATH_PROG([GREP], [grep], [not_found],
25   [$PATH:/usr/bin:/usr/local/bin])
26 if test -z "$GREP" || test "$GREP" = "not_found"; then
27   AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
28 fi
29 ac_cv_prog_grep="$GREP"
30 ac_cv_prog_GREP="$GREP"
31 AC_SUBST([GREP])
32
33 dnl EGREP is mandatory for configure process and libtool.
34 dnl Set it now and prevent it from being 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_cv_prog_egrep="$EGREP"
47 ac_cv_prog_EGREP="$EGREP"
48 AC_SUBST([EGREP])
49
50 dnl AR is mandatory for configure process and libtool.
51 dnl This is target dependant, so check it as a tool.
52 AC_PATH_TOOL([AR], [ar], [not_found],
53   [$PATH:/usr/bin:/usr/local/bin])
54 if test -z "$AR" || test "$AR" = "not_found"; then
55   AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
56 fi
57 AC_SUBST([AR])
58
59 dnl Fetch c-ares version from ares_version.h
60 VERSION=`$SED -ne 's/^#define ARES_VERSION_STR "\(.*\)"/\1/p' ${srcdir}/ares_version.h`
61 AM_INIT_AUTOMAKE([c-ares], [$VERSION])
62 AC_MSG_CHECKING([c-ares version])
63 AC_MSG_RESULT([$VERSION])
64
65 dnl
66 dnl Detect the canonical host and target build environment
67 dnl
68
69 AC_CANONICAL_HOST
70 dnl Get system canonical name
71 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
72
73 AC_AIX
74 AC_PROG_CC
75 AM_PROG_CC_C_O
76 AC_PROG_INSTALL
77
78 dnl Our configure and build reentrant settings
79 CONFIGURE_WITH_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 dnl ************************************************************
94 dnl Option to switch on debug options. This makes an assumption that
95 dnl this is built as an 'ares' subdir in the curl source tree. Subject for
96 dnl improval in the future!
97 dnl
98 AC_MSG_CHECKING([whether to enable debug options])
99 AC_ARG_ENABLE(debug,
100 AC_HELP_STRING([--enable-debug],[Enable pedantic debug options])
101 AC_HELP_STRING([--disable-debug],[Disable debug options]),
102 [ case "$enableval" in
103   no)
104        AC_MSG_RESULT(no)
105        ;;
106   *)   AC_MSG_RESULT(yes)
107
108     dnl when doing the debug stuff, use static library only
109     AC_DISABLE_SHARED
110
111     debugbuild="yes"
112
113     dnl the entire --enable-debug is a hack that lives and runs on top of
114     dnl libcurl stuff so this BUILDING_LIBCURL is not THAT much uglier
115     AC_DEFINE(BUILDING_LIBCURL, 1, [when building as static part of libcurl])
116
117     CPPFLAGS="$CPPFLAGS -DCURLDEBUG -I$srcdir/../include"
118     CFLAGS="$CFLAGS -g" 
119
120     dnl set compiler "debug" options to become more picky, and remove
121     dnl optimize options from CFLAGS
122     CURL_CC_DEBUG_OPTS
123
124        ;;
125   esac ],
126        AC_MSG_RESULT(no)
127 )
128 AM_CONDITIONAL(DEBUGBUILD, test x$debugbuild = xyes)
129
130 dnl skip libtool C++ and Fortran compiler checks
131 m4_ifdef([AC_PROG_CXX], [m4_undefine([AC_PROG_CXX])])
132 m4_defun([AC_PROG_CXX],[])
133 m4_ifdef([AC_PROG_CXXCPP], [m4_undefine([AC_PROG_CXXCPP])])
134 m4_defun([AC_PROG_CXXCPP],[true])
135 m4_ifdef([AC_PROG_F77], [m4_undefine([AC_PROG_F77])])
136 m4_defun([AC_PROG_F77],[])
137
138 dnl skip libtool C++ and Fortran linker checks
139 m4_ifdef([AC_LIBTOOL_CXX], [m4_undefine([AC_LIBTOOL_CXX])])
140 m4_defun([AC_LIBTOOL_CXX],[])
141 m4_ifdef([AC_LIBTOOL_CXXCPP], [m4_undefine([AC_LIBTOOL_CXXCPP])])
142 m4_defun([AC_LIBTOOL_CXXCPP],[true])
143 m4_ifdef([AC_LIBTOOL_F77], [m4_undefine([AC_LIBTOOL_F77])])
144 m4_defun([AC_LIBTOOL_F77],[])
145
146 dnl force libtool to build static libraries with PIC on AMD64-linux
147 AC_MSG_CHECKING([if arch-OS host is AMD64-linux (to build static libraries with PIC)])
148 case $host in
149   x86_64*linux*)
150     AC_MSG_RESULT([yes])
151     with_pic=yes
152     ;;
153   *)
154     AC_MSG_RESULT([no])
155     ;;
156 esac
157
158 dnl libtool setup
159 AC_PROG_LIBTOOL
160
161 AC_MSG_CHECKING([if we need -no-undefined])
162 case $host in
163   *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
164     need_no_undefined=yes
165     ;;
166   *)
167     need_no_undefined=no
168     ;;
169 esac
170 AC_MSG_RESULT($need_no_undefined)
171 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
172
173 dnl **********************************************************************
174 dnl check if this is the Intel ICC compiler, and if so make it stricter
175 dnl (convert warning 147 into an error) so that it properly can detect the
176 dnl gethostbyname_r() version
177 dnl **********************************************************************
178 CURL_DETECT_ICC([CFLAGS="$CFLAGS -we 147"])
179
180 dnl **********************************************************************
181 dnl platform/compiler/architecture specific checks/flags
182 dnl **********************************************************************
183
184 case $host in
185   #
186   x86_64*linux*)
187     #
188     dnl find out if icc is being used
189     if test "z$ICC" = "z"; then
190       CURL_DETECT_ICC
191     fi
192     #
193     if test "$ICC" = "yes"; then
194       dnl figure out icc version
195       AC_MSG_CHECKING([icc version])
196       iccver=`$CC -dumpversion`
197       iccnhi=`echo $iccver | cut -d . -f1`
198       iccnlo=`echo $iccver | cut -d . -f2`
199       iccnum=`(expr $iccnhi "*" 100 + $iccnlo) 2>/dev/null`
200       AC_MSG_RESULT($iccver)
201       #
202       if test "$iccnum" -ge "900" && test "$iccnum" -lt "1000"; then
203         dnl icc 9.X specific
204         CFLAGS="$CFLAGS -i-dynamic"
205       fi
206       #
207       if test "$iccnum" -ge "1000"; then
208         dnl icc 10.X or later
209         CFLAGS="$CFLAGS -shared-intel"
210       fi
211       #
212     fi
213     ;;
214   #
215 esac
216
217 AC_MSG_CHECKING([whether we are using the IBM C compiler])
218 CURL_CHECK_DEF([__IBMC__], [], [silent])
219 CURL_CHECK_DEF([__IBMCPP__], [], [silent])
220 if test "$curl_cv_have_def___IBMC__" = "yes" ||
221   test "$curl_cv_have_def___IBMCPP__" = "yes"; then
222   AC_MSG_RESULT([yes])
223   dnl Ensure that compiler optimizations are always thread-safe.
224   CFLAGS="$CFLAGS -qthreaded"
225   dnl Disable type based strict aliasing optimizations, using worst
226   dnl case aliasing assumptions when compiling. Type based aliasing
227   dnl would restrict the lvalues that could be safely used to access
228   dnl a data object.
229   CFLAGS="$CFLAGS -qnoansialias"
230   dnl Force compiler to stop after the compilation phase, without
231   dnl generating an object code file when compilation has errors.
232   CFLAGS="$CFLAGS -qhalt=e"
233 else
234   AC_MSG_RESULT([no])
235 fi
236
237 AC_MSG_CHECKING([whether we are using the DEC/Compaq C compiler])
238 CURL_CHECK_DEF([__DECC], [], [silent])
239 CURL_CHECK_DEF([__DECC_VER], [], [silent])
240 if test "$curl_cv_have_def___DECC" = "yes" ||
241   test "$curl_cv_have_def___DECC_VER" = "yes"; then
242   AC_MSG_RESULT([yes])
243   dnl Select strict ANSI C compiler mode
244   CFLAGS="$CFLAGS -std1"
245   dnl Select a higher warning level than default level2
246   CFLAGS="$CFLAGS -msg_enable level3"
247   dnl Generate warnings for missing function prototypes
248   CFLAGS="$CFLAGS -warnprotos"
249   dnl Change some warnings into fatal errors
250   CFLAGS="$CFLAGS -msg_fatal toofewargs,toomanyargs"
251 else
252   AC_MSG_RESULT([no])
253 fi
254
255 CURL_CHECK_COMPILER_HALT_ON_ERROR
256 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
257
258 dnl **********************************************************************
259 dnl Compilation based checks should not be done before this point.
260 dnl **********************************************************************
261
262 dnl **********************************************************************
263 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h 
264 dnl and ws2tcpip.h take precedence over any other further checks which 
265 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
266 dnl this specific header files. And do them before its results are used.
267 dnl **********************************************************************
268
269 CURL_CHECK_HEADER_WINDOWS
270 CURL_CHECK_NATIVE_WINDOWS
271 case X-"$ac_cv_native_windows" in
272   X-yes)
273     CURL_CHECK_HEADER_WINSOCK
274     CURL_CHECK_HEADER_WINSOCK2
275     CURL_CHECK_HEADER_WS2TCPIP
276     ;;
277   *)
278     ac_cv_header_winsock_h="no"
279     ac_cv_header_winsock2_h="no"
280     ac_cv_header_ws2tcpip_h="no"
281     ;;
282 esac
283
284 dnl **********************************************************************
285 dnl Checks for libraries.
286 dnl **********************************************************************
287
288 dnl gethostbyname without lib or in the nsl lib?
289 AC_CHECK_FUNC(gethostbyname,
290               [HAVE_GETHOSTBYNAME="1"
291               ],
292               [ AC_CHECK_LIB(nsl, gethostbyname,
293                              [HAVE_GETHOSTBYNAME="1"
294                              LIBS="$LIBS -lnsl"
295                              ])
296               ])
297
298 if test "$HAVE_GETHOSTBYNAME" != "1"
299 then
300   dnl gethostbyname in the socket lib?
301   AC_CHECK_LIB(socket, gethostbyname,
302                [HAVE_GETHOSTBYNAME="1"
303                LIBS="$LIBS -lsocket"
304                ])
305 fi
306
307 dnl At least one system has been identified to require BOTH nsl and socket
308 dnl libs at the same time to link properly.
309 if test "$HAVE_GETHOSTBYNAME" != "1"
310 then
311   AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
312   my_ac_save_LIBS=$LIBS
313   LIBS="-lnsl -lsocket $LIBS"
314   AC_LINK_IFELSE([
315     AC_LANG_PROGRAM([[
316     ]],[[
317       gethostbyname();
318     ]])
319   ],[
320     AC_MSG_RESULT([yes])
321     HAVE_GETHOSTBYNAME="1"
322   ],[
323     AC_MSG_RESULT([no])
324     LIBS=$my_ac_save_LIBS
325   ])
326 fi
327
328 if test "$HAVE_GETHOSTBYNAME" != "1"
329 then
330   dnl This is for winsock systems
331   if test "$ac_cv_header_windows_h" = "yes"; then
332     if test "$ac_cv_header_winsock_h" = "yes"; then
333       case $host in
334         *-*-mingw32ce*)
335           winsock_LIB="-lwinsock"
336           ;;
337         *)
338           winsock_LIB="-lwsock32"
339           ;;
340       esac
341     fi
342     if test "$ac_cv_header_winsock2_h" = "yes"; then
343       winsock_LIB="-lws2_32"
344     fi
345     if test ! -z "$winsock_LIB"; then
346       my_ac_save_LIBS=$LIBS
347       LIBS="$winsock_LIB $LIBS"
348       AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
349       AC_LINK_IFELSE([
350         AC_LANG_PROGRAM([[
351 #ifdef HAVE_WINDOWS_H
352 #ifndef WIN32_LEAN_AND_MEAN
353 #define WIN32_LEAN_AND_MEAN
354 #endif
355 #include <windows.h>
356 #ifdef HAVE_WINSOCK2_H
357 #include <winsock2.h>
358 #else
359 #ifdef HAVE_WINSOCK_H
360 #include <winsock.h>
361 #endif
362 #endif
363 #endif
364         ]],[[
365           gethostbyname("www.dummysite.com");
366         ]])
367       ],[
368         AC_MSG_RESULT([yes])
369         HAVE_GETHOSTBYNAME="1"
370       ],[
371         AC_MSG_RESULT([no])
372         winsock_LIB=""
373         LIBS=$my_ac_save_LIBS
374       ])
375     fi
376   fi
377 fi
378
379 if test "$HAVE_GETHOSTBYNAME" != "1"
380 then
381   dnl This is for Minix 3.1
382   AC_MSG_CHECKING([for gethostbyname for Minix 3])
383   AC_LINK_IFELSE([
384     AC_LANG_PROGRAM([[
385 /* Older Minix versions may need <net/gen/netdb.h> here instead */
386 #include <netdb.h>
387     ]],[[
388       gethostbyname("www.dummysite.com");
389     ]])
390   ],[
391     AC_MSG_RESULT([yes])
392     HAVE_GETHOSTBYNAME="1"
393   ],[
394     AC_MSG_RESULT([no])
395   ])
396 fi
397
398 if test "$HAVE_GETHOSTBYNAME" != "1"
399 then
400   dnl This is for eCos with a stubbed DNS implementation
401   AC_MSG_CHECKING([for gethostbyname for eCos])
402   AC_LINK_IFELSE([
403     AC_LANG_PROGRAM([[
404 #include <stdio.h>
405 #include <netdb.h>
406     ]],[[
407       gethostbyname("www.dummysite.com");
408     ]])
409   ],[
410     AC_MSG_RESULT([yes])
411     HAVE_GETHOSTBYNAME="1"
412   ],[
413     AC_MSG_RESULT([no])
414   ])
415 fi
416
417 if test "$HAVE_GETHOSTBYNAME" != "1"
418 then
419   dnl gethostbyname in the net lib - for BeOS
420   AC_CHECK_LIB(net, gethostbyname,
421                [HAVE_GETHOSTBYNAME="1"
422                LIBS="$LIBS -lnet"
423                ])
424 fi
425
426
427 if test "$HAVE_GETHOSTBYNAME" = "1"; then
428   AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
429 else
430   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
431 fi
432
433 dnl resolve lib?
434 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
435
436 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
437   AC_CHECK_LIB(resolve, strcasecmp,
438               [LIBS="-lresolve $LIBS"],
439                ,
440                -lnsl)
441 fi
442
443 dnl socket lib?
444 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
445
446 dnl **********************************************************************
447 dnl In case that function clock_gettime with monotonic timer is available,
448 dnl check for additional required libraries.
449 dnl **********************************************************************
450 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
451
452 AC_MSG_CHECKING([whether to use libgcc])
453 AC_ARG_ENABLE(libgcc,
454 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
455 [ case "$enableval" in
456   yes)
457         LIBS="$LIBS -lgcc"
458        AC_MSG_RESULT(yes)
459        ;;
460   *)   AC_MSG_RESULT(no)
461        ;;
462   esac ],
463        AC_MSG_RESULT(no)
464 )
465
466
467 dnl Default is to try the thread-safe versions of a few functions
468 OPT_THREAD=on
469
470 dnl detect AIX 4.3 or later
471 AC_MSG_CHECKING([AIX 4.3 or later])
472 AC_PREPROC_IFELSE([
473 #if defined(_AIX) && defined(_AIX43)
474 printf("just fine");
475 #else
476 #error "this is not AIX 4.3 or later"
477 #endif
478 ],
479  [ AC_MSG_RESULT([yes])
480    RECENTAIX=yes
481    OPT_THREAD=off ],
482  [ AC_MSG_RESULT([no]) ]
483 )
484
485 AC_ARG_ENABLE(thread,dnl
486 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
487 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
488 [ case "$enableval" in
489   no)
490     OPT_THREAD=off
491     AC_MSG_WARN(c-ares will not get built using thread-safe functions)
492     ;;
493   *)
494     ;;
495   esac
496 ]
497 )
498
499 if test X"$OPT_THREAD" = Xoff
500 then
501   AC_DEFINE(DISABLED_THREADSAFE, 1,
502     [Set to explicitly specify we don't want to use thread-safe functions])
503 fi
504
505 dnl for recent AIX versions, we skip all the thread-safe checks above since
506 dnl they claim a thread-safe libc using the standard API. But there are
507 dnl some functions still not thread-safe. Check for these!
508
509 dnl Let's hope this split URL remains working:
510 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
511 dnl genprogc/thread_quick_ref.htm
512
513 if test "x$RECENTAIX" = "xyes"; then
514
515   AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
516
517 fi
518
519
520 dnl **********************************************************************
521 dnl Back to "normal" configuring
522 dnl **********************************************************************
523
524 dnl Checks for header files.
525 AC_HEADER_STDC
526
527 CURL_CHECK_HEADER_MALLOC
528
529 dnl check for a few basic system headers we need
530 AC_CHECK_HEADERS(
531        sys/types.h \
532        sys/time.h \
533        sys/select.h \
534        sys/socket.h \
535        sys/ioctl.h \
536        sys/param.h \
537        netdb.h \
538        netinet/in.h \
539        netinet/tcp.h \
540        net/if.h \
541        errno.h \
542        strings.h \
543        stdbool.h \
544        time.h \
545        arpa/nameser.h \
546        arpa/nameser_compat.h \
547        arpa/inet.h,
548 dnl to do if not found
549 [],
550 dnl to do if found
551 [],
552 dnl default includes
553 [
554 #ifdef HAVE_SYS_TYPES_H
555 #include <sys/types.h>
556 #endif
557 #ifdef HAVE_SYS_TIME_H
558 #include <sys/time.h>
559 #endif
560 dnl We do this default-include simply to make sure that the nameser_compat.h
561 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
562 dnl (and others?) is not designed to allow this.
563 #ifdef HAVE_ARPA_NAMESER_H
564 #include <arpa/nameser.h>
565 #endif
566
567 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
568 #ifdef HAVE_SYS_SOCKET_H
569 #include <sys/socket.h>
570 #endif
571 #ifdef HAVE_NETINET_IN_H
572 #include <netinet/in.h>
573 #endif
574 ]
575 )
576
577 dnl Checks for typedefs, structures, and compiler characteristics.
578 AC_C_CONST
579 AC_TYPE_SIZE_T
580 AC_HEADER_TIME
581 CURL_CHECK_STRUCT_TIMEVAL
582
583 AC_CHECK_SIZEOF(size_t)
584 AC_CHECK_SIZEOF(long)
585 AC_CHECK_SIZEOF(time_t)
586
587 AC_CHECK_TYPE(long long,
588    [AC_DEFINE(HAVE_LONGLONG, 1, [if your compiler supports long long])]
589    longlong="yes"  
590 )
591
592 if test "xyes" = "x$longlong"; then
593   AC_MSG_CHECKING([if numberLL works])
594   AC_COMPILE_IFELSE([long long val = 1000LL;],
595    [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
596    AC_MSG_RESULT(yes),
597    AC_MSG_RESULT(no)
598   )
599 fi
600
601
602 # check for ssize_t
603 AC_CHECK_TYPE(ssize_t, ,
604    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
605
606 # check for bool type
607 AC_CHECK_TYPE([bool],[
608   AC_DEFINE(HAVE_BOOL_T, 1,
609     [Define to 1 if bool is an available type.])
610 ], ,[
611 #ifdef HAVE_SYS_TYPES_H
612 #include <sys/types.h>
613 #endif
614 #ifdef HAVE_STDBOOL_H
615 #include <stdbool.h>
616 #endif
617 ])
618
619 # Check for socklen_t or equivalent
620 CURL_CHECK_TYPE_SOCKLEN_T
621
622 TYPE_IN_ADDR_T
623
624 TYPE_SOCKADDR_STORAGE
625
626 TYPE_SIG_ATOMIC_T
627
628 AC_TYPE_SIGNAL
629
630 CURL_CHECK_FUNC_RECV
631 CURL_CHECK_FUNC_RECVFROM
632 CURL_CHECK_FUNC_SEND
633 CURL_CHECK_MSG_NOSIGNAL
634
635 dnl check for AF_INET6
636 CARES_CHECK_CONSTANT(
637   [
638 #undef inline
639 #ifdef HAVE_WINDOWS_H
640 #ifndef WIN32_LEAN_AND_MEAN
641 #define WIN32_LEAN_AND_MEAN
642 #endif
643 #include <windows.h>
644 #ifdef HAVE_WINSOCK2_H
645 #include <winsock2.h>
646 #endif
647 #else
648 #ifdef HAVE_SYS_TYPES_H
649 #include <sys/types.h>
650 #endif
651 #ifdef HAVE_SYS_SOCKET_H
652 #include <sys/socket.h>
653 #endif
654 #endif
655   ], [PF_INET6], 
656      AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
657 )
658
659 dnl check for PF_INET6
660 CARES_CHECK_CONSTANT(
661   [
662 #undef inline
663 #ifdef HAVE_WINDOWS_H
664 #ifndef WIN32_LEAN_AND_MEAN
665 #define WIN32_LEAN_AND_MEAN
666 #endif
667 #include <windows.h>
668 #ifdef HAVE_WINSOCK2_H
669 #include <winsock2.h>
670 #endif
671 #else
672 #ifdef HAVE_SYS_TYPES_H
673 #include <sys/types.h>
674 #endif
675 #ifdef HAVE_SYS_SOCKET_H
676 #include <sys/socket.h>
677 #endif
678 #endif
679   ], [AF_INET6], 
680      AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
681 )
682
683
684 dnl check for the in6_addr structure
685 CARES_CHECK_STRUCT(
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 #endif
707   ], [in6_addr], 
708      AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
709 )
710
711 dnl check for the sockaddr_in6 structure
712 CARES_CHECK_STRUCT(
713   [
714 #undef inline
715 #ifdef HAVE_WINDOWS_H
716 #ifndef WIN32_LEAN_AND_MEAN
717 #define WIN32_LEAN_AND_MEAN
718 #endif
719 #include <windows.h>
720 #ifdef HAVE_WINSOCK2_H
721 #include <winsock2.h>
722 #ifdef HAVE_WS2TCPIP_H
723 #include <ws2tcpip.h>
724 #endif
725 #endif
726 #else
727 #ifdef HAVE_SYS_TYPES_H
728 #include <sys/types.h>
729 #endif
730 #ifdef HAVE_NETINET_IN_H
731 #include <netinet/in.h>
732 #endif
733 #endif
734   ], [sockaddr_in6], 
735      AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
736        [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
737 )
738
739 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
740     AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
741       [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
742    , ,
743   [
744 #undef inline
745 #ifdef HAVE_WINDOWS_H
746 #ifndef WIN32_LEAN_AND_MEAN
747 #define WIN32_LEAN_AND_MEAN
748 #endif
749 #include <windows.h>
750 #ifdef HAVE_WINSOCK2_H
751 #include <winsock2.h>
752 #ifdef HAVE_WS2TCPIP_H
753 #include <ws2tcpip.h>
754 #endif
755 #endif
756 #else
757 #ifdef HAVE_SYS_TYPES_H
758 #include <sys/types.h>
759 #endif
760 #ifdef HAVE_NETINET_IN_H
761 #include <netinet/in.h>
762 #endif
763 #endif
764   ])
765
766 dnl check for the addrinfo structure
767 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
768      AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
769        [Define to 1 if you have struct addrinfo.]),,
770   [
771 #undef inline
772 #ifdef HAVE_WINDOWS_H
773 #ifndef WIN32_LEAN_AND_MEAN
774 #define WIN32_LEAN_AND_MEAN
775 #endif
776 #include <windows.h>
777 #ifdef HAVE_WINSOCK2_H
778 #include <winsock2.h>
779 #ifdef HAVE_WS2TCPIP_H
780 #include <ws2tcpip.h>
781 #endif
782 #endif
783 #else
784 #ifdef HAVE_SYS_TYPES_H
785 #include <sys/types.h>
786 #endif
787 #ifdef HAVE_NETINET_IN_H
788 #include <netinet/in.h>
789 #endif
790 #ifdef HAVE_SYS_SOCKET_H
791 #include <sys/socket.h>
792 #endif
793 #ifdef HAVE_NETDB_H
794 #include <netdb.h>
795 #endif
796 #endif
797   ]
798 )
799
800
801 AC_CHECK_FUNCS( bitncmp \
802                 gettimeofday \
803                 if_indextoname,
804 dnl if found
805 [],
806 dnl if not found, $ac_func is the name we check for
807 func="$ac_func"
808 AC_MSG_CHECKING([deeper for $func])
809 AC_TRY_LINK( [],
810              [ $func ();],
811              AC_MSG_RESULT(yes!)
812              eval "ac_cv_func_$func=yes"
813              def=`echo "HAVE_$func" | tr 'a-z' 'A-Z'`
814              AC_DEFINE_UNQUOTED($def, 1, [If you have $func]),
815              AC_MSG_RESULT(but still no)
816              )
817 )
818
819
820 dnl check for inet_pton
821 AC_CHECK_FUNCS(inet_pton)
822 dnl Some systems have it, but not IPv6
823 if test "$ac_cv_func_inet_pton" = "yes" ; then
824 AC_MSG_CHECKING(if inet_pton supports IPv6)
825 AC_TRY_RUN(
826   [
827 #ifdef HAVE_SYS_TYPES_H
828 #include <sys/types.h>
829 #endif
830 #ifdef HAVE_SYS_SOCKET_H
831 #include <sys/socket.h>
832 #endif
833 #ifdef HAVE_NETINET_IN_H
834 #include <netinet/in.h>
835 #endif
836 int main()
837   {
838     struct in6_addr addr6;
839     if (inet_pton(AF_INET6, "::1", &addr6) < 1)
840       exit(1);
841     else
842       exit(0);
843   }
844   ], [
845        AC_MSG_RESULT(yes)
846        AC_DEFINE_UNQUOTED(HAVE_INET_PTON_IPV6,1,[Define to 1 if inet_pton supports IPv6.])
847      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
848 fi
849 dnl Check for inet_net_pton
850 AC_CHECK_FUNCS(inet_net_pton)
851 dnl Again, some systems have it, but not IPv6
852 if test "$ac_cv_func_inet_net_pton" = "yes" ; then
853 AC_MSG_CHECKING(if inet_net_pton supports IPv6)
854 AC_TRY_RUN(
855   [
856 #ifdef HAVE_SYS_TYPES_H
857 #include <sys/types.h>
858 #endif
859 #ifdef HAVE_SYS_SOCKET_H
860 #include <sys/socket.h>
861 #endif
862 #ifdef HAVE_NETINET_IN_H
863 #include <netinet/in.h>
864 #endif
865 int main()
866   {
867     struct in6_addr addr6;
868     if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
869       exit(1);
870     else
871       exit(0);
872   }
873   ], [
874        AC_MSG_RESULT(yes)
875        AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
876      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
877 fi
878
879
880 dnl Check for inet_ntop
881 AC_CHECK_FUNCS(inet_ntop)
882 dnl Again, some systems have it, but not IPv6
883 if test "$ac_cv_func_inet_ntop" = "yes" ; then
884 AC_MSG_CHECKING(if inet_ntop supports IPv6)
885 AC_TRY_RUN(
886   [
887 #ifdef HAVE_SYS_TYPES_H
888 #include <sys/types.h>
889 #endif
890 #ifdef HAVE_SYS_SOCKET_H
891 #include <sys/socket.h>
892 #endif
893 #ifdef HAVE_NETINET_IN_H
894 #include <netinet/in.h>
895 #endif
896 #include <errno.h>
897 int main()
898   {
899     struct in6_addr addr6;
900     char buf[128];
901     if (inet_ntop(AF_INET6, &addr6, buf, 128) == 0 && errno == EAFNOSUPPORT)
902       exit(1);
903     else
904       exit(0);
905   }
906   ], [
907        AC_MSG_RESULT(yes)
908        AC_DEFINE_UNQUOTED(HAVE_INET_NTOP_IPV6,1,
909           [Define to 1 if inet_ntop supports IPv6.])
910      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
911 fi
912
913 AC_CHECK_SIZEOF(struct in6_addr, ,
914 [
915 #undef inline
916 #ifdef HAVE_WINDOWS_H
917 #ifndef WIN32_LEAN_AND_MEAN
918 #define WIN32_LEAN_AND_MEAN
919 #endif
920 #include <windows.h>
921 #ifdef HAVE_WINSOCK2_H
922 #include <winsock2.h>
923 #ifdef HAVE_WS2TCPIP_H
924 #include <ws2tcpip.h>
925 #endif
926 #endif
927 #else
928 #ifdef HAVE_SYS_TYPES_H
929 #include <sys/types.h>
930 #endif
931 #ifdef HAVE_SYS_SOCKET_H
932 #include <sys/socket.h>
933 #endif
934 #ifdef HAVE_NETINET_IN_H
935 #include <netinet/in.h>
936 #endif
937 #endif
938 ]
939 )
940
941 AC_CHECK_SIZEOF(struct in_addr, ,
942 [
943 #undef inline
944 #ifdef HAVE_WINDOWS_H
945 #ifndef WIN32_LEAN_AND_MEAN
946 #define WIN32_LEAN_AND_MEAN
947 #endif
948 #include <windows.h>
949 #ifdef HAVE_WINSOCK2_H
950 #include <winsock2.h>
951 #ifdef HAVE_WS2TCPIP_H
952 #include <ws2tcpip.h>
953 #endif
954 #endif
955 #else
956 #ifdef HAVE_SYS_TYPES_H
957 #include <sys/types.h>
958 #endif
959 #ifdef HAVE_SYS_SOCKET_H
960 #include <sys/socket.h>
961 #endif
962 #ifdef HAVE_NETINET_IN_H
963 #include <netinet/in.h>
964 #endif
965 #endif
966 ]
967 )
968
969
970 dnl Check if the getnameinfo function is available
971 dnl and get the types of five of its arguments.
972 CURL_CHECK_FUNC_GETNAMEINFO
973
974
975 dnl God bless non-standardized functions! We need to see which getservbyport_r
976 dnl variant is available
977 CARES_CHECK_GETSERVBYPORT_R
978
979 CURL_CHECK_NONBLOCKING_SOCKET
980
981 AC_C_BIGENDIAN(
982     [AC_DEFINE(ARES_BIG_ENDIAN, 1,
983       [define this if ares is built for a big endian system])],
984     ,
985     [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
986 )
987
988 dnl Check for user-specified random device
989 AC_ARG_WITH(random,
990 AC_HELP_STRING([--with-random=FILE],
991                [read randomness from FILE (default=/dev/urandom)]),
992     [ RANDOM_FILE="$withval" ],
993     [
994         dnl Check for random device.  If we're cross compiling, we can't
995         dnl check, and it's better to assume it doesn't exist than it is
996         dnl to fail on AC_CHECK_FILE or later.
997         if test "$cross_compiling" = "no"; then
998           AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
999         else
1000           AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
1001         fi
1002         
1003     ]
1004 )
1005 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
1006         AC_SUBST(RANDOM_FILE)
1007         AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
1008         [a suitable file/device to read random data from])
1009 fi
1010
1011 CARES_PRIVATE_LIBS="$LIBS"
1012 AC_SUBST(CARES_PRIVATE_LIBS)
1013
1014 AC_CONFIG_FILES([Makefile libcares.pc])
1015 AC_OUTPUT