Use CFLAGS for icc linker options instead of LDFLAGS,
[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 platform/compiler/architecture specific checks/flags
172 dnl **********************************************************************
173
174 ac_cv_compiler="unknown"
175 ac_cv_compiler_num="unknown"
176
177 AC_MSG_CHECKING([whether we are using the IBM C compiler])
178 CURL_CHECK_DEF([__IBMC__], [], [silent])
179 if test "$curl_cv_have_def___IBMC__" = "yes"; then
180   AC_MSG_RESULT([yes])
181   ac_cv_compiler="IBMC"
182   dnl Ensure that compiler optimizations are always thread-safe.
183   CFLAGS="$CFLAGS -qthreaded"
184   dnl Disable type based strict aliasing optimizations, using worst
185   dnl case aliasing assumptions when compiling. Type based aliasing
186   dnl would restrict the lvalues that could be safely used to access
187   dnl a data object.
188   CFLAGS="$CFLAGS -qnoansialias"
189   dnl Force compiler to stop after the compilation phase, without
190   dnl generating an object code file when compilation has errors.
191   CFLAGS="$CFLAGS -qhalt=e"
192 else
193   AC_MSG_RESULT([no])
194 fi
195
196 AC_MSG_CHECKING([whether we are using the Intel C compiler])
197 CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
198 if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
199   AC_MSG_RESULT([yes])
200   ac_cv_compiler="ICC"
201   AC_MSG_CHECKING([compiler version])
202   ac_cv_compiler_num="$curl_cv_def___INTEL_COMPILER"
203   AC_MSG_RESULT([$ac_cv_compiler_num])
204   dnl On unix this compiler uses gcc's header files, so
205   dnl we select ANSI C89 dialect plus GNU extensions.
206   CPPFLAGS="$CPPFLAGS -std=gnu89"
207   if test "$ac_cv_compiler_num" -gt "600"; then
208     dnl Show errors, warnings, and remarks
209     CPPFLAGS="$CPPFLAGS -Wall"
210     dnl Perform extra compile-time code checking
211     CPPFLAGS="$CPPFLAGS -Wcheck"
212   fi
213   dnl Change some warnings into errors
214   dnl #140: too many arguments in function call
215   dnl #147: declaration is incompatible with 'previous one'
216   dnl #165: too few arguments in function call
217   dnl #266: function declared implicitly
218   CPPFLAGS="$CPPFLAGS -we 140,147,165,266"
219   dnl Disable some remarks
220   dnl #279: controlling expression is constant
221   dnl #981: operands are evaluated in unspecified order
222   dnl #1469: "cc" clobber ignored
223   if test "$ac_cv_compiler_num" -lt "910"; then
224     CPPFLAGS="$CPPFLAGS -wd 279"
225   fi
226   CPPFLAGS="$CPPFLAGS -wd 981,1469"
227   dnl Disable use of ANSI C aliasing rules in optimizations
228   CFLAGS="$CFLAGS -no-ansi-alias"
229   dnl Disable floating point optimizations
230   CFLAGS="$CFLAGS -fp-model precise -mp"
231 else
232   AC_MSG_RESULT([no])
233 fi
234
235 AC_MSG_CHECKING([whether we are using the DEC/Compaq C compiler])
236 CURL_CHECK_DEF([__DECC], [], [silent])
237 CURL_CHECK_DEF([__DECC_VER], [], [silent])
238 if test "$curl_cv_have_def___DECC" = "yes" &&
239   test "$curl_cv_have_def___DECC_VER" = "yes"; then
240   AC_MSG_RESULT([yes])
241   ac_cv_compiler="DECC"
242   dnl Select strict ANSI C compiler mode
243   CFLAGS="$CFLAGS -std1"
244   dnl Turn off optimizer ANSI C aliasing rules
245   CFLAGS="$CFLAGS -noansi_alias"
246   dnl Select a higher warning level than default level2
247   CFLAGS="$CFLAGS -msg_enable level3"
248   dnl Generate warnings for missing function prototypes
249   CFLAGS="$CFLAGS -warnprotos"
250   dnl Change some warnings into fatal errors
251   CFLAGS="$CFLAGS -msg_fatal toofewargs,toomanyargs"
252 else
253   AC_MSG_RESULT([no])
254 fi
255
256 AC_MSG_CHECKING([whether we are using the GNU C compiler])
257 CURL_CHECK_DEF([__GNUC__], [], [silent])
258 if test "$curl_cv_have_def___GNUC__" = "yes" &&
259   test "$ac_cv_compiler" = "unknown"; then
260   AC_MSG_RESULT([yes])
261   ac_cv_compiler="GNUC"
262   AC_MSG_CHECKING([compiler version])
263   gccver=`$CC -dumpversion`
264   gccvhi=`echo $gccver | cut -d . -f1`
265   gccvlo=`echo $gccver | cut -d . -f2`
266   gccnum=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
267   ac_cv_compiler_num="$gccnum"
268   AC_MSG_RESULT([$ac_cv_compiler_num])
269 else
270   AC_MSG_RESULT([no])
271 fi
272
273 case $host in
274   #
275   x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
276     #
277     if test "$ac_cv_compiler" = "ICC"; then
278       #
279       if test "$ac_cv_compiler_num" -ge "900" &&
280         test "$ac_cv_compiler_num" -lt "1000"; then
281         dnl icc 9.X specific
282         CFLAGS="$CFLAGS -i-dynamic"
283       fi
284       #
285       if test "$ac_cv_compiler_num" -ge "1000"; then
286         dnl icc 10.X or later
287         CFLAGS="$CFLAGS -shared-intel"
288       fi
289       #
290     fi
291     ;;
292   #
293 esac
294
295 CURL_CHECK_COMPILER_HALT_ON_ERROR
296 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
297
298 dnl **********************************************************************
299 dnl Compilation based checks should not be done before this point.
300 dnl **********************************************************************
301
302 dnl **********************************************************************
303 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h 
304 dnl and ws2tcpip.h take precedence over any other further checks which 
305 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
306 dnl this specific header files. And do them before its results are used.
307 dnl **********************************************************************
308
309 CURL_CHECK_HEADER_WINDOWS
310 CURL_CHECK_NATIVE_WINDOWS
311 case X-"$ac_cv_native_windows" in
312   X-yes)
313     CURL_CHECK_HEADER_WINSOCK
314     CURL_CHECK_HEADER_WINSOCK2
315     CURL_CHECK_HEADER_WS2TCPIP
316     ;;
317   *)
318     ac_cv_header_winsock_h="no"
319     ac_cv_header_winsock2_h="no"
320     ac_cv_header_ws2tcpip_h="no"
321     ;;
322 esac
323
324 dnl **********************************************************************
325 dnl Checks for libraries.
326 dnl **********************************************************************
327
328 dnl gethostbyname without lib or in the nsl lib?
329 AC_CHECK_FUNC(gethostbyname,
330               [HAVE_GETHOSTBYNAME="1"
331               ],
332               [ AC_CHECK_LIB(nsl, gethostbyname,
333                              [HAVE_GETHOSTBYNAME="1"
334                              LIBS="$LIBS -lnsl"
335                              ])
336               ])
337
338 if test "$HAVE_GETHOSTBYNAME" != "1"
339 then
340   dnl gethostbyname in the socket lib?
341   AC_CHECK_LIB(socket, gethostbyname,
342                [HAVE_GETHOSTBYNAME="1"
343                LIBS="$LIBS -lsocket"
344                ])
345 fi
346
347 dnl At least one system has been identified to require BOTH nsl and socket
348 dnl libs at the same time to link properly.
349 if test "$HAVE_GETHOSTBYNAME" != "1"
350 then
351   AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
352   my_ac_save_LIBS=$LIBS
353   LIBS="-lnsl -lsocket $LIBS"
354   AC_LINK_IFELSE([
355     AC_LANG_PROGRAM([[
356     ]],[[
357       gethostbyname();
358     ]])
359   ],[
360     AC_MSG_RESULT([yes])
361     HAVE_GETHOSTBYNAME="1"
362   ],[
363     AC_MSG_RESULT([no])
364     LIBS=$my_ac_save_LIBS
365   ])
366 fi
367
368 if test "$HAVE_GETHOSTBYNAME" != "1"
369 then
370   dnl This is for winsock systems
371   if test "$ac_cv_header_windows_h" = "yes"; then
372     if test "$ac_cv_header_winsock_h" = "yes"; then
373       case $host in
374         *-*-mingw32ce*)
375           winsock_LIB="-lwinsock"
376           ;;
377         *)
378           winsock_LIB="-lwsock32"
379           ;;
380       esac
381     fi
382     if test "$ac_cv_header_winsock2_h" = "yes"; then
383       winsock_LIB="-lws2_32"
384     fi
385     if test ! -z "$winsock_LIB"; then
386       my_ac_save_LIBS=$LIBS
387       LIBS="$winsock_LIB $LIBS"
388       AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
389       AC_LINK_IFELSE([
390         AC_LANG_PROGRAM([[
391 #ifdef HAVE_WINDOWS_H
392 #ifndef WIN32_LEAN_AND_MEAN
393 #define WIN32_LEAN_AND_MEAN
394 #endif
395 #include <windows.h>
396 #ifdef HAVE_WINSOCK2_H
397 #include <winsock2.h>
398 #else
399 #ifdef HAVE_WINSOCK_H
400 #include <winsock.h>
401 #endif
402 #endif
403 #endif
404         ]],[[
405           gethostbyname("www.dummysite.com");
406         ]])
407       ],[
408         AC_MSG_RESULT([yes])
409         HAVE_GETHOSTBYNAME="1"
410       ],[
411         AC_MSG_RESULT([no])
412         winsock_LIB=""
413         LIBS=$my_ac_save_LIBS
414       ])
415     fi
416   fi
417 fi
418
419 if test "$HAVE_GETHOSTBYNAME" != "1"
420 then
421   dnl This is for Minix 3.1
422   AC_MSG_CHECKING([for gethostbyname for Minix 3])
423   AC_LINK_IFELSE([
424     AC_LANG_PROGRAM([[
425 /* Older Minix versions may need <net/gen/netdb.h> here instead */
426 #include <netdb.h>
427     ]],[[
428       gethostbyname("www.dummysite.com");
429     ]])
430   ],[
431     AC_MSG_RESULT([yes])
432     HAVE_GETHOSTBYNAME="1"
433   ],[
434     AC_MSG_RESULT([no])
435   ])
436 fi
437
438 if test "$HAVE_GETHOSTBYNAME" != "1"
439 then
440   dnl This is for eCos with a stubbed DNS implementation
441   AC_MSG_CHECKING([for gethostbyname for eCos])
442   AC_LINK_IFELSE([
443     AC_LANG_PROGRAM([[
444 #include <stdio.h>
445 #include <netdb.h>
446     ]],[[
447       gethostbyname("www.dummysite.com");
448     ]])
449   ],[
450     AC_MSG_RESULT([yes])
451     HAVE_GETHOSTBYNAME="1"
452   ],[
453     AC_MSG_RESULT([no])
454   ])
455 fi
456
457 if test "$HAVE_GETHOSTBYNAME" != "1"
458 then
459   dnl gethostbyname in the net lib - for BeOS
460   AC_CHECK_LIB(net, gethostbyname,
461                [HAVE_GETHOSTBYNAME="1"
462                LIBS="$LIBS -lnet"
463                ])
464 fi
465
466
467 if test "$HAVE_GETHOSTBYNAME" = "1"; then
468   AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
469 else
470   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
471 fi
472
473 dnl resolve lib?
474 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
475
476 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
477   AC_CHECK_LIB(resolve, strcasecmp,
478               [LIBS="-lresolve $LIBS"],
479                ,
480                -lnsl)
481 fi
482 ac_cv_func_strcasecmp="no"
483
484 dnl socket lib?
485 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
486
487 dnl **********************************************************************
488 dnl In case that function clock_gettime with monotonic timer is available,
489 dnl check for additional required libraries.
490 dnl **********************************************************************
491 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
492
493 AC_MSG_CHECKING([whether to use libgcc])
494 AC_ARG_ENABLE(libgcc,
495 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
496 [ case "$enableval" in
497   yes)
498         LIBS="$LIBS -lgcc"
499        AC_MSG_RESULT(yes)
500        ;;
501   *)   AC_MSG_RESULT(no)
502        ;;
503   esac ],
504        AC_MSG_RESULT(no)
505 )
506
507
508 dnl Default is to try the thread-safe versions of a few functions
509 OPT_THREAD=on
510
511 dnl detect AIX 4.3 or later
512 AC_MSG_CHECKING([AIX 4.3 or later])
513 AC_PREPROC_IFELSE([
514 #if defined(_AIX) && defined(_AIX43)
515 printf("just fine");
516 #else
517 #error "this is not AIX 4.3 or later"
518 #endif
519 ],
520  [ AC_MSG_RESULT([yes])
521    RECENTAIX=yes
522    OPT_THREAD=off ],
523  [ AC_MSG_RESULT([no]) ]
524 )
525
526 AC_ARG_ENABLE(thread,dnl
527 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
528 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
529 [ case "$enableval" in
530   no)
531     OPT_THREAD=off
532     AC_MSG_WARN(c-ares will not get built using thread-safe functions)
533     ;;
534   *)
535     ;;
536   esac
537 ]
538 )
539
540 if test X"$OPT_THREAD" = Xoff
541 then
542   AC_DEFINE(DISABLED_THREADSAFE, 1,
543     [Set to explicitly specify we don't want to use thread-safe functions])
544 fi
545
546 dnl for recent AIX versions, we skip all the thread-safe checks above since
547 dnl they claim a thread-safe libc using the standard API. But there are
548 dnl some functions still not thread-safe. Check for these!
549
550 dnl Let's hope this split URL remains working:
551 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
552 dnl genprogc/thread_quick_ref.htm
553
554 if test "x$RECENTAIX" = "xyes"; then
555
556   AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
557
558 fi
559
560
561 dnl **********************************************************************
562 dnl Back to "normal" configuring
563 dnl **********************************************************************
564
565 dnl Checks for header files.
566 AC_HEADER_STDC
567
568 CURL_CHECK_HEADER_MALLOC
569
570 dnl check for a few basic system headers we need
571 AC_CHECK_HEADERS(
572        sys/types.h \
573        sys/time.h \
574        sys/select.h \
575        sys/socket.h \
576        sys/ioctl.h \
577        sys/param.h \
578        sys/uio.h \
579        netdb.h \
580        netinet/in.h \
581        netinet/tcp.h \
582        net/if.h \
583        errno.h \
584        strings.h \
585        stdbool.h \
586        time.h \
587        arpa/nameser.h \
588        arpa/nameser_compat.h \
589        arpa/inet.h,
590 dnl to do if not found
591 [],
592 dnl to do if found
593 [],
594 dnl default includes
595 [
596 #ifdef HAVE_SYS_TYPES_H
597 #include <sys/types.h>
598 #endif
599 #ifdef HAVE_SYS_TIME_H
600 #include <sys/time.h>
601 #endif
602 dnl We do this default-include simply to make sure that the nameser_compat.h
603 dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
604 dnl (and others?) is not designed to allow this.
605 #ifdef HAVE_ARPA_NAMESER_H
606 #include <arpa/nameser.h>
607 #endif
608
609 dnl *Sigh* these are needed in order for net/if.h to get properly detected.
610 #ifdef HAVE_SYS_SOCKET_H
611 #include <sys/socket.h>
612 #endif
613 #ifdef HAVE_NETINET_IN_H
614 #include <netinet/in.h>
615 #endif
616 ]
617 )
618
619 dnl Checks for typedefs, structures, and compiler characteristics.
620 AC_C_CONST
621 AC_TYPE_SIZE_T
622 AC_HEADER_TIME
623 CURL_CHECK_STRUCT_TIMEVAL
624
625 AC_CHECK_SIZEOF(size_t)
626 AC_CHECK_SIZEOF(long)
627 AC_CHECK_SIZEOF(time_t)
628
629 AC_CHECK_TYPE(long long,
630    [AC_DEFINE(HAVE_LONGLONG, 1,
631      [Define to 1 if the compiler supports the 'long long' data type.])]
632    longlong="yes"  
633 )
634
635 if test "xyes" = "x$longlong"; then
636   AC_MSG_CHECKING([if numberLL works])
637   AC_COMPILE_IFELSE([long long val = 1000LL;],
638    [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
639    AC_MSG_RESULT(yes),
640    AC_MSG_RESULT(no)
641   )
642 fi
643
644
645 # check for ssize_t
646 AC_CHECK_TYPE(ssize_t, ,
647    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
648
649 # check for bool type
650 AC_CHECK_TYPE([bool],[
651   AC_DEFINE(HAVE_BOOL_T, 1,
652     [Define to 1 if bool is an available type.])
653 ], ,[
654 #ifdef HAVE_SYS_TYPES_H
655 #include <sys/types.h>
656 #endif
657 #ifdef HAVE_STDBOOL_H
658 #include <stdbool.h>
659 #endif
660 ])
661
662 # Check for socklen_t or equivalent
663 CURL_CHECK_TYPE_SOCKLEN_T
664
665 TYPE_IN_ADDR_T
666
667 TYPE_SOCKADDR_STORAGE
668
669 TYPE_SIG_ATOMIC_T
670
671 AC_TYPE_SIGNAL
672
673 CURL_CHECK_FUNC_RECV
674 CURL_CHECK_FUNC_RECVFROM
675 CURL_CHECK_FUNC_SEND
676 CURL_CHECK_MSG_NOSIGNAL
677
678 CARES_CHECK_FUNC_GETHOSTNAME
679 CARES_CHECK_FUNC_GETSERVBYPORT_R
680 CARES_CHECK_FUNC_INET_NTOP
681 CARES_CHECK_FUNC_INET_PTON
682 CARES_CHECK_FUNC_STRCASECMP
683 CARES_CHECK_FUNC_STRCMPI
684 CARES_CHECK_FUNC_STRDUP
685 CARES_CHECK_FUNC_STRICMP
686 CARES_CHECK_FUNC_STRNCASECMP
687 CARES_CHECK_FUNC_STRNCMPI
688 CARES_CHECK_FUNC_STRNICMP
689 CARES_CHECK_FUNC_WRITEV
690
691
692 dnl check for AF_INET6
693 CARES_CHECK_CONSTANT(
694   [
695 #undef inline
696 #ifdef HAVE_WINDOWS_H
697 #ifndef WIN32_LEAN_AND_MEAN
698 #define WIN32_LEAN_AND_MEAN
699 #endif
700 #include <windows.h>
701 #ifdef HAVE_WINSOCK2_H
702 #include <winsock2.h>
703 #endif
704 #else
705 #ifdef HAVE_SYS_TYPES_H
706 #include <sys/types.h>
707 #endif
708 #ifdef HAVE_SYS_SOCKET_H
709 #include <sys/socket.h>
710 #endif
711 #endif
712   ], [PF_INET6], 
713      AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
714 )
715
716 dnl check for PF_INET6
717 CARES_CHECK_CONSTANT(
718   [
719 #undef inline
720 #ifdef HAVE_WINDOWS_H
721 #ifndef WIN32_LEAN_AND_MEAN
722 #define WIN32_LEAN_AND_MEAN
723 #endif
724 #include <windows.h>
725 #ifdef HAVE_WINSOCK2_H
726 #include <winsock2.h>
727 #endif
728 #else
729 #ifdef HAVE_SYS_TYPES_H
730 #include <sys/types.h>
731 #endif
732 #ifdef HAVE_SYS_SOCKET_H
733 #include <sys/socket.h>
734 #endif
735 #endif
736   ], [AF_INET6], 
737      AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
738 )
739
740
741 dnl check for the in6_addr structure
742 CARES_CHECK_STRUCT(
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   ], [in6_addr], 
765      AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
766 )
767
768 dnl check for the sockaddr_in6 structure
769 CARES_CHECK_STRUCT(
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 #endif
791   ], [sockaddr_in6], 
792      AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
793        [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
794 )
795
796 AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
797     AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
798       [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
799    , ,
800   [
801 #undef inline
802 #ifdef HAVE_WINDOWS_H
803 #ifndef WIN32_LEAN_AND_MEAN
804 #define WIN32_LEAN_AND_MEAN
805 #endif
806 #include <windows.h>
807 #ifdef HAVE_WINSOCK2_H
808 #include <winsock2.h>
809 #ifdef HAVE_WS2TCPIP_H
810 #include <ws2tcpip.h>
811 #endif
812 #endif
813 #else
814 #ifdef HAVE_SYS_TYPES_H
815 #include <sys/types.h>
816 #endif
817 #ifdef HAVE_NETINET_IN_H
818 #include <netinet/in.h>
819 #endif
820 #endif
821   ])
822
823 dnl check for the addrinfo structure
824 AC_CHECK_MEMBER(struct addrinfo.ai_flags,
825      AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
826        [Define to 1 if you have struct addrinfo.]),,
827   [
828 #undef inline
829 #ifdef HAVE_WINDOWS_H
830 #ifndef WIN32_LEAN_AND_MEAN
831 #define WIN32_LEAN_AND_MEAN
832 #endif
833 #include <windows.h>
834 #ifdef HAVE_WINSOCK2_H
835 #include <winsock2.h>
836 #ifdef HAVE_WS2TCPIP_H
837 #include <ws2tcpip.h>
838 #endif
839 #endif
840 #else
841 #ifdef HAVE_SYS_TYPES_H
842 #include <sys/types.h>
843 #endif
844 #ifdef HAVE_NETINET_IN_H
845 #include <netinet/in.h>
846 #endif
847 #ifdef HAVE_SYS_SOCKET_H
848 #include <sys/socket.h>
849 #endif
850 #ifdef HAVE_NETDB_H
851 #include <netdb.h>
852 #endif
853 #endif
854   ]
855 )
856
857
858 AC_CHECK_FUNCS([bitncmp \
859   gettimeofday \
860   if_indextoname
861 ],[
862 ],[
863   func="$ac_func"
864   AC_MSG_CHECKING([deeper for $func])
865   AC_LINK_IFELSE([
866     AC_LANG_PROGRAM([[
867     ]],[[
868       $func ();
869     ]])
870   ],[
871     AC_MSG_RESULT([yes])
872     eval "ac_cv_func_$func=yes"
873     AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$func])], [1],
874       [Define to 1 if you have the $func function.])
875   ],[
876     AC_MSG_RESULT([but still no])
877   ])
878 ])
879
880
881 dnl Check for inet_net_pton
882 AC_CHECK_FUNCS(inet_net_pton)
883 dnl Again, some systems have it, but not IPv6
884 if test "$ac_cv_func_inet_net_pton" = "yes" ; then
885 AC_MSG_CHECKING(if inet_net_pton supports IPv6)
886 AC_TRY_RUN(
887   [
888 #ifdef HAVE_SYS_TYPES_H
889 #include <sys/types.h>
890 #endif
891 #ifdef HAVE_SYS_SOCKET_H
892 #include <sys/socket.h>
893 #endif
894 #ifdef HAVE_NETINET_IN_H
895 #include <netinet/in.h>
896 #endif
897 int main()
898   {
899     struct in6_addr addr6;
900     if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
901       exit(1);
902     else
903       exit(0);
904   }
905   ], [
906        AC_MSG_RESULT(yes)
907        AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
908      ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
909 fi
910
911
912 AC_CHECK_SIZEOF(struct in6_addr, ,
913 [
914 #undef inline
915 #ifdef HAVE_WINDOWS_H
916 #ifndef WIN32_LEAN_AND_MEAN
917 #define WIN32_LEAN_AND_MEAN
918 #endif
919 #include <windows.h>
920 #ifdef HAVE_WINSOCK2_H
921 #include <winsock2.h>
922 #ifdef HAVE_WS2TCPIP_H
923 #include <ws2tcpip.h>
924 #endif
925 #endif
926 #else
927 #ifdef HAVE_SYS_TYPES_H
928 #include <sys/types.h>
929 #endif
930 #ifdef HAVE_SYS_SOCKET_H
931 #include <sys/socket.h>
932 #endif
933 #ifdef HAVE_NETINET_IN_H
934 #include <netinet/in.h>
935 #endif
936 #endif
937 ]
938 )
939
940 AC_CHECK_SIZEOF(struct in_addr, ,
941 [
942 #undef inline
943 #ifdef HAVE_WINDOWS_H
944 #ifndef WIN32_LEAN_AND_MEAN
945 #define WIN32_LEAN_AND_MEAN
946 #endif
947 #include <windows.h>
948 #ifdef HAVE_WINSOCK2_H
949 #include <winsock2.h>
950 #ifdef HAVE_WS2TCPIP_H
951 #include <ws2tcpip.h>
952 #endif
953 #endif
954 #else
955 #ifdef HAVE_SYS_TYPES_H
956 #include <sys/types.h>
957 #endif
958 #ifdef HAVE_SYS_SOCKET_H
959 #include <sys/socket.h>
960 #endif
961 #ifdef HAVE_NETINET_IN_H
962 #include <netinet/in.h>
963 #endif
964 #endif
965 ]
966 )
967
968
969 dnl Check if the getnameinfo function is available
970 dnl and get the types of five of its arguments.
971 CURL_CHECK_FUNC_GETNAMEINFO
972
973
974 CURL_CHECK_NONBLOCKING_SOCKET
975
976 AC_C_BIGENDIAN(
977     [AC_DEFINE(ARES_BIG_ENDIAN, 1,
978       [define this if ares is built for a big endian system])],
979     ,
980     [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
981 )
982
983 dnl Check for user-specified random device
984 AC_ARG_WITH(random,
985 AC_HELP_STRING([--with-random=FILE],
986                [read randomness from FILE (default=/dev/urandom)]),
987     [ RANDOM_FILE="$withval" ],
988     [
989         dnl Check for random device.  If we're cross compiling, we can't
990         dnl check, and it's better to assume it doesn't exist than it is
991         dnl to fail on AC_CHECK_FILE or later.
992         if test "$cross_compiling" = "no"; then
993           AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
994         else
995           AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
996         fi
997         
998     ]
999 )
1000 if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
1001         AC_SUBST(RANDOM_FILE)
1002         AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
1003         [a suitable file/device to read random data from])
1004 fi
1005
1006 CARES_PRIVATE_LIBS="$LIBS"
1007 AC_SUBST(CARES_PRIVATE_LIBS)
1008
1009 AC_CONFIG_FILES([Makefile libcares.pc])
1010 AC_OUTPUT