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