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