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