b204653d919f6e98a045975611b8a4d320ab3ff5
[platform/upstream/curl.git] / configure.ac
1 dnl $Id$
2 dnl Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.57)
5
6 dnl We don't know the version number "staticly" so we use a dash here
7 AC_INIT(curl, [-], [a suitable curl mailing list => http://curl.haxx.se/mail/])
8
9 dnl configure script copyright
10 AC_COPYRIGHT([Copyright (c) 1998 - 2004 Daniel Stenberg, <daniel@haxx.se>
11 This configure script may be copied, distributed and modified under the 
12 terms of the curl license; see COPYING for more details])
13
14 AC_CONFIG_SRCDIR([lib/urldata.h])
15 AM_CONFIG_HEADER(lib/config.h src/config.h)
16 AM_MAINTAINER_MODE
17
18 dnl SED is needed by some of the tools
19 AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
20               $PATH:/usr/bin:/usr/local/bin)
21 AC_SUBST(SED)
22
23 if test "x$SED" = "xsed-was-not-found-by-configure"; then
24   AC_MSG_WARN([sed was not found, this may ruin your chances to build fine])
25 fi
26
27 dnl AR is used by libtool, and try the odd Solaris path too
28 dnl we use AC_CHECK_TOOL since this should make a library for the target
29 dnl platform
30 AC_CHECK_TOOL(AR, ar,
31               ar-was-not-found-by-configure,
32               $PATH:/usr/bin:/usr/local/bin:/usr/ccs/bin)
33 AC_SUBST(AR)
34 if test "x$AR" = "xar-was-not-found-by-configure"; then
35   AC_MSG_WARN([ar was not found, this may ruin your chances to build fine])
36 fi
37
38 dnl figure out the libcurl version
39 VERSION=`$SED -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curlver.h`
40 AM_INIT_AUTOMAKE(curl,$VERSION)
41 AC_MSG_CHECKING([curl version])
42 AC_MSG_RESULT($VERSION)
43
44 dnl
45 dnl we extract the numerical version for curl-config only
46 VERSIONNUM=`$SED -ne 's/^#define LIBCURL_VERSION_NUM 0x\(.*\)/\1/p' ${srcdir}/include/curl/curlver.h`
47 AC_SUBST(VERSIONNUM)
48
49 dnl Solaris pkgadd support definitions
50 PKGADD_PKG="HAXXcurl"
51 PKGADD_NAME="cURL - a client that groks URLs"
52 PKGADD_VENDOR="curl.haxx.se"
53 AC_SUBST(PKGADD_PKG)
54 AC_SUBST(PKGADD_NAME)
55 AC_SUBST(PKGADD_VENDOR)
56
57 dnl
58 dnl initialize all the info variables
59     curl_ssl_msg="no      (--with-ssl)"
60    curl_zlib_msg="no      (--with-zlib)"
61    curl_krb4_msg="no      (--with-krb4*)"
62     curl_gss_msg="no      (--with-gssapi)"
63  curl_spnego_msg="no      (--with-spnego)"
64    curl_ares_msg="no      (--enable-ares)"
65    curl_ipv6_msg="no      (--enable-ipv6)"
66     curl_idn_msg="no      (--with-libidn)"
67  curl_manual_msg="no      (--enable-manual)"
68 curl_verbose_msg="enabled (--disable-verbose)"
69
70 dnl
71 dnl Detect the canonical host and target build environment
72 dnl
73
74 AC_CANONICAL_HOST
75 dnl Get system canonical name
76 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
77
78 dnl Check for AIX weirdos
79 AC_AIX
80
81 dnl Checks for programs.
82 AC_PROG_CC
83
84 dnl check for how to do large files
85 AC_SYS_LARGEFILE
86
87 dnl check for cygwin stuff
88 AC_LIBTOOL_WIN32_DLL
89
90 dnl libtool setup
91 AC_PROG_LIBTOOL
92
93 AC_MSG_CHECKING([if we need -no-undefined])
94 case $host in
95   *-*-cygwin | *-*-mingw* | *-*-pw32*)
96     need_no_undefined=yes
97     ;;
98   *)
99     need_no_undefined=no
100     ;;
101 esac
102 AC_MSG_RESULT($need_no_undefined)
103 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
104
105 AC_MSG_CHECKING([if we need -mimpure-text])
106 mimpure=no
107 case $host in
108   *-*-solaris2*)
109     if test "$GCC" = "yes"; then
110       mimpure="yes"
111     fi
112     ;;
113   *)
114     ;;
115 esac
116 AC_MSG_RESULT($mimpure)
117 AM_CONDITIONAL(MIMPURE, test x$mimpure = xyes)
118
119 dnl The install stuff has already been taken care of by the automake stuff
120 dnl AC_PROG_INSTALL
121 AC_PROG_MAKE_SET
122
123 dnl ************************************************************
124 dnl switch off particular protocols
125 dnl
126 AC_MSG_CHECKING([whether to support http])
127 AC_ARG_ENABLE(http,
128 AC_HELP_STRING([--enable-http],[Enable HTTP support])
129 AC_HELP_STRING([--disable-http],[Disable HTTP support]),
130 [ case "$enableval" in
131   no)
132        AC_MSG_RESULT(no)
133        AC_DEFINE(CURL_DISABLE_HTTP, 1, [to disable HTTP])
134        AC_MSG_WARN([disable HTTP disables FTP over proxy and GOPHER too])
135        AC_DEFINE(CURL_DISABLE_GOPHER, 1, [to disable GOPHER])
136        AC_SUBST(CURL_DISABLE_HTTP)
137        AC_SUBST(CURL_DISABLE_GOPHER)
138        ;;
139   *)   AC_MSG_RESULT(yes)
140        ;;
141   esac ],
142        AC_MSG_RESULT(yes)
143 )
144 AC_MSG_CHECKING([whether to support ftp])
145 AC_ARG_ENABLE(ftp,
146 AC_HELP_STRING([--enable-ftp],[Enable FTP support])
147 AC_HELP_STRING([--disable-ftp],[Disable FTP support]),
148 [ case "$enableval" in
149   no)
150        AC_MSG_RESULT(no)
151        AC_DEFINE(CURL_DISABLE_FTP, 1, [to disable FTP])
152        AC_SUBST(CURL_DISABLE_FTP)
153        ;;
154   *)   AC_MSG_RESULT(yes)
155        ;;
156   esac ],
157        AC_MSG_RESULT(yes)
158 )
159 AC_MSG_CHECKING([whether to support gopher])
160 AC_ARG_ENABLE(gopher,
161 AC_HELP_STRING([--enable-gopher],[Enable GOPHER support])
162 AC_HELP_STRING([--disable-gopher],[Disable GOPHER support]),
163 [ case "$enableval" in
164   no)
165        AC_MSG_RESULT(no)
166        AC_DEFINE(CURL_DISABLE_GOPHER, 1, [to disable GOPHER])
167        AC_SUBST(CURL_DISABLE_GOPHER)
168        ;;
169   *)   AC_MSG_RESULT(yes)
170        ;;
171   esac ],
172        AC_MSG_RESULT(yes)
173 )
174 AC_MSG_CHECKING([whether to support file])
175 AC_ARG_ENABLE(file,
176 AC_HELP_STRING([--enable-file],[Enable FILE support])
177 AC_HELP_STRING([--disable-file],[Disable FILE support]),
178 [ case "$enableval" in
179   no)
180        AC_MSG_RESULT(no)
181        AC_DEFINE(CURL_DISABLE_FILE, 1, [to disable FILE])
182        AC_SUBST(CURL_DISABLE_FILE)
183        ;;
184   *)   AC_MSG_RESULT(yes)
185        ;;
186   esac ],
187        AC_MSG_RESULT(yes)
188 )
189 AC_MSG_CHECKING([whether to support ldap])
190 AC_ARG_ENABLE(ldap,
191 AC_HELP_STRING([--enable-ldap],[Enable LDAP support])
192 AC_HELP_STRING([--disable-ldap],[Disable LDAP support]),
193 [ case "$enableval" in
194   no)
195        AC_MSG_RESULT(no)
196        AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
197        AC_SUBST(CURL_DISABLE_LDAP)
198        ;;
199   *)   AC_MSG_RESULT(yes)
200        ;;
201   esac ],
202        AC_MSG_RESULT(yes)
203 )
204 AC_MSG_CHECKING([whether to support dict])
205 AC_ARG_ENABLE(dict,
206 AC_HELP_STRING([--enable-dict],[Enable DICT support])
207 AC_HELP_STRING([--disable-dict],[Disable DICT support]),
208 [ case "$enableval" in
209   no)
210        AC_MSG_RESULT(no)
211        AC_DEFINE(CURL_DISABLE_DICT, 1, [to disable DICT])
212        AC_SUBST(CURL_DISABLE_DICT)
213        ;;
214   *)   AC_MSG_RESULT(yes)
215        ;;
216   esac ],
217        AC_MSG_RESULT(yes)
218 )
219 AC_MSG_CHECKING([whether to support telnet])
220 AC_ARG_ENABLE(telnet,
221 AC_HELP_STRING([--enable-telnet],[Enable TELNET support])
222 AC_HELP_STRING([--disable-telnet],[Disable TELNET support]),
223 [ case "$enableval" in
224   no)
225        AC_MSG_RESULT(no)
226        AC_DEFINE(CURL_DISABLE_TELNET, 1, [to disable TELNET])
227        AC_SUBST(CURL_DISABLE_TELNET)
228        ;;
229   *)   AC_MSG_RESULT(yes)
230        ;;
231   esac ],
232        AC_MSG_RESULT(yes)
233 )
234
235 dnl **********************************************************************
236 dnl Check for built-in manual
237 dnl **********************************************************************
238
239 AC_MSG_CHECKING([whether to provide built-in manual])
240 AC_ARG_ENABLE(manual,
241 AC_HELP_STRING([--enable-manual],[Enable built-in manual])
242 AC_HELP_STRING([--disable-manual],[Disable built-in manual]),
243 [ case "$enableval" in
244   no)
245        AC_MSG_RESULT(no)
246        ;;
247   *)   AC_MSG_RESULT(yes)
248        USE_MANUAL="1"
249        ;;
250   esac ],
251        AC_MSG_RESULT(yes)
252        USE_MANUAL="1"
253 )
254 dnl The actual use of the USE_MANUAL variable is done much later in this
255 dnl script to allow other actions to disable it as well.
256
257
258 dnl **********************************************************************
259 dnl Checks for libraries.
260 dnl **********************************************************************
261
262 dnl gethostbyname without lib or in the nsl lib?
263 AC_CHECK_FUNC(gethostbyname,
264               [HAVE_GETHOSTBYNAME="1"
265               ],
266               [ AC_CHECK_LIB(nsl, gethostbyname,
267                              [HAVE_GETHOSTBYNAME="1"
268                              LIBS="$LIBS -lnsl"
269                              ])
270               ])
271
272 if test "$HAVE_GETHOSTBYNAME" != "1"
273 then
274   dnl gethostbyname in the socket lib?
275   AC_CHECK_LIB(socket, gethostbyname,
276                [HAVE_GETHOSTBYNAME="1"
277                LIBS="$LIBS -lsocket"
278                ])
279 fi
280
281 dnl At least one system has been identified to require BOTH nsl and socket
282 dnl libs at the same time to link properly.
283 if test "$HAVE_GETHOSTBYNAME" != "1"
284 then
285   AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
286   my_ac_save_LIBS=$LIBS
287   LIBS="-lnsl -lsocket $LIBS"
288   AC_TRY_LINK( ,
289              [gethostbyname();],
290              [ dnl found it!
291              HAVE_GETHOSTBYNAME="1"
292              AC_MSG_RESULT([yes])],
293              [ dnl failed!
294              AC_MSG_RESULT([no])
295              dnl restore LIBS
296              LIBS=$my_ac_save_LIBS]
297              )
298 fi
299
300 if test "$HAVE_GETHOSTBYNAME" != "1"
301 then
302   dnl This is for Msys/Mingw
303   AC_MSG_CHECKING([for gethostbyname in ws2_32])
304   my_ac_save_LIBS=$LIBS
305   LIBS="-lws2_32 $LIBS"
306   AC_TRY_LINK([#include <winsock2.h>],
307                [gethostbyname("www.dummysite.com");],
308                [ dnl worked!
309                AC_MSG_RESULT([yes])
310                HAVE_GETHOSTBYNAME="1"],
311                [ dnl failed, restore LIBS
312                LIBS=$my_ac_save_LIBS
313                AC_MSG_RESULT(no)]
314              )
315 fi
316
317 if test "$HAVE_GETHOSTBYNAME" = "1"; then
318   AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
319 else
320   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
321 fi
322
323 dnl resolve lib?
324 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
325
326 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
327   AC_CHECK_LIB(resolve, strcasecmp,
328               [LIBS="-lresolve $LIBS"],
329                ,
330                -lnsl)
331 fi
332
333 dnl socket lib?
334 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
335
336 dnl dl lib?
337 AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
338
339 AC_MSG_CHECKING([whether to use libgcc])
340 AC_ARG_ENABLE(libgcc,
341 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
342 [ case "$enableval" in
343   yes)
344         LIBS="$LIBS -lgcc"
345        AC_MSG_RESULT(yes)
346        ;;
347   *)   AC_MSG_RESULT(no)
348        ;;
349   esac ],
350        AC_MSG_RESULT(no)
351 )
352
353 dnl **********************************************************************
354 dnl Check for the presence of the winmm library.
355 dnl **********************************************************************
356
357 AC_MSG_CHECKING([for timeGetTime in winmm])
358 my_ac_save_LIBS=$LIBS
359 LIBS="-lwinmm $LIBS"
360 AC_TRY_LINK([#include <windef.h>
361              #include <mmsystem.h>
362              ],
363              [timeGetTime();],
364              [ dnl worked!
365              AC_MSG_RESULT([yes])
366              ],
367              [ dnl failed, restore LIBS
368              LIBS=$my_ac_save_LIBS
369              AC_MSG_RESULT(no)]
370            )
371
372 dnl **********************************************************************
373 dnl Checks for IPv6
374 dnl **********************************************************************
375
376 AC_MSG_CHECKING([whether to enable ipv6])
377 AC_ARG_ENABLE(ipv6,
378 AC_HELP_STRING([--enable-ipv6],[Enable ipv6 (with ipv4) support])
379 AC_HELP_STRING([--disable-ipv6],[Disable ipv6 support]),
380 [ case "$enableval" in
381   no)
382        AC_MSG_RESULT(no)
383        ipv6=no
384        ;;
385   *)   AC_MSG_RESULT(yes)
386        ipv6=yes
387        ;;
388   esac ],
389
390   AC_TRY_RUN([ /* is AF_INET6 available? */
391 #include <sys/types.h>
392 #include <sys/socket.h>
393 main()
394 {
395  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
396    exit(1);
397  else
398    exit(0);
399 }
400 ],
401   AC_MSG_RESULT(yes)
402   ipv6=yes,
403   AC_MSG_RESULT(no)
404   ipv6=no,
405   AC_MSG_RESULT(no)
406   ipv6=no
407 ))
408
409 if test "$ipv6" = "yes"; then
410   curl_ipv6_msg="enabled"
411
412   CURL_CHECK_WORKING_GETADDRINFO
413
414   CURL_CHECK_NI_WITHSCOPEID
415 fi
416
417 dnl **********************************************************************
418 dnl Check how non-blocking sockets are set
419 dnl **********************************************************************
420 AC_ARG_ENABLE(nonblocking,
421 AC_HELP_STRING([--enable-nonblocking],[Enable detecting how to do it])
422 AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking socket detection]),
423 [
424   if test "$enableval" = "no" ; then
425     AC_MSG_WARN([non-blocking sockets disabled])
426     AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
427     [to disable NON-BLOCKING connections])
428   else
429     CURL_CHECK_NONBLOCKING_SOCKET
430   fi
431 ],
432 [
433   CURL_CHECK_NONBLOCKING_SOCKET
434 ])
435
436 dnl **********************************************************************
437 dnl Check for the random seed preferences 
438 dnl **********************************************************************
439
440 AC_ARG_WITH(egd-socket,
441 AC_HELP_STRING([--with-egd-socket=FILE],
442                [Entropy Gathering Daemon socket pathname]),
443     [ EGD_SOCKET="$withval" ]
444 )
445 if test -n "$EGD_SOCKET" ; then
446         AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET",
447         [your Entropy Gathering Daemon socket pathname] )
448 fi
449
450 dnl Check for user-specified random device
451 AC_ARG_WITH(random,
452 AC_HELP_STRING([--with-random=FILE],[read randomness from FILE (default=/dev/urandom)]),
453     [ RANDOM_FILE="$withval" ],
454     [
455         dnl Check for random device
456         AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
457     ]
458 )
459 if test -n "$RANDOM_FILE" ; then
460         AC_SUBST(RANDOM_FILE)
461         AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
462         [a suitable file to read random data from])
463 fi
464
465 dnl **********************************************************************
466 dnl Check if the operating system allows programs to write to their own argv[]
467 dnl **********************************************************************
468
469 AC_MSG_CHECKING([if argv can be written to])
470 AC_CACHE_VAL(curl_cv_writable_argv, [
471 AC_RUN_IFELSE([[
472 int main(int argc, char ** argv) {
473         argv[0][0] = ' ';
474         return (argv[0][0] == ' ')?0:1;
475 }
476         ]],
477         curl_cv_writable_argv=yes,
478         curl_cv_writable_argv=no,
479         curl_cv_writable_argv=cross)
480 ])
481 case $curl_cv_writable_argv in
482 yes)
483         AC_DEFINE(HAVE_WRITABLE_ARGV, 1, [Define this symbol if your OS supports changing the contents of argv])
484         AC_MSG_RESULT(yes)
485         ;;
486 no)
487         AC_MSG_RESULT(no)
488         ;;
489 *)
490         AC_MSG_RESULT(no)
491         AC_MSG_WARN([the previous check could not be made default was used])
492         ;;
493 esac
494
495 dnl **********************************************************************
496 dnl Check for the presence of Kerberos4 libraries and headers
497 dnl **********************************************************************
498
499 AC_ARG_WITH(krb4-includes,
500 AC_HELP_STRING([--with-krb4-includes=DIR],
501                [Specify location of kerberos4 headers]),[
502  CPPFLAGS="$CPPFLAGS -I$withval"
503  KRB4INC="$withval"
504  want_krb4=yes
505  ])
506
507 AC_ARG_WITH(krb4-libs,
508 AC_HELP_STRING([--with-krb4-libs=DIR],[Specify location of kerberos4 libs]),[
509  LDFLAGS="$LDFLAGS -L$withval"
510  KRB4LIB="$withval"
511  want_krb4=yes
512  ])
513
514
515 OPT_KRB4=off
516 AC_ARG_WITH(krb4,dnl
517 AC_HELP_STRING([--with-krb4=DIR],[where to look for Kerberos4]),[
518   OPT_KRB4="$withval"
519   if test X"$OPT_KRB4" != Xyes
520   then
521     LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib$libsuff"
522     KRB4LIB="$OPT_KRB4/lib$libsuff"
523     CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
524     KRB4INC="$OPT_KRB4/include"
525   fi
526   want_krb4="yes"
527  ])
528
529 AC_MSG_CHECKING([if Kerberos4 support is requested])
530
531 if test "$want_krb4" = yes
532 then
533   if test "$ipv6" = "yes"; then
534     echo krb4 is not compatible with IPv6
535     exit 1
536   fi
537   AC_MSG_RESULT(yes)
538
539   dnl Check for & handle argument to --with-krb4
540
541   AC_MSG_CHECKING(where to look for Kerberos4)
542   if test X"$OPT_KRB4" = Xyes
543   then
544     AC_MSG_RESULT([defaults])
545   else
546     AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
547   fi
548
549   dnl Check for DES library
550   AC_CHECK_LIB(des, des_pcbc_encrypt,
551   [
552     AC_CHECK_HEADERS(des.h)
553
554     dnl resolv lib?
555     AC_CHECK_FUNC(res_search, , [AC_CHECK_LIB(resolv, res_search)])
556
557     dnl Check for the Kerberos4 library
558     AC_CHECK_LIB(krb, krb_net_read,
559     [
560       dnl Check for header files
561       AC_CHECK_HEADERS(krb.h)
562
563       dnl we found the required libraries, add to LIBS
564       LIBS="-lkrb -lcom_err -ldes $LIBS"
565
566       dnl Check for function krb_get_our_ip_for_realm
567       dnl this is needed for NAT networks
568       AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
569
570       dnl add define KRB4
571       AC_DEFINE(HAVE_KRB4, 1,
572       [if you have the Kerberos4 libraries (including -ldes)])
573
574       dnl substitute it too!
575       KRB4_ENABLED=1
576       AC_SUBST(KRB4_ENABLED)
577
578       curl_krb4_msg="enabled"
579
580       dnl the krb4 stuff needs a strlcpy()
581       AC_CHECK_FUNCS(strlcpy)
582
583     ])
584   ])
585 else
586   AC_MSG_RESULT(no)
587 fi
588
589 dnl **********************************************************************
590 dnl Check for FBopenssl(SPNEGO) libraries
591 dnl **********************************************************************
592
593 AC_ARG_WITH(spnego,
594   AC_HELP_STRING([--with-spnego=DIR],
595                  [Specify location of SPNEGO library fbopenssl]),
596   [ SPNEGO_ROOT="$withval"
597     want_spnego="yes" ]
598 )
599 AC_MSG_CHECKING([if SPNEGO support is requested])
600 if test x"$want_spnego" = xyes; then
601
602   if test X"$SPNEGO_ROOT" = Xyes; then
603      AC_MSG_ERROR([FBOpenSSL libs and/or directories were not found where specified!])
604      AC_MSG_RESULT(no)
605   else
606      if test -z "$SPNEGO_LIB_DIR"; then
607         LDFLAGS="$LDFLAGS -L$SPNEGO_ROOT -lfbopenssl"
608      else
609         LDFLAGS="$LDFLAGS $SPNEGO_LIB_DIR"
610      fi
611  
612      AC_MSG_RESULT(yes)
613      AC_DEFINE(HAVE_SPNEGO, 1,
614                [Define this if you have the SPNEGO library fbopenssl])
615      curl_spnego_msg="enabled"
616   fi
617 else
618   AC_MSG_RESULT(no)
619 fi
620
621 dnl **********************************************************************
622 dnl Check for GSS-API libraries
623 dnl **********************************************************************
624
625 AC_ARG_WITH(gssapi-includes,
626   AC_HELP_STRING([--with-gssapi-includes=DIR],
627                  [Specify location of GSSAPI header]),
628   [ GSSAPI_INCS="-I$withval" 
629     want_gss="yes" ]
630 )
631
632 AC_ARG_WITH(gssapi-libs,
633   AC_HELP_STRING([--with-gssapi-libs=DIR],
634                  [Specify location of GSSAPI libs]),
635   [ GSSAPI_LIBS="-L$withval -lgssapi"
636     want_gss="yes" ]
637 )
638
639 AC_ARG_WITH(gssapi,
640   AC_HELP_STRING([--with-gssapi=DIR],
641                  [Where to look for GSSAPI]),
642   [ GSSAPI_ROOT="$withval"
643     want_gss="yes" ]
644 )
645
646 AC_MSG_CHECKING([if GSSAPI support is requested])
647 if test x"$want_gss" = xyes; then
648   if test -z "$GSSAPI_INCS"; then
649      if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
650         GSSAPI_INCS=`$GSSAPI_ROOT/bin/krb5-config --cflags gssapi`
651      elif test "$GSSAPI_ROOT" != "yes"; then
652         GSSAPI_INCS="-I$GSSAPI_ROOT/include"
653      fi
654   fi
655   CPPFLAGS="$CPPFLAGS $GSSAPI_INCS"
656   
657   if test -z "$GSSAPI_LIB_DIR"; then
658      if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
659         gss_ldflags=`$GSSAPI_ROOT/bin/krb5-config --libs gssapi`
660         LDFLAGS="$LDFLAGS $gss_ldflags"
661      elif test "$GSSAPI_ROOT" != "yes"; then
662         LDFLAGS="$LDFLAGS -L$GSSAPI_ROOT/lib$libsuff -lgssapi"
663      else
664         LDFLAGS="$LDFLAGS -lgssapi"
665      fi
666   else
667      LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
668   fi
669
670   AC_MSG_RESULT(yes)
671   AC_DEFINE(HAVE_GSSAPI, 1, [if you have the gssapi libraries])
672
673   curl_gss_msg="enabled"
674
675   AC_CHECK_HEADER(gssapi.h,
676     [
677        dnl found in the given dirs
678       AC_DEFINE(HAVE_GSSHEIMDAL, 1, [if you have the Heimdal gssapi libraries])
679     ],
680     [
681       dnl not found, check in gssapi/ subdir 
682       AC_CHECK_HEADER(gssapi/gssapi.h,
683         dnl found 
684         AC_DEFINE(HAVE_GSSMIT, 1, [if you have the MIT gssapi libraries])
685       )
686       
687     ]
688   )
689
690 else
691   AC_MSG_RESULT(no)
692 fi
693   
694 dnl **********************************************************************
695 dnl Check for the presence of SSL libraries and headers
696 dnl **********************************************************************
697
698 dnl Default to compiler & linker defaults for SSL files & libraries.
699 OPT_SSL=off
700 dnl Default to no CA bundle
701 ca="no"
702 AC_ARG_WITH(ssl,dnl
703 AC_HELP_STRING([--with-ssl=PATH],[where to look for SSL, PATH points to the SSL installation (default: /usr/local/ssl)])
704 AC_HELP_STRING([--without-ssl], [disable SSL]),
705   OPT_SSL=$withval)
706
707 if test X"$OPT_SSL" = Xno
708 then
709   AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more])  
710 else
711
712   dnl backup the pre-ssl variables
713   CLEANLDFLAGS="$LDFLAGS"
714   CLEANCPPFLAGS="$CPPFLAGS"
715   CLEANLIBS="$LIBS"
716
717   case "$OPT_SSL" in
718   yes)
719     dnl --with-ssl (without path) used
720     if test x$cross_compiling != xyes; then
721       dnl only do pkg-config magic when not cross-compiling
722       PKGTEST="yes"
723     fi
724     EXTRA_SSL=/usr/local/ssl ;;
725   off)
726     dnl no --with-ssl option given, just check default places
727     if test x$cross_compiling != xyes; then
728       dnl only do pkg-config magic when not cross-compiling
729       PKGTEST="yes"
730     fi
731     EXTRA_SSL= ;;
732   *)
733     dnl check the given --with-ssl spot
734     PKGTEST="no"
735     EXTRA_SSL=$OPT_SSL
736     LDFLAGS="$LDFLAGS -L$EXTRA_SSL/lib$libsuff"
737     CPPFLAGS="$CPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
738     ;;
739   esac
740
741   if test "$PKGTEST" = "yes"; then
742
743     dnl Detect the pkg-config tool, as it may have extra info about the
744     dnl openssl installation we can use. I *believe* this is what we are
745     dnl expected to do on really recent Redhat Linux hosts.
746
747     AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
748     if test "$PKGCONFIG" != "no" ; then
749       AC_MSG_CHECKING([OpenSSL options with pkg-config])
750
751       $PKGCONFIG --exists openssl
752       SSL_EXISTS=$?
753
754       if test "$SSL_EXISTS" -eq "0"; then
755         SSL_LIBS=`$PKGCONFIG --libs-only-l openssl 2>/dev/null`
756         SSL_LDFLAGS=`$PKGCONFIG --libs-only-L openssl 2>/dev/null`
757         SSL_CPPFLAGS=`$PKGCONFIG --cflags-only-I openssl 2>/dev/null`
758
759         dnl use the values pkg-config reported
760         LIBS="$LIBS $SSL_LIBS"
761         CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
762         LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
763         AC_MSG_RESULT([found])
764       else
765         AC_MSG_RESULT([no])
766       fi
767     fi
768   fi
769
770   AC_CHECK_LIB(crypto, CRYPTO_lock,[
771      HAVECRYPTO="yes"
772      ],[
773      LDFLAGS="$CLEANLDFLAGS -L$EXTRA_SSL/lib$libsuff"
774      CPPFLAGS="$CLEANCPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
775      AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
776        HAVECRYPTO="yes" ], [
777        LDFLAGS="$CLEANLDFLAGS"
778        CPPFLAGS="$CLEANCPPFLAGS"
779        LIBS="$CLEANLIBS"
780        ])
781     ])
782
783
784   if test "$HAVECRYPTO" = "yes"; then
785     dnl This is only reasonable to do if crypto actually is there: check for
786     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
787
788     dnl This is for Msys/Mingw
789     AC_MSG_CHECKING([for gdi32])
790     my_ac_save_LIBS=$LIBS
791     LIBS="-lgdi32 $LIBS"
792     AC_TRY_LINK([#include <windef.h>
793                  #include <wingdi.h>],
794                [GdiFlush();],
795                [ dnl worked!
796                AC_MSG_RESULT([yes])],
797                [ dnl failed, restore LIBS
798                LIBS=$my_ac_save_LIBS
799                AC_MSG_RESULT(no)]
800               )
801
802     AC_CHECK_LIB(crypto, CRYPTO_add_lock)
803     AC_CHECK_LIB(ssl, SSL_connect)
804
805     if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
806         dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
807         AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
808         OLIBS=$LIBS
809         LIBS="$LIBS -lRSAglue -lrsaref"
810         AC_CHECK_LIB(ssl, SSL_connect)
811         if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
812             dnl still no SSL_connect
813             AC_MSG_RESULT(no)
814             LIBS=$OLIBS
815         else
816             AC_MSG_RESULT(yes)
817         fi
818     fi
819
820
821     dnl Check for SSLeay headers
822     AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
823                      openssl/pem.h openssl/ssl.h openssl/err.h,
824       curl_ssl_msg="enabled"
825       OPENSSL_ENABLED=1)
826
827     if test $ac_cv_header_openssl_x509_h = no; then
828       AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h,
829         curl_ssl_msg="enabled"
830         OPENSSL_ENABLED=1)
831     fi
832
833     dnl If the ENGINE library seems to be around, check for the OpenSSL engine
834     dnl header, it is kind of "separated" from the main SSL check
835     AC_CHECK_FUNC(ENGINE_init, [ AC_CHECK_HEADERS(openssl/engine.h) ])
836
837     AC_SUBST(OPENSSL_ENABLED)
838
839     AC_MSG_CHECKING([CA cert bundle install path])
840
841     AC_ARG_WITH(ca-bundle,
842 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to install the CA bundle as])
843 AC_HELP_STRING([--without-ca-bundle], [Don't install the CA bundle]),
844     [ ca="$withval" ],
845     [
846       if test "x$prefix" != xNONE; then
847         ca="\${prefix}/share/curl/curl-ca-bundle.crt"
848       else
849         ca="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
850       fi
851     ] )
852
853     if test X"$OPT_SSL" = Xno; then
854       ca="no"
855     fi
856
857     if test "x$ca" != "xno"; then
858       CURL_CA_BUNDLE='"'$ca'"'
859       AC_SUBST(CURL_CA_BUNDLE)  
860     fi
861     AC_MSG_RESULT([$ca])
862
863     dnl these can only exist if openssl exists
864
865     AC_CHECK_FUNCS( RAND_status \
866                     RAND_screen \
867                     RAND_egd \
868                     CRYPTO_cleanup_all_ex_data )
869
870   fi
871
872   if test X"$OPT_SSL" != Xoff &&
873      test "$OPENSSL_ENABLED" != "1"; then
874     AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
875   elif test "$OPENSSL_ENABLED" = "1"; then
876     dnl when the ssl shared libs were found in a path that the run-time linker
877     dnl doesn't search through, we need to add it to LD_LIBRARY_PATH to
878     dnl prevent further configure tests to fail due to this
879     LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$EXTRA_SSL/lib$libsuff"
880     export LD_LIBRARY_PATH
881   fi
882
883 fi
884
885 AM_CONDITIONAL(CABUNDLE, test x$ca != xno)
886
887 dnl **********************************************************************
888 dnl Check for the presence of ZLIB libraries and headers
889 dnl **********************************************************************
890
891 dnl Check for & handle argument to --with-zlib.
892
893 _cppflags=$CPPFLAGS
894 _ldflags=$LDFLAGS
895 OPT_ZLIB="/usr/local"
896 AC_ARG_WITH(zlib,
897 AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH])
898 AC_HELP_STRING([--without-zlib],[disable use of zlib]),
899                [OPT_ZLIB="$withval"])
900
901 case "$OPT_ZLIB" in
902   no)
903     AC_MSG_WARN([zlib disabled]) ;;
904   *)
905     dnl check for the lib first without setting any new path, since many
906     dnl people have it in the default path
907
908     AC_CHECK_LIB(z, inflateEnd,
909                    dnl libz found, set the variable
910                    [HAVE_LIBZ="1"],
911                    dnl if no lib found, try to add the given library
912                    [if test -d "$OPT_ZLIB"; then
913                       CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
914                       LDFLAGS="$LDFLAGS -L$OPT_ZLIB/lib$libsuff"
915                    fi])
916
917     AC_CHECK_HEADER(zlib.h,
918       [
919       dnl zlib.h was found
920       HAVE_ZLIB_H="1"
921       dnl if the lib wasn't found already, try again with the new paths
922       if test "$HAVE_LIBZ" != "1"; then
923         AC_CHECK_LIB(z, gzread,
924                      [
925                      dnl the lib was found!
926                      HAVE_LIBZ="1"
927                      ],
928                      [ CPPFLAGS=$_cppflags
929                      LDFLAGS=$_ldflags])
930       fi
931       ],
932       [
933         dnl zlib.h was not found, restore the flags
934         CPPFLAGS=$_cppflags
935         LDFLAGS=$_ldflags]
936       )
937
938     if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
939     then
940       AC_MSG_WARN([configure found only the libz lib, not the header file!])
941     elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
942     then
943       AC_MSG_WARN([configure found only the libz header file, not the lib!])
944     elif test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" = "1"
945     then
946       dnl both header and lib were found!
947       AC_SUBST(HAVE_LIBZ)
948       AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
949       AC_DEFINE(HAVE_LIBZ, 1, [if zlib is available])
950
951       LIBS="$LIBS -lz"
952
953       dnl replace 'HAVE_LIBZ' in the automake makefile.ams
954       AMFIXLIB="1"
955       AC_MSG_NOTICE([found both libz and libz.h header])
956       curl_zlib_msg="enabled"
957     fi
958     ;;
959 esac
960
961 dnl set variable for use in automakefile(s)
962 AM_CONDITIONAL(HAVE_LIBZ, test x"$AMFIXLIB" = x1)
963
964 AC_MSG_CHECKING([whether to build with libidn])
965 AC_ARG_WITH(libidn,
966 AC_HELP_STRING([--with-libidn=PATH],[Enable libidn usage])
967 AC_HELP_STRING([--without-libidn],[Disable libidn usage]),
968   [LIBIDN="$withval"])
969
970 case "$LIBIDN" in
971   no)
972        AC_MSG_RESULT(no)
973        ;;
974   *)   AC_MSG_RESULT(yes)
975
976        idn=""
977        dnl if there is a given path, check that FIRST
978        if test -n "$LIBIDN"; then
979          if test "x$LIBIDN" != "xyes"; then
980             AC_MSG_WARN([moo moo $LIBIDN])
981             oldLDFLAGS=$LDFLAGS
982             oldCPPFLAGS=$CPPFLAGS
983             LDFLAGS="$LDFLAGS -L$LIBIDN/lib"
984             CPPFLAGS="$CPPFLAGS -I$LIBIDN/include"
985             idn="yes"
986             AC_CHECK_LIB(idn, idna_to_ascii_4i, ,
987                          idn=""
988                          LDFLAGS=$oldLDFLAGS
989                          CPPFLAGS=$oldCPPFLAGS)
990          fi
991        fi
992
993        if test "x$idn" != "xyes"; then
994           dnl check with default paths
995           idn="yes"
996           AC_CHECK_LIB(idn, idna_to_ascii_lz, ,
997                        idn="")
998        fi
999
1000        if test "x$idn" = "xyes"; then
1001          curl_idn_msg="enabled"
1002          dnl different versions of libidn have different setups of these:
1003          AC_CHECK_FUNCS( idn_free idna_strerror tld_strerror)
1004          AC_CHECK_HEADERS( idn-free.h tld.h )
1005        fi
1006                     
1007        ;; 
1008 esac
1009
1010 dnl Default is to try the thread-safe versions of a few functions
1011 OPT_THREAD=on
1012
1013 dnl detect AIX 4.3 or later
1014 dnl see full docs on this reasoning in the lib/hostip.c source file
1015 AC_MSG_CHECKING([AIX 4.3 or later])
1016 AC_PREPROC_IFELSE([
1017 #if defined(_AIX) && defined(_AIX43)
1018 printf("just fine");
1019 #else
1020 #error "this is not AIX 4.3 or later"
1021 #endif
1022 ],
1023  [ AC_MSG_RESULT([yes])
1024    RECENTAIX=yes
1025    OPT_THREAD=off ],
1026  [ AC_MSG_RESULT([no]) ]
1027 )
1028
1029 AC_ARG_ENABLE(thread,dnl
1030 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
1031 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
1032 [ case "$enableval" in
1033   no)
1034     OPT_THREAD=off
1035     AC_MSG_WARN(libcurl will not get built using thread-safe functions)
1036     ;;
1037   *)
1038     ;;
1039   esac
1040 ]
1041 )
1042
1043 if test X"$OPT_THREAD" = Xoff
1044 then
1045   AC_DEFINE(DISABLED_THREADSAFE, 1, \
1046 Set to explicitly specify we don't want to use thread-safe functions)
1047 else
1048   if test "$ipv6" != "yes"; then
1049     dnl dig around for gethostbyname_r()
1050     CURL_CHECK_GETHOSTBYNAME_R()
1051
1052     dnl dig around for gethostbyaddr_r()
1053     dnl CURL_CHECK_GETHOSTBYADDR_R()
1054   fi
1055
1056   dnl poke around for inet_ntoa_r()
1057   CURL_CHECK_INET_NTOA_R()
1058
1059   dnl is there a localtime_r()
1060   CURL_CHECK_LOCALTIME_R()
1061
1062   dnl is there a strerror_r()
1063   CURL_CHECK_STRERROR_R()
1064
1065   AC_CHECK_FUNCS( gmtime_r )
1066 fi
1067
1068 dnl for recent AIX versions, we skip all the thread-safe checks above since
1069 dnl they claim a thread-safe libc using the standard API. But there are
1070 dnl some functions still not thread-safe. Check for these!
1071
1072 dnl Let's hope this split URL remains working:
1073 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
1074 dnl genprogc/thread_quick_ref.htm
1075
1076 if test "x$RECENTAIX" = "xyes"; then
1077
1078   AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
1079
1080   dnl check if this is the IMB xlc compiler
1081   dnl Details thanks to => http://predef.sourceforge.net/
1082   AC_MSG_CHECKING([if this is the xlc compiler])
1083   AC_EGREP_CPP([^__xlC__], [__xlC__],
1084          dnl action if the text is found, this it has not been replaced by the
1085          dnl cpp
1086          XLC="no"
1087          AC_MSG_RESULT([no]),
1088          dnl the text was not found, it was replaced by the cpp
1089          XLC="yes"
1090          AC_MSG_RESULT([yes])
1091          CFLAGS="$CFLAGS -qthreaded"
1092        )
1093
1094
1095   dnl is there a localtime_r()
1096   CURL_CHECK_LOCALTIME_R()
1097
1098   dnl is there a strerror_r()
1099   CURL_CHECK_STRERROR_R()
1100
1101   AC_CHECK_FUNCS( gmtime_r )
1102 fi
1103
1104
1105 dnl **********************************************************************
1106 dnl Back to "normal" configuring
1107 dnl **********************************************************************
1108
1109 dnl Checks for header files.
1110 AC_HEADER_STDC
1111
1112 dnl First check for the very most basic headers. Then we can use these
1113 dnl ones as default-headers when checking for the rest!
1114 AC_CHECK_HEADERS(
1115         sys/types.h \
1116         sys/time.h \
1117         sys/select.h \
1118         sys/socket.h \
1119         sys/ioctl.h \
1120         assert.h \
1121         unistd.h \
1122         malloc.h \
1123         stdlib.h \
1124         limits.h \
1125         arpa/inet.h \
1126         net/if.h \
1127         netinet/in.h \
1128         netinet/tcp.h \
1129         netdb.h \
1130         sys/sockio.h \
1131         sys/stat.h \
1132         sys/param.h \
1133         termios.h \
1134         termio.h \
1135         sgtty.h \
1136         fcntl.h \
1137         dlfcn.h \
1138         alloca.h \
1139         winsock.h \
1140         winsock2.h \
1141         time.h \
1142         io.h \
1143         pwd.h \
1144         utime.h \
1145         sys/utime.h \
1146         sys/poll.h \
1147         sys/resource.h \
1148         libgen.h \
1149         locale.h \
1150         setjmp.h,
1151 dnl to do if not found
1152 [],
1153 dnl to do if found
1154 [],
1155 dnl default includes
1156 [
1157 #ifdef HAVE_SYS_TYPES_H
1158 #include <sys/types.h>
1159 #endif
1160 #ifdef HAVE_SYS_TIME_H
1161 #include <sys/time.h>
1162 #endif
1163 #ifdef HAVE_SYS_SELECT_H
1164 #include <sys/select.h>
1165 #endif
1166 #ifdef HAVE_SYS_SOCKET_H
1167 #include <sys/socket.h>
1168 #endif
1169 #ifdef HAVE_NETINET_IN_H
1170 #include <netinet/in.h>
1171 #endif
1172 ]
1173 )
1174
1175 dnl Checks for typedefs, structures, and compiler characteristics.
1176 AC_C_CONST
1177 AC_TYPE_SIZE_T
1178 AC_HEADER_TIME
1179
1180 AC_CHECK_SIZEOF(curl_off_t, ,[
1181 #include <stdio.h>
1182 #include "$srcdir/include/curl/curl.h"
1183 ])
1184 AC_CHECK_SIZEOF(size_t)
1185 AC_CHECK_SIZEOF(long)
1186 AC_CHECK_SIZEOF(time_t)
1187
1188 AC_CHECK_TYPE(long long,
1189    [AC_DEFINE(HAVE_LONGLONG, 1, [if your compiler supports long long])]
1190    longlong="yes"  
1191 )
1192
1193 if test "xyes" = "x$longlong"; then
1194   AC_MSG_CHECKING([if numberLL works])
1195   AC_COMPILE_IFELSE([long long val = 1000LL;],
1196    [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
1197    AC_MSG_RESULT(yes),
1198    AC_MSG_RESULT(no)
1199   )
1200 fi
1201
1202
1203 # check for ssize_t
1204 AC_CHECK_TYPE(ssize_t, ,
1205    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
1206
1207 TYPE_SOCKLEN_T
1208 TYPE_IN_ADDR_T
1209
1210 AC_FUNC_SELECT_ARGTYPES
1211
1212 dnl Checks for library functions.
1213 dnl AC_PROG_GCC_TRADITIONAL
1214 AC_TYPE_SIGNAL
1215 dnl AC_FUNC_VPRINTF
1216 AC_CHECK_FUNCS( strtoll \
1217                 socket \
1218                 select \
1219                 strdup \
1220                 strstr \
1221                 strtok_r \
1222                 strftime \
1223                 uname \
1224                 strcasecmp \
1225                 stricmp \
1226                 strcmpi \
1227                 gethostbyaddr \
1228                 gettimeofday \
1229                 inet_addr \
1230                 inet_ntoa \
1231                 inet_pton \
1232                 tcsetattr \
1233                 tcgetattr \
1234                 perror \
1235                 closesocket \
1236                 siginterrupt \
1237                 sigaction \
1238                 signal \
1239                 getpass_r \
1240                 strlcat \
1241                 getpwuid \
1242                 geteuid \
1243                 dlopen \
1244                 utime \
1245                 sigsetjmp \
1246                 basename \
1247                 setlocale \
1248                 ftruncate \
1249                 pipe \
1250                 poll \
1251                 getrlimit \
1252                 setrlimit,
1253 dnl if found
1254 [],
1255 dnl if not found, $ac_func is the name we check for
1256   func="$ac_func"
1257   AC_MSG_CHECKING([deeper for $func])
1258   AC_TRY_LINK( [],
1259                [ $func ();],
1260                AC_MSG_RESULT(yes!)
1261                eval "ac_cv_func_$func=yes"
1262                def=`echo "HAVE_$func" | tr 'a-z' 'A-Z'`
1263                AC_DEFINE_UNQUOTED($def, 1, [If you have $func]),
1264                AC_MSG_RESULT(but still no)
1265                )
1266
1267 )
1268
1269 dnl For some reason, the check above doesn't properly detect select() with
1270 dnl Msys/Mingw
1271 if test "$ac_cv_func_select" != "yes"; then
1272   AC_MSG_CHECKING([for select in ws2_32])
1273   AC_TRY_LINK([#include <winsock2.h>],
1274                [select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL);],
1275                [ dnl worked!
1276                AC_MSG_RESULT([yes])
1277                HAVE_SELECT="1"
1278                AC_DEFINE_UNQUOTED(HAVE_SELECT,1)],
1279                [AC_MSG_ERROR(You can't compile without a select)]
1280              )
1281 fi
1282
1283 dnl sigsetjmp() might be a macro and no function so if it isn't found already
1284 dnl we make an extra check here!
1285 if test "$ac_cv_func_sigsetjmp" != "yes"; then
1286   AC_MSG_CHECKING([for sigsetjmp defined as macro])
1287   AC_TRY_LINK( [#include <setjmp.h>],
1288                [sigjmp_buf jmpenv;
1289                 sigsetjmp(jmpenv, 1);],
1290                AC_MSG_RESULT(yes)
1291                AC_DEFINE(HAVE_SIGSETJMP, 1, [If you have sigsetjmp]),
1292                AC_MSG_RESULT(no)
1293                )
1294 fi
1295
1296 AC_CHECK_DECL(basename, ,
1297               AC_DEFINE(NEED_BASENAME_PROTO, 1, [If you lack a fine basename() prototype]),
1298 #ifdef HAVE_STRING_H
1299 #include <string.h>
1300 #endif
1301 #ifdef HAVE_LIBGEN_H
1302 #include <libgen.h>
1303 #endif
1304 )
1305
1306 dnl poll() might be badly emulated, as in Mac OS X 10.3 (and other BSDs?) and
1307 dnl to find out we make an extra check here!
1308 if test "$ac_cv_func_poll" = "yes"; then
1309   AC_MSG_CHECKING([if poll works with NULL inputs])
1310   AC_RUN_IFELSE([
1311 #ifdef HAVE_SYS_POLL_H
1312 #include <sys/poll.h>
1313 #endif
1314
1315   int main(void)
1316   {
1317     /* make this return 0 == timeout since there's nothing to read from */
1318     return poll((void *)0, 0, 10 /*ms*/);
1319   }
1320 ],
1321   AC_MSG_RESULT(yes)
1322   AC_DEFINE(HAVE_POLL_FINE, 1, [If you have a fine poll]),
1323   AC_MSG_RESULT(no),
1324   AC_MSG_RESULT(cross-compiling assumes yes)
1325   AC_DEFINE(HAVE_POLL_FINE, 1, [If you have a fine poll])
1326   ) dnl end of AC_RUN_IFELSE
1327 fi
1328
1329
1330
1331 AC_PATH_PROG( PERL, perl, , 
1332   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
1333 AC_SUBST(PERL)
1334
1335 AC_PATH_PROGS( NROFF, gnroff nroff, , 
1336   $PATH:/usr/bin/:/usr/local/bin )
1337 AC_SUBST(NROFF)
1338
1339 if test -n "$NROFF"; then
1340   dnl only check for nroff options if an nroff command was found
1341
1342   AC_MSG_CHECKING([how to use *nroff to get plain text from man pages])
1343   MANOPT="-man"
1344   mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
1345   if test -z "$mancheck"; then
1346     MANOPT="-mandoc"
1347    mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
1348     if test -z "$mancheck"; then
1349       MANOPT=""
1350       AC_MSG_RESULT([failed])
1351       AC_MSG_WARN([found no *nroff option to get plaintext from man pages])
1352     else
1353       AC_MSG_RESULT([$MANOPT])
1354     fi
1355   else
1356     AC_MSG_RESULT([$MANOPT])
1357   fi
1358   AC_SUBST(MANOPT)
1359 fi
1360
1361 if test -z "$MANOPT"
1362 then
1363   dnl if no nroff tool was found, or no option that could convert man pages
1364   dnl was found, then disable the built-in manual stuff
1365   AC_MSG_WARN([disabling built-in manual])
1366   USE_MANUAL="no";
1367 fi
1368
1369 dnl *************************************************************************
1370 dnl If the manual variable still is set, then we go with providing a built-in
1371 dnl manual
1372
1373 if test "$USE_MANUAL" = "1"; then
1374   AC_DEFINE(USE_MANUAL, 1, [If you want to build curl with the built-in manual])
1375   curl_manual_msg="enabled"
1376 fi
1377
1378 dnl set variable for use in automakefile(s)
1379 AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1)
1380
1381 AC_MSG_CHECKING([whether to enable ares])
1382 AC_ARG_ENABLE(ares,
1383 AC_HELP_STRING([--enable-ares=PATH],[Enable ares for name lookups])
1384 AC_HELP_STRING([--disable-ares],[Disable ares for name lookups]),
1385 [ case "$enableval" in
1386   no)
1387        AC_MSG_RESULT(no)
1388        ;;
1389   *)   AC_MSG_RESULT(yes)
1390
1391        if test "x$IPV6_ENABLED" = "x1"; then
1392          AC_MSG_ERROR([ares doesn't work with ipv6, disable ipv6 to use ares])
1393        fi
1394
1395        AC_DEFINE(USE_ARES, 1, [Define if you want to enable ares support])
1396        dnl substitute HAVE_ARES for curl-config and similar
1397        HAVE_ARES="1"
1398        AC_SUBST(HAVE_ARES)
1399        curl_ares_msg="enabled"
1400
1401        LIBS="$LIBS -lcares"
1402
1403        dnl For backwards compatibility default to includes/lib in srcdir/ares
1404        dnl If a value is specified it is assumed that the libs are in $val/lib
1405        dnl and the includes are in $val/include. This is the default setup for
1406        dnl ares so it should not be a problem.
1407        if test "x$enableval" = "xyes" ; then
1408          if test -d "$srcdir/ares"; then
1409             aresembedded="yes"
1410             AC_CONFIG_SUBDIRS(ares)
1411             aresinc=`cd $srcdir/ares && pwd`
1412             CPPFLAGS="$CPPFLAGS -I$aresinc"
1413
1414             dnl the pwd= below cannot 'cd' into the ares dir to get the full
1415             dnl path to it, since it may not exist yet if we build outside of
1416             dnl the source tree
1417             pwd=`pwd`
1418             LDFLAGS="$LDFLAGS -L$pwd/ares"
1419          fi
1420        else
1421          CPPFLAGS="$CPPFLAGS -I$enableval/include"
1422          LDFLAGS="$LDFLAGS -L$enableval/lib"
1423        fi
1424
1425        if test -z "$aresembedded"; then
1426          dnl verify that a sufficient c-ares is here if we have pointed one
1427          dnl out and don't use the "embedded" ares dir (in which case we don't
1428          dnl check it because it might not have been built yet)
1429          AC_MSG_CHECKING([that c-ares is good and recent enough])
1430          AC_LINK_IFELSE( [
1431 #include <ares.h>
1432 /* provide a set of dummy functions in case c-ares was built with debug */
1433 void curl_dofree() { }
1434 void curl_sclose() { }
1435 void curl_domalloc() { }
1436
1437 int main(void)
1438 {
1439   ares_channel channel;
1440   ares_cancel(channel);
1441   return 0;
1442 }
1443 ],
1444           AC_MSG_RESULT(yes),
1445           AC_MSG_RESULT(no)
1446           AC_MSG_ERROR([c-ares library defective or too old])
1447           )
1448        fi
1449        ;;
1450   esac ],
1451        AC_MSG_RESULT(no)
1452 )
1453
1454 dnl ************************************************************
1455 dnl disable verbose text strings
1456 dnl
1457 AC_MSG_CHECKING([whether to enable verbose strings])
1458 AC_ARG_ENABLE(verbose,
1459 AC_HELP_STRING([--enable-verbose],[Enable verbose strings])
1460 AC_HELP_STRING([--disable-verbose],[Disable verbose strings]),
1461 [ case "$enableval" in
1462   no)
1463        AC_MSG_RESULT(no)
1464        AC_DEFINE(CURL_DISABLE_VERBOSE_STRINGS, 1, [to disable verbose strings])
1465        AC_SUBST(CURL_DISABLE_VERBOSE_STRINGS)
1466        curl_verbose_msg="no"
1467        ;;
1468   *)   AC_MSG_RESULT(yes)
1469        ;;
1470   esac ],
1471        AC_MSG_RESULT(yes)
1472 )
1473
1474 dnl ************************************************************
1475 dnl lame option to switch on debug options
1476 dnl
1477 AC_MSG_CHECKING([whether to enable debug options])
1478 AC_ARG_ENABLE(debug,
1479 AC_HELP_STRING([--enable-debug],[Enable pedantic debug options])
1480 AC_HELP_STRING([--disable-debug],[Disable debug options]),
1481 [ case "$enableval" in
1482   no)
1483        AC_MSG_RESULT(no)
1484        ;;
1485   *)   AC_MSG_RESULT(yes)
1486
1487     CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
1488     CFLAGS="$CFLAGS -g"
1489
1490     dnl set compiler "debug" options to become more picky, and remove
1491     dnl optimize options from CFLAGS
1492     CURL_CC_DEBUG_OPTS
1493        ;;
1494   esac
1495  ],
1496        AC_MSG_RESULT(no)
1497 )
1498
1499 dnl ************************************************************
1500 dnl disable cryptographic authentication
1501 dnl
1502 AC_MSG_CHECKING([whether to enable cryptographic authentication methods])
1503 AC_ARG_ENABLE(crypto-auth,
1504 AC_HELP_STRING([--enable-crypto-auth],[Enable cryptographic authentication])
1505 AC_HELP_STRING([--disable-crypto-auth],[Disable cryptographic authentication]),
1506 [ case "$enableval" in
1507   no)
1508        AC_MSG_RESULT(no)
1509        AC_DEFINE(CURL_DISABLE_CRYPTO_AUTH, 1, [to disable cryptographic authentication])
1510        AC_SUBST(CURL_DISABLE_CRYPTO_AUTH)
1511        ;;
1512   *)   AC_MSG_RESULT(yes)
1513        ;;
1514   esac ],
1515        AC_MSG_RESULT(yes)
1516 )
1517
1518 dnl ************************************************************
1519 dnl disable cookies support
1520 dnl
1521 AC_MSG_CHECKING([whether to enable support for cookies])
1522 AC_ARG_ENABLE(cookies,
1523 AC_HELP_STRING([--enable-cookies],[Enable cookies support])
1524 AC_HELP_STRING([--disable-cookies],[Disable cookies support]),
1525 [ case "$enableval" in
1526   no)
1527        AC_MSG_RESULT(no)
1528        AC_DEFINE(CURL_DISABLE_COOKIES, 1, [to disable cookies support])
1529        AC_SUBST(CURL_DISABLE_COOKIES)
1530        ;;
1531   *)   AC_MSG_RESULT(yes)
1532        ;;
1533   esac ],
1534        AC_MSG_RESULT(yes)
1535 )
1536
1537 AM_CONDITIONAL(CROSSCOMPILING, test x$cross_compiling = xyes)
1538
1539 AC_CONFIG_FILES([Makefile \
1540            docs/Makefile \
1541            docs/examples/Makefile \
1542            docs/libcurl/Makefile \
1543            include/Makefile \
1544            include/curl/Makefile \
1545            src/Makefile \
1546            lib/Makefile \
1547            tests/Makefile \
1548            tests/data/Makefile \
1549            tests/server/Makefile \
1550            tests/libtest/Makefile \
1551            packages/Makefile \
1552            packages/Win32/Makefile \
1553            packages/Win32/cygwin/Makefile \
1554            packages/Linux/Makefile \
1555            packages/Linux/RPM/Makefile \
1556            packages/Linux/RPM/curl.spec \
1557            packages/Linux/RPM/curl-ssl.spec \
1558            packages/Solaris/Makefile \
1559            packages/DOS/Makefile \
1560            packages/EPM/curl.list \
1561            packages/EPM/Makefile \
1562            packages/vms/Makefile \
1563            curl-config
1564 ])
1565 AC_OUTPUT
1566
1567 AC_MSG_NOTICE([Configured to build curl/libcurl:
1568
1569   curl version:    ${VERSION}
1570   Host setup:      ${host}
1571   Install prefix:  ${prefix}
1572   Compiler:        ${CC}
1573   SSL support:     ${curl_ssl_msg}
1574   zlib support:    ${curl_zlib_msg}
1575   krb4 support:    ${curl_krb4_msg}
1576   GSSAPI support:  ${curl_gss_msg}
1577   SPNEGO support:  ${curl_spnego_msg}
1578   c-ares support:  ${curl_ares_msg}
1579   ipv6 support:    ${curl_ipv6_msg}
1580   IDN support:     ${curl_idn_msg}
1581   Build libcurl:   Shared=${enable_shared}, Static=${enable_static} 
1582   Built-in manual: ${curl_manual_msg}
1583   Verbose errors:  ${curl_verbose_msg}
1584 ])