Adjust DEC/Compaq C compiler settings
[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 check for how to do large files
79 AC_SYS_LARGEFILE
80
81 case $host_os in
82   solaris*)
83     AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
84     ;;
85 esac
86
87 dnl support building of Windows DLLs
88 AC_LIBTOOL_WIN32_DLL
89
90 dnl ************************************************************
91 dnl Option to switch on debug options. This makes an assumption that
92 dnl this is built as an 'ares' subdir in the curl source tree. Subject for
93 dnl improval in the future!
94 dnl
95 AC_MSG_CHECKING([whether to enable debug options])
96 AC_ARG_ENABLE(debug,
97 AC_HELP_STRING([--enable-debug],[Enable pedantic debug options])
98 AC_HELP_STRING([--disable-debug],[Disable debug options]),
99 [ case "$enableval" in
100   no)
101        AC_MSG_RESULT(no)
102        ;;
103   *)   AC_MSG_RESULT(yes)
104
105     dnl when doing the debug stuff, use static library only
106     AC_DISABLE_SHARED
107
108     debugbuild="yes"
109
110     dnl the entire --enable-debug is a hack that lives and runs on top of
111     dnl libcurl stuff so this BUILDING_LIBCURL is not THAT much uglier
112     AC_DEFINE(BUILDING_LIBCURL, 1, [when building as static part of libcurl])
113
114     CPPFLAGS="$CPPFLAGS -DCURLDEBUG -I$srcdir/../include"
115     CFLAGS="$CFLAGS -g" 
116
117     dnl set compiler "debug" options to become more picky, and remove
118     dnl optimize options from CFLAGS
119     CURL_CC_DEBUG_OPTS
120
121        ;;
122   esac ],
123        AC_MSG_RESULT(no)
124 )
125 AM_CONDITIONAL(DEBUGBUILD, 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 Select a higher warning level than default level2
243   CFLAGS="$CFLAGS -msg_enable level3"
244   dnl Generate warnings for missing function prototypes
245   CFLAGS="$CFLAGS -warnprotos"
246   dnl Change some warnings into fatal errors
247   CFLAGS="$CFLAGS -msg_fatal toofewargs,toomanyargs"
248 else
249   AC_MSG_RESULT([no])
250 fi
251
252 CURL_CHECK_COMPILER_HALT_ON_ERROR
253 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
254
255 dnl **********************************************************************
256 dnl Compilation based checks should not be done before this point.
257 dnl **********************************************************************
258
259 dnl **********************************************************************
260 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h 
261 dnl and ws2tcpip.h take precedence over any other further checks which 
262 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
263 dnl this specific header files. And do them before its results are used.
264 dnl **********************************************************************
265
266 CURL_CHECK_HEADER_WINDOWS
267 CURL_CHECK_NATIVE_WINDOWS
268 case X-"$ac_cv_native_windows" in
269   X-yes)
270     CURL_CHECK_HEADER_WINSOCK
271     CURL_CHECK_HEADER_WINSOCK2
272     CURL_CHECK_HEADER_WS2TCPIP
273     ;;
274   *)
275     ac_cv_header_winsock_h="no"
276     ac_cv_header_winsock2_h="no"
277     ac_cv_header_ws2tcpip_h="no"
278     ;;
279 esac
280
281 dnl **********************************************************************
282 dnl Checks for libraries.
283 dnl **********************************************************************
284
285 dnl gethostbyname without lib or in the nsl lib?
286 AC_CHECK_FUNC(gethostbyname,
287               [HAVE_GETHOSTBYNAME="1"
288               ],
289               [ AC_CHECK_LIB(nsl, gethostbyname,
290                              [HAVE_GETHOSTBYNAME="1"
291                              LIBS="$LIBS -lnsl"
292                              ])
293               ])
294
295 if test "$HAVE_GETHOSTBYNAME" != "1"
296 then
297   dnl gethostbyname in the socket lib?
298   AC_CHECK_LIB(socket, gethostbyname,
299                [HAVE_GETHOSTBYNAME="1"
300                LIBS="$LIBS -lsocket"
301                ])
302 fi
303
304 dnl At least one system has been identified to require BOTH nsl and socket
305 dnl libs at the same time to link properly.
306 if test "$HAVE_GETHOSTBYNAME" != "1"
307 then
308   AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
309   my_ac_save_LIBS=$LIBS
310   LIBS="-lnsl -lsocket $LIBS"
311   AC_LINK_IFELSE([
312     AC_LANG_PROGRAM([[
313     ]],[[
314       gethostbyname();
315     ]])
316   ],[
317     AC_MSG_RESULT([yes])
318     HAVE_GETHOSTBYNAME="1"
319   ],[
320     AC_MSG_RESULT([no])
321     LIBS=$my_ac_save_LIBS
322   ])
323 fi
324
325 if test "$HAVE_GETHOSTBYNAME" != "1"
326 then
327   dnl This is for winsock systems
328   if test "$ac_cv_header_windows_h" = "yes"; then
329     if test "$ac_cv_header_winsock_h" = "yes"; then
330       case $host in
331         *-*-mingw32ce*)
332           winsock_LIB="-lwinsock"
333           ;;
334         *)
335           winsock_LIB="-lwsock32"
336           ;;
337       esac
338     fi
339     if test "$ac_cv_header_winsock2_h" = "yes"; then
340       winsock_LIB="-lws2_32"
341     fi
342     if test ! -z "$winsock_LIB"; then
343       my_ac_save_LIBS=$LIBS
344       LIBS="$winsock_LIB $LIBS"
345       AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
346       AC_LINK_IFELSE([
347         AC_LANG_PROGRAM([[
348 #ifdef HAVE_WINDOWS_H
349 #ifndef WIN32_LEAN_AND_MEAN
350 #define WIN32_LEAN_AND_MEAN
351 #endif
352 #include <windows.h>
353 #ifdef HAVE_WINSOCK2_H
354 #include <winsock2.h>
355 #else
356 #ifdef HAVE_WINSOCK_H
357 #include <winsock.h>
358 #endif
359 #endif
360 #endif
361         ]],[[
362           gethostbyname("www.dummysite.com");
363         ]])
364       ],[
365         AC_MSG_RESULT([yes])
366         HAVE_GETHOSTBYNAME="1"
367       ],[
368         AC_MSG_RESULT([no])
369         winsock_LIB=""
370         LIBS=$my_ac_save_LIBS
371       ])
372     fi
373   fi
374 fi
375
376 if test "$HAVE_GETHOSTBYNAME" != "1"
377 then
378   dnl This is for Minix 3.1
379   AC_MSG_CHECKING([for gethostbyname for Minix 3])
380   AC_LINK_IFELSE([
381     AC_LANG_PROGRAM([[
382 /* Older Minix versions may need <net/gen/netdb.h> here instead */
383 #include <netdb.h>
384     ]],[[
385       gethostbyname("www.dummysite.com");
386     ]])
387   ],[
388     AC_MSG_RESULT([yes])
389     HAVE_GETHOSTBYNAME="1"
390   ],[
391     AC_MSG_RESULT([no])
392   ])
393 fi
394
395 if test "$HAVE_GETHOSTBYNAME" != "1"
396 then
397   dnl This is for eCos with a stubbed DNS implementation
398   AC_MSG_CHECKING([for gethostbyname for eCos])
399   AC_LINK_IFELSE([
400     AC_LANG_PROGRAM([[
401 #include <stdio.h>
402 #include <netdb.h>
403     ]],[[
404       gethostbyname("www.dummysite.com");
405     ]])
406   ],[
407     AC_MSG_RESULT([yes])
408     HAVE_GETHOSTBYNAME="1"
409   ],[
410     AC_MSG_RESULT([no])
411   ])
412 fi
413
414 if test "$HAVE_GETHOSTBYNAME" != "1"
415 then
416   dnl gethostbyname in the net lib - for BeOS
417   AC_CHECK_LIB(net, gethostbyname,
418                [HAVE_GETHOSTBYNAME="1"
419                LIBS="$LIBS -lnet"
420                ])
421 fi
422
423
424 if test "$HAVE_GETHOSTBYNAME" = "1"; then
425   AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
426 else
427   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
428 fi
429
430 dnl resolve lib?
431 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
432
433 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
434   AC_CHECK_LIB(resolve, strcasecmp,
435               [LIBS="-lresolve $LIBS"],
436                ,
437                -lnsl)
438 fi
439
440 dnl socket lib?
441 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
442
443 dnl **********************************************************************
444 dnl In case that function clock_gettime with monotonic timer is available,
445 dnl check for additional required libraries.
446 dnl **********************************************************************
447 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
448
449 AC_MSG_CHECKING([whether to use libgcc])
450 AC_ARG_ENABLE(libgcc,
451 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
452 [ case "$enableval" in
453   yes)
454         LIBS="$LIBS -lgcc"
455        AC_MSG_RESULT(yes)
456        ;;
457   *)   AC_MSG_RESULT(no)
458        ;;
459   esac ],
460        AC_MSG_RESULT(no)
461 )
462
463
464 dnl Default is to try the thread-safe versions of a few functions
465 OPT_THREAD=on
466
467 dnl detect AIX 4.3 or later
468 AC_MSG_CHECKING([AIX 4.3 or later])
469 AC_PREPROC_IFELSE([
470 #if defined(_AIX) && defined(_AIX43)
471 printf("just fine");
472 #else
473 #error "this is not AIX 4.3 or later"
474 #endif
475 ],
476  [ AC_MSG_RESULT([yes])
477    RECENTAIX=yes
478    OPT_THREAD=off ],
479  [ AC_MSG_RESULT([no]) ]
480 )
481
482 AC_ARG_ENABLE(thread,dnl
483 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
484 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
485 [ case "$enableval" in
486   no)
487     OPT_THREAD=off
488     AC_MSG_WARN(c-ares will not get built using thread-safe functions)
489     ;;
490   *)
491     ;;
492   esac
493 ]
494 )
495
496 if test X"$OPT_THREAD" = Xoff
497 then
498   AC_DEFINE(DISABLED_THREADSAFE, 1,
499     [Set to explicitly specify we don't want to use thread-safe functions])
500 fi
501
502 dnl for recent AIX versions, we skip all the thread-safe checks above since
503 dnl they claim a thread-safe libc using the standard API. But there are
504 dnl some functions still not thread-safe. Check for these!
505
506 dnl Let's hope this split URL remains working:
507 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
508 dnl genprogc/thread_quick_ref.htm
509
510 if test "x$RECENTAIX" = "xyes"; then
511
512   AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
513
514 fi
515
516
517 dnl **********************************************************************
518 dnl Back to "normal" configuring
519 dnl **********************************************************************
520
521 dnl Checks for header files.
522 AC_HEADER_STDC
523
524 CURL_CHECK_HEADER_MALLOC
525
526 dnl check for a few basic system headers we need
527 AC_CHECK_HEADERS(
528        sys/types.h \
529        sys/time.h \
530        sys/select.h \
531        sys/socket.h \
532        sys/ioctl.h \
533        sys/param.h \
534        netdb.h \
535        netinet/in.h \
536        netinet/tcp.h \
537        net/if.h \
538        errno.h \
539        strings.h \
540        stdbool.h \
541        time.h \
542        arpa/nameser.h \
543        arpa/nameser_compat.h \
544        arpa/inet.h,
545 dnl to do if not found
546 [],
547 dnl to do if found
548 [],
549 dnl default includes
550 [
551 #ifdef HAVE_SYS_TYPES_H
552 #include <sys/types.h>
553 #endif
554 #ifdef HAVE_SYS_TIME_H
555 #include <sys/time.h>
556 #endif
557 dnl We do this default-include simply to make sure that the nameser_compat.h
558 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
559 dnl (and others?) is not designed to allow this.
560 #ifdef HAVE_ARPA_NAMESER_H
561 #include <arpa/nameser.h>
562 #endif
563
564 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
565 #ifdef HAVE_SYS_SOCKET_H
566 #include <sys/socket.h>
567 #endif
568 #ifdef HAVE_NETINET_IN_H
569 #include <netinet/in.h>
570 #endif
571 ]
572 )
573
574 dnl Checks for typedefs, structures, and compiler characteristics.
575 AC_C_CONST
576 AC_TYPE_SIZE_T
577 AC_HEADER_TIME
578 CURL_CHECK_STRUCT_TIMEVAL
579
580 AC_CHECK_SIZEOF(size_t)
581 AC_CHECK_SIZEOF(long)
582 AC_CHECK_SIZEOF(time_t)
583
584 AC_CHECK_TYPE(long long,
585    [AC_DEFINE(HAVE_LONGLONG, 1, [if your compiler supports long long])]
586    longlong="yes"  
587 )
588
589 if test "xyes" = "x$longlong"; then
590   AC_MSG_CHECKING([if numberLL works])
591   AC_COMPILE_IFELSE([long long val = 1000LL;],
592    [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
593    AC_MSG_RESULT(yes),
594    AC_MSG_RESULT(no)
595   )
596 fi
597
598
599 # check for ssize_t
600 AC_CHECK_TYPE(ssize_t, ,
601    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
602
603 # check for bool type
604 AC_CHECK_TYPE([bool],[
605   AC_DEFINE(HAVE_BOOL_T, 1,
606     [Define to 1 if bool is an available type.])
607 ], ,[
608 #ifdef HAVE_SYS_TYPES_H
609 #include <sys/types.h>
610 #endif
611 #ifdef HAVE_STDBOOL_H
612 #include <stdbool.h>
613 #endif
614 ])
615
616 # Check for socklen_t or equivalent
617 CURL_CHECK_TYPE_SOCKLEN_T
618
619 TYPE_IN_ADDR_T
620
621 TYPE_SOCKADDR_STORAGE
622
623 TYPE_SIG_ATOMIC_T
624
625 AC_TYPE_SIGNAL
626
627 CURL_CHECK_FUNC_RECV
628 CURL_CHECK_FUNC_RECVFROM
629 CURL_CHECK_FUNC_SEND
630 CURL_CHECK_MSG_NOSIGNAL
631
632 dnl check for AF_INET6
633 CARES_CHECK_CONSTANT(
634   [
635 #undef inline
636 #ifdef HAVE_WINDOWS_H
637 #ifndef WIN32_LEAN_AND_MEAN
638 #define WIN32_LEAN_AND_MEAN
639 #endif
640 #include <windows.h>
641 #ifdef HAVE_WINSOCK2_H
642 #include <winsock2.h>
643 #endif
644 #else
645 #ifdef HAVE_SYS_TYPES_H
646 #include <sys/types.h>
647 #endif
648 #ifdef HAVE_SYS_SOCKET_H
649 #include <sys/socket.h>
650 #endif
651 #endif
652   ], [PF_INET6], 
653      AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
654 )
655
656 dnl check for PF_INET6
657 CARES_CHECK_CONSTANT(
658   [
659 #undef inline
660 #ifdef HAVE_WINDOWS_H
661 #ifndef WIN32_LEAN_AND_MEAN
662 #define WIN32_LEAN_AND_MEAN
663 #endif
664 #include <windows.h>
665 #ifdef HAVE_WINSOCK2_H
666 #include <winsock2.h>
667 #endif
668 #else
669 #ifdef HAVE_SYS_TYPES_H
670 #include <sys/types.h>
671 #endif
672 #ifdef HAVE_SYS_SOCKET_H
673 #include <sys/socket.h>
674 #endif
675 #endif
676   ], [AF_INET6], 
677      AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
678 )
679
680
681 dnl check for the in6_addr structure
682 CARES_CHECK_STRUCT(
683   [
684 #undef inline
685 #ifdef HAVE_WINDOWS_H
686 #ifndef WIN32_LEAN_AND_MEAN
687 #define WIN32_LEAN_AND_MEAN
688 #endif
689 #include <windows.h>
690 #ifdef HAVE_WINSOCK2_H
691 #include <winsock2.h>
692 #ifdef HAVE_WS2TCPIP_H
693 #include <ws2tcpip.h>
694 #endif
695 #endif
696 #else
697 #ifdef HAVE_SYS_TYPES_H
698 #include <sys/types.h>
699 #endif
700 #ifdef HAVE_NETINET_IN_H
701 #include <netinet/in.h>
702 #endif
703 #endif
704   ], [in6_addr], 
705      AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
706 )
707
708 dnl check for the sockaddr_in6 structure
709 CARES_CHECK_STRUCT(
710   [
711 #undef inline
712 #ifdef HAVE_WINDOWS_H
713 #ifndef WIN32_LEAN_AND_MEAN
714 #define WIN32_LEAN_AND_MEAN
715 #endif
716 #include <windows.h>
717 #ifdef HAVE_WINSOCK2_H
718 #include <winsock2.h>
719 #ifdef HAVE_WS2TCPIP_H
720 #include <ws2tcpip.h>
721 #endif
722 #endif
723 #else
724 #ifdef HAVE_SYS_TYPES_H
725 #include <sys/types.h>
726 #endif
727 #ifdef HAVE_NETINET_IN_H
728 #include <netinet/in.h>
729 #endif
730 #endif
731   ], [sockaddr_in6], 
732      AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
733        [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
734 )
735
736 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
737     AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
738       [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
739    , ,
740   [
741 #undef inline
742 #ifdef HAVE_WINDOWS_H
743 #ifndef WIN32_LEAN_AND_MEAN
744 #define WIN32_LEAN_AND_MEAN
745 #endif
746 #include <windows.h>
747 #ifdef HAVE_WINSOCK2_H
748 #include <winsock2.h>
749 #ifdef HAVE_WS2TCPIP_H
750 #include <ws2tcpip.h>
751 #endif
752 #endif
753 #else
754 #ifdef HAVE_SYS_TYPES_H
755 #include <sys/types.h>
756 #endif
757 #ifdef HAVE_NETINET_IN_H
758 #include <netinet/in.h>
759 #endif
760 #endif
761   ])
762
763 dnl check for the addrinfo structure
764 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
765      AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
766        [Define to 1 if you have struct addrinfo.]),,
767   [
768 #undef inline
769 #ifdef HAVE_WINDOWS_H
770 #ifndef WIN32_LEAN_AND_MEAN
771 #define WIN32_LEAN_AND_MEAN
772 #endif
773 #include <windows.h>
774 #ifdef HAVE_WINSOCK2_H
775 #include <winsock2.h>
776 #ifdef HAVE_WS2TCPIP_H
777 #include <ws2tcpip.h>
778 #endif
779 #endif
780 #else
781 #ifdef HAVE_SYS_TYPES_H
782 #include <sys/types.h>
783 #endif
784 #ifdef HAVE_NETINET_IN_H
785 #include <netinet/in.h>
786 #endif
787 #ifdef HAVE_SYS_SOCKET_H
788 #include <sys/socket.h>
789 #endif
790 #ifdef HAVE_NETDB_H
791 #include <netdb.h>
792 #endif
793 #endif
794   ]
795 )
796
797
798 AC_CHECK_FUNCS( bitncmp \
799                 gettimeofday \
800                 if_indextoname,
801 dnl if found
802 [],
803 dnl if not found, $ac_func is the name we check for
804 func="$ac_func"
805 AC_MSG_CHECKING([deeper for $func])
806 AC_TRY_LINK( [],
807              [ $func ();],
808              AC_MSG_RESULT(yes!)
809              eval "ac_cv_func_$func=yes"
810              def=`echo "HAVE_$func" | tr 'a-z' 'A-Z'`
811              AC_DEFINE_UNQUOTED($def, 1, [If you have $func]),
812              AC_MSG_RESULT(but still no)
813              )
814 )
815
816
817 dnl check for inet_pton
818 AC_CHECK_FUNCS(inet_pton)
819 dnl Some systems have it, but not IPv6
820 if test "$ac_cv_func_inet_pton" = "yes" ; then
821 AC_MSG_CHECKING(if inet_pton supports IPv6)
822 AC_TRY_RUN(
823   [
824 #ifdef HAVE_SYS_TYPES_H
825 #include <sys/types.h>
826 #endif
827 #ifdef HAVE_SYS_SOCKET_H
828 #include <sys/socket.h>
829 #endif
830 #ifdef HAVE_NETINET_IN_H
831 #include <netinet/in.h>
832 #endif
833 int main()
834   {
835     struct in6_addr addr6;
836     if (inet_pton(AF_INET6, "::1", &addr6) < 1)
837       exit(1);
838     else
839       exit(0);
840   }
841   ], [
842        AC_MSG_RESULT(yes)
843        AC_DEFINE_UNQUOTED(HAVE_INET_PTON_IPV6,1,[Define to 1 if inet_pton supports IPv6.])
844      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
845 fi
846 dnl Check for inet_net_pton
847 AC_CHECK_FUNCS(inet_net_pton)
848 dnl Again, some systems have it, but not IPv6
849 if test "$ac_cv_func_inet_net_pton" = "yes" ; then
850 AC_MSG_CHECKING(if inet_net_pton supports IPv6)
851 AC_TRY_RUN(
852   [
853 #ifdef HAVE_SYS_TYPES_H
854 #include <sys/types.h>
855 #endif
856 #ifdef HAVE_SYS_SOCKET_H
857 #include <sys/socket.h>
858 #endif
859 #ifdef HAVE_NETINET_IN_H
860 #include <netinet/in.h>
861 #endif
862 int main()
863   {
864     struct in6_addr addr6;
865     if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
866       exit(1);
867     else
868       exit(0);
869   }
870   ], [
871        AC_MSG_RESULT(yes)
872        AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
873      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
874 fi
875
876
877 dnl Check for inet_ntop
878 AC_CHECK_FUNCS(inet_ntop)
879 dnl Again, some systems have it, but not IPv6
880 if test "$ac_cv_func_inet_ntop" = "yes" ; then
881 AC_MSG_CHECKING(if inet_ntop supports IPv6)
882 AC_TRY_RUN(
883   [
884 #ifdef HAVE_SYS_TYPES_H
885 #include <sys/types.h>
886 #endif
887 #ifdef HAVE_SYS_SOCKET_H
888 #include <sys/socket.h>
889 #endif
890 #ifdef HAVE_NETINET_IN_H
891 #include <netinet/in.h>
892 #endif
893 #include <errno.h>
894 int main()
895   {
896     struct in6_addr addr6;
897     char buf[128];
898     if (inet_ntop(AF_INET6, &addr6, buf, 128) == 0 && errno == EAFNOSUPPORT)
899       exit(1);
900     else
901       exit(0);
902   }
903   ], [
904        AC_MSG_RESULT(yes)
905        AC_DEFINE_UNQUOTED(HAVE_INET_NTOP_IPV6,1,
906           [Define to 1 if inet_ntop supports IPv6.])
907      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
908 fi
909
910 AC_CHECK_SIZEOF(struct in6_addr, ,
911 [
912 #undef inline
913 #ifdef HAVE_WINDOWS_H
914 #ifndef WIN32_LEAN_AND_MEAN
915 #define WIN32_LEAN_AND_MEAN
916 #endif
917 #include <windows.h>
918 #ifdef HAVE_WINSOCK2_H
919 #include <winsock2.h>
920 #ifdef HAVE_WS2TCPIP_H
921 #include <ws2tcpip.h>
922 #endif
923 #endif
924 #else
925 #ifdef HAVE_SYS_TYPES_H
926 #include <sys/types.h>
927 #endif
928 #ifdef HAVE_SYS_SOCKET_H
929 #include <sys/socket.h>
930 #endif
931 #ifdef HAVE_NETINET_IN_H
932 #include <netinet/in.h>
933 #endif
934 #endif
935 ]
936 )
937
938 AC_CHECK_SIZEOF(struct in_addr, ,
939 [
940 #undef inline
941 #ifdef HAVE_WINDOWS_H
942 #ifndef WIN32_LEAN_AND_MEAN
943 #define WIN32_LEAN_AND_MEAN
944 #endif
945 #include <windows.h>
946 #ifdef HAVE_WINSOCK2_H
947 #include <winsock2.h>
948 #ifdef HAVE_WS2TCPIP_H
949 #include <ws2tcpip.h>
950 #endif
951 #endif
952 #else
953 #ifdef HAVE_SYS_TYPES_H
954 #include <sys/types.h>
955 #endif
956 #ifdef HAVE_SYS_SOCKET_H
957 #include <sys/socket.h>
958 #endif
959 #ifdef HAVE_NETINET_IN_H
960 #include <netinet/in.h>
961 #endif
962 #endif
963 ]
964 )
965
966
967 dnl Check if the getnameinfo function is available
968 dnl and get the types of five of its arguments.
969 CURL_CHECK_FUNC_GETNAMEINFO
970
971
972 dnl God bless non-standardized functions! We need to see which getservbyport_r
973 dnl variant is available
974 CARES_CHECK_GETSERVBYPORT_R
975
976 CURL_CHECK_NONBLOCKING_SOCKET
977
978 AC_C_BIGENDIAN(
979     [AC_DEFINE(ARES_BIG_ENDIAN, 1,
980       [define this if ares is built for a big endian system])],
981     ,
982     [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
983 )
984
985 dnl Check for user-specified random device
986 AC_ARG_WITH(random,
987 AC_HELP_STRING([--with-random=FILE],
988                [read randomness from FILE (default=/dev/urandom)]),
989     [ RANDOM_FILE="$withval" ],
990     [
991         dnl Check for random device.  If we're cross compiling, we can't
992         dnl check, and it's better to assume it doesn't exist than it is
993         dnl to fail on AC_CHECK_FILE or later.
994         if test "$cross_compiling" = "no"; then
995           AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
996         else
997           AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
998         fi
999         
1000     ]
1001 )
1002 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
1003         AC_SUBST(RANDOM_FILE)
1004         AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
1005         [a suitable file/device to read random data from])
1006 fi
1007
1008 CARES_PRIVATE_LIBS="$LIBS"
1009 AC_SUBST(CARES_PRIVATE_LIBS)
1010
1011 AC_CONFIG_FILES([Makefile libcares.pc])
1012 AC_OUTPUT