c831dffaf8ce8566f995ca1920e4284f490755fb
[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, [-], [curl-bug@haxx.se])
8
9 dnl configure script copyright
10 AC_COPYRIGHT([Copyright (c) 1998 - 2003 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, , $PATH:/usr/bin:/usr/local/bin)
20 AC_SUBST(SED)
21
22 dnl AR is used by libtool, and try the odd Solaris path too
23 AC_PATH_PROG( AR, ar, , $PATH:/usr/bin:/usr/local/bin:/usr/ccs/bin)
24 AC_SUBST(AR)
25
26 dnl figure out the libcurl version
27 VERSION=`$SED -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curl.h`
28 AM_INIT_AUTOMAKE(curl,$VERSION)
29 AC_MSG_CHECKING([curl version])
30 AC_MSG_RESULT($VERSION)
31
32 dnl
33 dnl we extract the numerical version for curl-config only
34 VERSIONNUM=`$SED -ne 's/^#define LIBCURL_VERSION_NUM 0x\(.*\)/\1/p' ${srcdir}/include/curl/curl.h`
35 AC_SUBST(VERSIONNUM)
36
37 dnl Solaris pkgadd support definitions
38 PKGADD_PKG="HAXXcurl"
39 PKGADD_NAME="cURL - a client that groks URLs"
40 PKGADD_VENDOR="curl.haxx.se"
41 AC_SUBST(PKGADD_PKG)
42 AC_SUBST(PKGADD_NAME)
43 AC_SUBST(PKGADD_VENDOR)
44
45
46 dnl
47 dnl Detect the canonical host and target build environment
48 dnl
49
50 AC_CANONICAL_HOST
51 dnl Get system canonical name
52 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
53
54 dnl Check for AIX weirdos
55 AC_AIX
56
57 dnl Checks for programs.
58 AC_PROG_CC
59
60 dnl check for how to do large files
61 AC_SYS_LARGEFILE
62
63 dnl check for cygwin stuff
64 AC_LIBTOOL_WIN32_DLL
65
66 dnl libtool setup
67 AM_PROG_LIBTOOL
68
69 AC_MSG_CHECKING([if we need -no-undefined])
70 case $host in
71   *-*-cygwin | *-*-mingw* | *-*-pw32*)
72     need_no_undefined=yes
73     ;;
74   *)
75     need_no_undefined=no
76     ;;
77 esac
78 AC_MSG_RESULT($need_no_undefined)
79 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
80
81 AC_MSG_CHECKING([if we need -mimpure-text])
82 case $host in
83   *-*-solaris2*)
84     if test "$GCC" = "yes"; then
85       mimpure="yes"
86     fi
87     ;;
88   *)
89     mimpure=no
90     ;;
91 esac
92 AC_MSG_RESULT($mimpure)
93 AM_CONDITIONAL(MIMPURE, test x$mimpure = xyes)
94
95 dnl The install stuff has already been taken care of by the automake stuff
96 dnl AC_PROG_INSTALL
97 AC_PROG_MAKE_SET
98
99 dnl ************************************************************
100 dnl switch off particular protocols
101 dnl
102 AC_MSG_CHECKING([whether to support http])
103 AC_ARG_ENABLE(http,
104 AC_HELP_STRING([--enable-http],[Enable HTTP support])
105 AC_HELP_STRING([--disable-http],[Disable HTTP support]),
106 [ case "$enableval" in
107   no)
108        AC_MSG_RESULT(no)
109        AC_DEFINE(CURL_DISABLE_HTTP, 1, [to disable HTTP])
110        AC_MSG_WARN([disable HTTP disables FTP over proxy and GOPHER too])
111        AC_DEFINE(CURL_DISABLE_GOPHER, 1, [to disable GOPHER])
112        AC_SUBST(CURL_DISABLE_HTTP)
113        AC_SUBST(CURL_DISABLE_GOPHER)
114        ;;
115   *)   AC_MSG_RESULT(yes)
116        ;;
117   esac ],
118        AC_MSG_RESULT(yes)
119 )
120 AC_MSG_CHECKING([whether to support ftp])
121 AC_ARG_ENABLE(ftp,
122 AC_HELP_STRING([--enable-ftp],[Enable FTP support])
123 AC_HELP_STRING([--disable-ftp],[Disable FTP support]),
124 [ case "$enableval" in
125   no)
126        AC_MSG_RESULT(no)
127        AC_DEFINE(CURL_DISABLE_FTP, 1, [to disable FTP])
128        AC_SUBST(CURL_DISABLE_FTP)
129        ;;
130   *)   AC_MSG_RESULT(yes)
131        ;;
132   esac ],
133        AC_MSG_RESULT(yes)
134 )
135 AC_MSG_CHECKING([whether to support gopher])
136 AC_ARG_ENABLE(gopher,
137 AC_HELP_STRING([--enable-gopher],[Enable GOPHER support])
138 AC_HELP_STRING([--disable-gopher],[Disable GOPHER support]),
139 [ case "$enableval" in
140   no)
141        AC_MSG_RESULT(no)
142        AC_DEFINE(CURL_DISABLE_GOPHER, 1, [to disable GOPHER])
143        AC_SUBST(CURL_DISABLE_GOPHER)
144        ;;
145   *)   AC_MSG_RESULT(yes)
146        ;;
147   esac ],
148        AC_MSG_RESULT(yes)
149 )
150 AC_MSG_CHECKING([whether to support file])
151 AC_ARG_ENABLE(file,
152 AC_HELP_STRING([--enable-file],[Enable FILE support])
153 AC_HELP_STRING([--disable-file],[Disable FILE support]),
154 [ case "$enableval" in
155   no)
156        AC_MSG_RESULT(no)
157        AC_DEFINE(CURL_DISABLE_FILE, 1, [to disable FILE])
158        AC_SUBST(CURL_DISABLE_FILE)
159        ;;
160   *)   AC_MSG_RESULT(yes)
161        ;;
162   esac ],
163        AC_MSG_RESULT(yes)
164 )
165 AC_MSG_CHECKING([whether to support ldap])
166 AC_ARG_ENABLE(ldap,
167 AC_HELP_STRING([--enable-ldap],[Enable LDAP support])
168 AC_HELP_STRING([--disable-ldap],[Disable LDAP support]),
169 [ case "$enableval" in
170   no)
171        AC_MSG_RESULT(no)
172        AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
173        AC_SUBST(CURL_DISABLE_LDAP)
174        ;;
175   *)   AC_MSG_RESULT(yes)
176        ;;
177   esac ],
178        AC_MSG_RESULT(yes)
179 )
180 AC_MSG_CHECKING([whether to support dict])
181 AC_ARG_ENABLE(dict,
182 AC_HELP_STRING([--enable-dict],[Enable DICT support])
183 AC_HELP_STRING([--disable-dict],[Disable DICT support]),
184 [ case "$enableval" in
185   no)
186        AC_MSG_RESULT(no)
187        AC_DEFINE(CURL_DISABLE_DICT, 1, [to disable DICT])
188        AC_SUBST(CURL_DISABLE_DICT)
189        ;;
190   *)   AC_MSG_RESULT(yes)
191        ;;
192   esac ],
193        AC_MSG_RESULT(yes)
194 )
195 AC_MSG_CHECKING([whether to support telnet])
196 AC_ARG_ENABLE(telnet,
197 AC_HELP_STRING([--enable-telnet],[Enable TELNET support])
198 AC_HELP_STRING([--disable-telnet],[Disable TELNET support]),
199 [ case "$enableval" in
200   no)
201        AC_MSG_RESULT(no)
202        AC_DEFINE(CURL_DISABLE_TELNET, 1, [to disable TELNET])
203        AC_SUBST(CURL_DISABLE_TELNET)
204        ;;
205   *)   AC_MSG_RESULT(yes)
206        ;;
207   esac ],
208        AC_MSG_RESULT(yes)
209 )
210
211 dnl **********************************************************************
212 dnl Checks for libraries.
213 dnl **********************************************************************
214
215 dnl gethostbyname in the nsl lib?
216 AC_CHECK_FUNC(gethostbyname, , [ AC_CHECK_LIB(nsl, gethostbyname) ])
217
218 if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then
219   dnl gethostbyname in the socket lib?
220   AC_CHECK_FUNC(gethostbyname, , [ AC_CHECK_LIB(socket, gethostbyname) ])
221 fi
222
223 dnl At least one system has been identified to require BOTH nsl and
224 dnl socket libs to link properly.
225 if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_lib_socket_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then
226   AC_MSG_CHECKING([trying both nsl and socket libs])
227   my_ac_save_LIBS=$LIBS
228   LIBS="-lnsl -lsocket $LIBS"
229   AC_TRY_LINK( ,
230              [gethostbyname();],
231              my_ac_link_result=success,
232              my_ac_link_result=failure )
233
234   if test "$my_ac_link_result" = "failure"; then
235     AC_MSG_RESULT([no])
236     AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
237     dnl restore LIBS
238     LIBS=$my_ac_save_LIBS
239   else
240     AC_MSG_RESULT([yes])
241   fi
242 fi
243
244 dnl resolve lib?
245 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
246
247 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
248   AC_CHECK_LIB(resolve, strcasecmp,
249               [LIBS="-lresolve $LIBS"],
250                ,
251                -lnsl)
252 fi
253
254 dnl socket lib?
255 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
256
257 dnl dl lib?
258 AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
259
260 AC_MSG_CHECKING([whether to use libgcc])
261 AC_ARG_ENABLE(libgcc,
262 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
263 [ case "$enableval" in
264   yes)
265         LIBS="$LIBS -lgcc"
266        AC_MSG_RESULT(yes)
267        ;;
268   *)   AC_MSG_RESULT(no)
269        ;;
270   esac ],
271        AC_MSG_RESULT(no)
272 )
273
274 dnl **********************************************************************
275 dnl Checks for IPv6
276 dnl **********************************************************************
277
278 AC_MSG_CHECKING([whether to enable ipv6])
279 AC_ARG_ENABLE(ipv6,
280 AC_HELP_STRING([--enable-ipv6],[Enable ipv6 (with ipv4) support])
281 AC_HELP_STRING([--disable-ipv6],[Disable ipv6 support]),
282 [ case "$enableval" in
283   no)
284        AC_MSG_RESULT(no)
285        ipv6=no
286        ;;
287   *)   AC_MSG_RESULT(yes)
288        ipv6=yes
289        ;;
290   esac ],
291
292   AC_TRY_RUN([ /* is AF_INET6 available? */
293 #include <sys/types.h>
294 #include <sys/socket.h>
295 main()
296 {
297  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
298    exit(1);
299  else
300    exit(0);
301 }
302 ],
303   AC_MSG_RESULT(yes)
304   ipv6=yes,
305   AC_MSG_RESULT(no)
306   ipv6=no,
307   AC_MSG_RESULT(no)
308   ipv6=no
309 ))
310
311 if test "$ipv6" = "yes"; then
312   CURL_CHECK_WORKING_GETADDRINFO
313 fi
314
315 dnl **********************************************************************
316 dnl Check how non-blocking sockets are set
317 dnl **********************************************************************
318 AC_ARG_ENABLE(nonblocking,
319 AC_HELP_STRING([--enable-nonblocking],[Enable detecting how to do it])
320 AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking socket detection]),
321 [
322   if test "$enableval" = "no" ; then
323     AC_MSG_WARN([non-blocking sockets disabled])
324     AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
325     [to disable NON-BLOCKING connections])
326   else
327     CURL_CHECK_NONBLOCKING_SOCKET
328   fi
329 ],
330 [
331   CURL_CHECK_NONBLOCKING_SOCKET
332 ])
333
334 dnl **********************************************************************
335 dnl Check for the random seed preferences 
336 dnl **********************************************************************
337
338 AC_ARG_WITH(egd-socket,
339 AC_HELP_STRING([--with-egd-socket=FILE],
340                [Entropy Gathering Daemon socket pathname]),
341     [ EGD_SOCKET="$withval" ]
342 )
343 if test -n "$EGD_SOCKET" ; then
344         AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET",
345         [your Entropy Gathering Daemon socket pathname] )
346 fi
347
348 dnl Check for user-specified random device
349 AC_ARG_WITH(random,
350 AC_HELP_STRING([--with-random=FILE],[read randomness from FILE (default=/dev/urandom)]),
351     [ RANDOM_FILE="$withval" ],
352     [
353         dnl Check for random device
354         AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
355     ]
356 )
357 if test -n "$RANDOM_FILE" ; then
358         AC_SUBST(RANDOM_FILE)
359         AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
360         [a suitable file to read random data from])
361 fi
362
363 dnl **********************************************************************
364 dnl Check if the operating system allows programs to write to their own argv[]
365 dnl **********************************************************************
366
367 AC_MSG_CHECKING([if argv can be written to])
368 AC_CACHE_VAL(curl_cv_writable_argv, [
369 AC_RUN_IFELSE([[
370 int main(int argc, char ** argv) {
371         argv[0][0] = ' ';
372         return (argv[0][0] == ' ')?0:1;
373 }
374         ]],
375         curl_cv_writable_argv=yes,
376         curl_cv_writable_argv=no,
377         curl_cv_writable_argv=cross)
378 ])
379 case $curl_cv_writable_argv in
380 yes)
381         AC_DEFINE(HAVE_WRITABLE_ARGV, 1, [Define this symbol if your OS supports changing the contents of argv])
382         AC_MSG_RESULT(yes)
383         ;;
384 no)
385         AC_MSG_RESULT(no)
386         ;;
387 *)
388         AC_MSG_RESULT(no)
389         AC_MSG_WARN([the previous check could not be made default was used])
390         ;;
391 esac
392
393 dnl **********************************************************************
394 dnl Check for the presence of Kerberos4 libraries and headers
395 dnl **********************************************************************
396
397 AC_ARG_WITH(krb4-includes,
398 AC_HELP_STRING([--with-krb4-includes=DIR],
399                [Specify location of kerberos4 headers]),[
400  CPPFLAGS="$CPPFLAGS -I$withval"
401  KRB4INC="$withval"
402  want_krb4=yes
403  ])
404
405 AC_ARG_WITH(krb4-libs,
406 AC_HELP_STRING([--with-krb4-libs=DIR],[Specify location of kerberos4 libs]),[
407  LDFLAGS="$LDFLAGS -L$withval"
408  KRB4LIB="$withval"
409  want_krb4=yes
410  ])
411
412
413 OPT_KRB4=off
414 AC_ARG_WITH(krb4,dnl
415 AC_HELP_STRING([--with-krb4=DIR],[where to look for Kerberos4]),[
416   OPT_KRB4="$withval"
417   if test X"$OPT_KRB4" != Xyes
418   then
419     LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib"
420     KRB4LIB="$OPT_KRB4/lib"
421     CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
422     KRB4INC="$OPT_KRB4/include"
423   fi
424   want_krb4="yes"
425  ])
426
427 AC_MSG_CHECKING([if Kerberos4 support is requested])
428
429 if test "$want_krb4" = yes
430 then
431   if test "$ipv6" = "yes"; then
432     echo krb4 is not compatible with IPv6
433     exit 1
434   fi
435   AC_MSG_RESULT(yes)
436
437   dnl Check for & handle argument to --with-krb4
438
439   AC_MSG_CHECKING(where to look for Kerberos4)
440   if test X"$OPT_KRB4" = Xyes
441   then
442     AC_MSG_RESULT([defaults])
443   else
444     AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
445   fi
446
447   dnl Check for DES library
448   AC_CHECK_LIB(des, des_pcbc_encrypt,
449   [
450     AC_CHECK_HEADERS(des.h)
451
452     dnl resolv lib?
453     AC_CHECK_FUNC(res_search, , [AC_CHECK_LIB(resolv, res_search)])
454
455     dnl Check for the Kerberos4 library
456     AC_CHECK_LIB(krb, krb_net_read,
457     [
458       dnl Check for header files
459       AC_CHECK_HEADERS(krb.h)
460
461       dnl we found the required libraries, add to LIBS
462       LIBS="-lkrb -ldes $LIBS"
463
464       dnl Check for function krb_get_our_ip_for_realm
465       dnl this is needed for NAT networks
466       AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
467
468       dnl add define KRB4
469       AC_DEFINE(HAVE_KRB4, 1,
470       [if you have the Kerberos4 libraries (including -ldes)])
471
472       dnl substitute it too!
473       KRB4_ENABLED=1
474       AC_SUBST(KRB4_ENABLED)
475
476       dnl the krb4 stuff needs a strlcpy()
477       AC_CHECK_FUNCS(strlcpy)
478
479     ])
480   ])
481 else
482   AC_MSG_RESULT(no)
483 fi
484
485 dnl **********************************************************************
486 dnl Check for FBopenssl(SPNEGO) libraries
487 dnl **********************************************************************
488
489 AC_ARG_WITH(spnego,
490   AC_HELP_STRING([--with-spnego=DIR],
491                  [Specify location of SPNEGO library fbopenssl]),
492   [ SPNEGO_ROOT="$withval"
493     want_spnego="yes" ]
494 )
495 AC_MSG_CHECKING([if SPNEGO support is requested])
496 if test x"$want_spnego" = xyes; then
497
498   if test X"$SPNEGO_ROOT" = Xyes; then
499      AC_MSG_ERROR([FBOpenSSL libs and/or directories were not found where specified!])
500      AC_MSG_RESULT(no)
501   else
502      if test -z "$SPNEGO_LIB_DIR"; then
503         LDFLAGS="$LDFLAGS -L$SPNEGO_ROOT ${wl}-R$SPNEGO_ROOT -lfbopenssl"
504      else
505         LDFLAGS="$LDFLAGS $SPNEGO_LIB_DIR"
506      fi
507  
508      AC_MSG_RESULT(yes)
509      AC_DEFINE(HAVE_SPNEGO, 1, [Define this if you have the SPNEGO library fbopenssl])
510   fi
511 else
512   AC_MSG_RESULT(no)
513 fi
514
515 dnl **********************************************************************
516 dnl Check for GSS-API libraries
517 dnl **********************************************************************
518
519 AC_ARG_WITH(gssapi-includes,
520   AC_HELP_STRING([--with-gssapi-includes=DIR],
521                  [Specify location of GSSAPI header]),
522   [ GSSAPI_INCS="-I$withval" 
523     want_gss="yes" ]
524 )
525
526 AC_ARG_WITH(gssapi-libs,
527   AC_HELP_STRING([--with-gssapi-libs=DIR],
528                  [Specify location of GSSAPI libs]),
529   [ GSSAPI_LIBS="-L$withval -lgssapi"
530     want_gss="yes" ]
531 )
532
533 AC_ARG_WITH(gssapi,
534   AC_HELP_STRING([--with-gssapi=DIR],
535                  [Where to look for GSSAPI]),
536   [ GSSAPI_ROOT="$withval"
537     want_gss="yes" ]
538 )
539
540 AC_MSG_CHECKING([if GSSAPI support is requested])
541 if test x"$want_gss" = xyes; then
542   if test -z "$GSSAPI_INCS"; then
543      if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
544         GSSAPI_INCS=`$GSSAPI_ROOT/bin/krb5-config --cflags gssapi`
545      else
546         GSSAPI_INCS=="-I$GSSAPI_ROOT/include"
547      fi
548   fi
549   CPPFLAGS="$CPPFLAGS $GSSAPI_INCS"
550   
551   if test -z "$GSSAPI_LIB_DIR"; then
552      if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
553         gss_ldflags=`$GSSAPI_ROOT/bin/krb5-config --libs gssapi`
554         LDFLAGS="$LDFLAGS $gss_ldflags"
555      else
556         LDFLAGS="$LDFLAGS $GSSAPI_ROOT/lib -lgssapi"
557      fi
558   else
559      LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
560   fi
561
562   AC_MSG_RESULT(yes)
563   AC_DEFINE(HAVE_GSSAPI, 1, [if you have the gssapi libraries])
564
565   if test -n "$GSSAPI_INCS"; then
566     # cut off the preceding -I from the include path
567     GSSAPI_INCS=`echo $GSSAPI_INCS | sed -e s/^-I//g`
568   fi
569
570   if test -f "$GSSAPI_INCS/gssapi.h"; then
571       AC_DEFINE(HAVE_GSSHEIMDAL, 1, [if you have the Heimdal gssapi libraries])
572   else
573       AC_DEFINE(HAVE_GSSMIT, 1, [if you have the MIT gssapi libraries])
574   fi
575   
576 else
577   AC_MSG_RESULT(no)
578 fi
579   
580
581 dnl Detect the pkg-config tool, as it may have extra info about the
582 dnl openssl installation we can use. I *believe* this is what we are
583 dnl expected to do on really recent Redhat Linux hosts.
584 AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
585 if test "$PKGCONFIG" != "no" ; then
586   AC_MSG_CHECKING([for OpenSSL options using pkg-config])
587
588   $PKGCONFIG --exists openssl
589   SSL_EXISTS=$?
590
591   if test "$SSL_EXISTS" -eq "0"; then
592     SSL_LIBS=`$PKGCONFIG --libs-only-l openssl 2>/dev/null`
593     SSL_LDFLAGS=`$PKGCONFIG --libs-only-L openssl 2>/dev/null`
594     SSL_CPPFLAGS=`$PKGCONFIG --cflags-only-I openssl 2>/dev/null`
595
596     LIBS="$LIBS $SSL_LIBS"
597     CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
598     LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
599
600     AC_MSG_RESULT([yes])
601   else
602     AC_MSG_RESULT([no])
603   fi
604
605 fi
606
607 dnl **********************************************************************
608 dnl Check for the presence of SSL libraries and headers
609 dnl **********************************************************************
610
611 dnl Default to compiler & linker defaults for SSL files & libraries.
612 OPT_SSL=off
613 dnl Default to no CA bundle
614 ca="no"
615 AC_ARG_WITH(ssl,dnl
616 AC_HELP_STRING([--with-ssl=PATH],[where to look for SSL, PATH points to the SSL installation (default: /usr/local/ssl)])
617 AC_HELP_STRING([--without-ssl], [disable SSL]),
618   OPT_SSL=$withval)
619
620 if test X"$OPT_SSL" = Xno
621 then
622   AC_MSG_WARN(SSL/https support disabled)  
623 else
624
625   dnl Check for and handle argument to --with-ssl.
626
627   dnl save the pre-ssl check flags for a while
628   CLEANLDFLAGS="$LDFLAGS"
629   CLEANCPPFLAGS="$CPPFLAGS"
630
631   case "$OPT_SSL" in
632   yes)
633     EXTRA_SSL=/usr/local/ssl ;;
634   off)
635     EXTRA_SSL= ;;
636   *)
637     dnl check the given spot right away!
638     EXTRA_SSL=$OPT_SSL
639     LDFLAGS="$LDFLAGS -L$EXTRA_SSL/lib"
640     CPPFLAGS="$CPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
641     ;;
642   esac
643
644   AC_CHECK_LIB(crypto, CRYPTO_lock,[
645      HAVECRYPTO="yes"
646      ],[
647      OLDLDFLAGS="$LDFLAGS"
648      OLDCPPFLAGS="$CPPFLAGS"
649      LDFLAGS="$CLEANLDFLAGS -L$EXTRA_SSL/lib"
650      CPPFLAGS="$CLEANCPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
651      AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
652        HAVECRYPTO="yes" ], [
653        LDFLAGS="$OLDLDFLAGS"
654        CPPFLAGS="$OLDCPPFLAGS"
655        ])
656     ])
657
658
659   if test "$HAVECRYPTO" = "yes"; then
660     dnl This is only reasonable to do if crypto actually is there: check for
661     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
662
663     AC_CHECK_LIB(crypto, CRYPTO_add_lock)
664     AC_CHECK_LIB(ssl, SSL_connect)
665
666     if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
667         dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
668         AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
669         OLIBS=$LIBS
670         LIBS="$LIBS -lRSAglue -lrsaref"
671         AC_CHECK_LIB(ssl, SSL_connect)
672         if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
673             dnl still no SSL_connect
674             AC_MSG_RESULT(no)
675             LIBS=$OLIBS
676         else
677             AC_MSG_RESULT(yes)
678         fi
679     fi
680
681
682     dnl Check for SSLeay headers
683     AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
684                      openssl/pem.h openssl/ssl.h openssl/err.h,
685       OPENSSL_ENABLED=1)
686
687     if test $ac_cv_header_openssl_x509_h = no; then
688       AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h,
689         OPENSSL_ENABLED=1)
690     fi
691
692     dnl If the ENGINE library seems to be around, check for the OpenSSL engine
693     dnl header, it is kind of "separated" from the main SSL check
694     AC_CHECK_FUNC(ENGINE_init, [ AC_CHECK_HEADERS(openssl/engine.h) ])
695
696     AC_SUBST(OPENSSL_ENABLED)
697
698     AC_MSG_CHECKING([CA cert bundle install path])
699
700     AC_ARG_WITH(ca-bundle,
701 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to install the CA bundle as])
702 AC_HELP_STRING([--without-ca-bundle], [Don't install the CA bundle]),
703     [ ca="$withval" ],
704     [
705       if test "x$prefix" != xNONE; then
706         ca="\${prefix}/share/curl/curl-ca-bundle.crt"
707       else
708         ca="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
709       fi
710     ] )
711
712     if test X"$OPT_SSL" = Xno; then
713       ca="no"
714     fi
715
716     if test "x$ca" != "xno"; then
717       CURL_CA_BUNDLE='"'$ca'"'
718       AC_SUBST(CURL_CA_BUNDLE)  
719     fi
720     AC_MSG_RESULT([$ca])
721
722     dnl these can only exist if openssl exists
723
724     AC_CHECK_FUNCS( RAND_status \
725                     RAND_screen \
726                     RAND_egd \
727                     CRYPTO_cleanup_all_ex_data )
728
729   fi
730
731   if test X"$OPT_SSL" != Xoff &&
732      test "$OPENSSL_ENABLED" != "1"; then
733     AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
734   fi
735
736 fi
737
738 AM_CONDITIONAL(CABUNDLE, test x$ca != xno)
739
740 dnl **********************************************************************
741 dnl Check for the presence of ZLIB libraries and headers
742 dnl **********************************************************************
743
744 dnl Check for & handle argument to --with-zlib.
745
746 _cppflags=$CPPFLAGS
747 _ldflags=$LDFLAGS
748 OPT_ZLIB="/usr/local"
749 AC_ARG_WITH(zlib,
750 AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH])
751 AC_HELP_STRING([--without-zlib],[disable use of zlib]),
752                [OPT_ZLIB="$withval"])
753
754 case "$OPT_ZLIB" in
755   no)
756     AC_MSG_WARN([zlib disabled]) ;;
757   *)
758     dnl check for the lib first without setting any new path, since many
759     dnl people have it in the default path
760
761     AC_CHECK_LIB(z, inflateEnd, ,
762                    [if test -d "$OPT_ZLIB"; then
763                       CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
764                       LDFLAGS="$LDFLAGS -L$OPT_ZLIB/lib"
765                    fi])
766
767     AC_CHECK_HEADER(zlib.h,[
768       AC_CHECK_LIB(z, gzread,
769                    [HAVE_LIBZ="1"
770                    AC_SUBST(HAVE_LIBZ)
771                    LIBS="$LIBS -lz"
772                    AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
773                    AC_DEFINE(HAVE_LIBZ, 1, [If zlib is available])],
774                    [ CPPFLAGS=$_cppflags
775                    LDFLAGS=$_ldflags])],
776       [ CPPFLAGS=$_cppflags
777       LDFLAGS=$_ldflags]
778     )
779     ;;
780 esac
781
782 dnl set variable for use in automakefile(s)
783 AM_CONDITIONAL(HAVE_LIBZ, test x"$HAVE_LIBZ" = x1)
784
785 dnl Default is to try the thread-safe versions of a few functions
786 OPT_THREAD=on
787
788 dnl detect AIX 4.3 or later
789 dnl see full docs on this reasoning in the lib/hostip.c source file
790 AC_MSG_CHECKING([AIX 4.3 or later])
791 AC_PREPROC_IFELSE([
792 #if defined(_AIX) && defined(_AIX43)
793 printf("just fine");
794 #else
795 #error "this is not AIX 4.3 or later"
796 #endif
797 ],
798  [ AC_MSG_RESULT([yes])
799    OPT_THREAD=off ],
800  [ AC_MSG_RESULT([no]) ]
801 )
802
803 AC_ARG_ENABLE(thread,dnl
804 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
805 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
806 [ case "$enableval" in
807   no)
808     OPT_THREAD=off
809     AC_MSG_WARN(libcurl will not get built using thread-safe functions)
810     ;;
811   *)
812     ;;
813   esac
814 ]
815 )
816
817 if test X"$OPT_THREAD" = Xoff
818 then
819   AC_DEFINE(DISABLED_THREADSAFE, 1, \
820 Set to explicitly specify we don't want to use thread-safe functions)
821 else
822
823   dnl dig around for gethostbyname_r()
824   CURL_CHECK_GETHOSTBYNAME_R()
825
826   dnl dig around for gethostbyaddr_r()
827   CURL_CHECK_GETHOSTBYADDR_R()
828
829   dnl poke around for inet_ntoa_r()
830   CURL_CHECK_INET_NTOA_R()
831
832   dnl is there a localtime_r()
833   CURL_CHECK_LOCALTIME_R()
834
835   AC_CHECK_FUNCS( gmtime_r )
836
837 fi
838
839 dnl **********************************************************************
840 dnl Back to "normal" configuring
841 dnl **********************************************************************
842
843 dnl Checks for header files.
844 AC_HEADER_STDC
845
846 dnl First check for the very most basic headers. Then we can use these
847 dnl ones as default-headers when checking for the rest!
848 AC_CHECK_HEADERS(
849         sys/types.h \
850         sys/time.h \
851         sys/select.h \
852         sys/socket.h \
853         unistd.h \
854         malloc.h \
855         stdlib.h \
856         arpa/inet.h \
857         net/if.h \
858         netinet/in.h \
859         netdb.h \
860         sys/sockio.h \
861         sys/stat.h \
862         sys/param.h \
863         termios.h \
864         termio.h \
865         sgtty.h \
866         fcntl.h \
867         dlfcn.h \
868         alloca.h \
869         winsock.h \
870         time.h \
871         io.h \
872         pwd.h \
873         utime.h \
874         sys/utime.h \
875         sys/poll.h \
876         setjmp.h,
877 dnl to do if not found
878 [],
879 dnl to do if found
880 [],
881 dnl default includes
882 [
883 #ifdef HAVE_SYS_TYPES_H
884 #include <sys/types.h>
885 #endif
886 #ifdef HAVE_SYS_TIME_H
887 #include <sys/time.h>
888 #endif
889 #ifdef HAVE_SYS_SELECT_H
890 #include <sys/select.h>
891 #endif
892 #ifdef HAVE_SYS_SOCKET_H
893 #include <sys/socket.h>
894 #endif
895 ]
896 )
897
898 dnl Checks for typedefs, structures, and compiler characteristics.
899 AC_C_CONST
900 AC_TYPE_SIZE_T
901 AC_HEADER_TIME
902
903 AC_CHECK_SIZEOF(off_t)
904
905 AC_CHECK_TYPE(long long,
906    [AC_DEFINE(HAVE_LONGLONG, 1, [if your compiler supports 'long long'])])
907
908 # check for ssize_t
909 AC_CHECK_TYPE(ssize_t, ,
910    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
911
912 TYPE_SOCKLEN_T
913 TYPE_IN_ADDR_T
914
915 AC_FUNC_SELECT_ARGTYPES
916
917 dnl Checks for library functions.
918 dnl AC_PROG_GCC_TRADITIONAL
919 AC_TYPE_SIGNAL
920 dnl AC_FUNC_VPRINTF
921 AC_CHECK_FUNCS( socket \
922                 select \
923                 strdup \
924                 strstr \
925                 strtok_r \
926                 strftime \
927                 uname \
928                 strcasecmp \
929                 stricmp \
930                 strcmpi \
931                 gethostbyaddr \
932                 gettimeofday \
933                 inet_addr \
934                 inet_ntoa \
935                 inet_pton \
936                 tcsetattr \
937                 tcgetattr \
938                 perror \
939                 closesocket \
940                 siginterrupt \
941                 sigaction \
942                 signal \
943                 getpass_r \
944                 strlcat \
945                 getpwuid \
946                 geteuid \
947                 dlopen \
948                 utime \
949                 sigsetjmp \
950                 poll,
951 dnl if found
952 [],
953 dnl if not found, $ac_func is the name we check for
954   func="$ac_func"
955   AC_MSG_CHECKING([deeper for $func])
956   AC_TRY_LINK( [],
957                [ $func ();],
958                AC_MSG_RESULT(yes!)
959                eval "ac_cv_func_$func=yes"
960                def=`echo "HAVE_$func" | tr 'a-z' 'A-Z'`
961                AC_DEFINE_UNQUOTED($def, 1, [If you have $func]),
962                AC_MSG_RESULT(but still no)
963                )
964
965 )
966
967 dnl sigsetjmp() might be a macro and no function so if it isn't found already
968 dnl we make an extra check here!
969 if test "$ac_cv_func_sigsetjmp" != "yes"; then
970   AC_MSG_CHECKING([for sigsetjmp defined as macro])
971   AC_TRY_LINK( [#include <setjmp.h>],
972                [sigjmp_buf jmpenv;
973                 sigsetjmp(jmpenv, 1);],
974                AC_MSG_RESULT(yes)
975                AC_DEFINE(HAVE_SIGSETJMP, 1, [If you have sigsetjmp]),
976                AC_MSG_RESULT(no)
977                )
978 fi
979
980 AC_PATH_PROG( PERL, perl, , 
981   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
982 AC_SUBST(PERL)
983
984 AC_PATH_PROGS( NROFF, gnroff nroff, , 
985   $PATH:/usr/bin/:/usr/local/bin )
986 AC_SUBST(NROFF)
987
988 AC_PROG_YACC
989
990 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib, 
991 dnl   $PATH:/usr/bin/:/usr/local/bin )
992 dnl AC_SUBST(RANLIB)
993
994 dnl ************************************************************
995 dnl lame option to switch on debug options
996 dnl
997 AC_MSG_CHECKING([whether to enable debug options])
998 AC_ARG_ENABLE(debug,
999 AC_HELP_STRING([--enable-debug],[Enable pedantic debug options])
1000 AC_HELP_STRING([--disable-debug],[Disable debug options]),
1001 [ case "$enableval" in
1002   no)
1003        AC_MSG_RESULT(no)
1004        ;;
1005   *)   AC_MSG_RESULT(yes)
1006
1007     CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
1008     CFLAGS="$CFLAGS -g" 
1009     if test "$GCC" = "yes"; then
1010        CFLAGS="$CFLAGS -W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs"
1011     fi
1012     dnl strip off optimizer flags
1013     NEWFLAGS=""
1014     for flag in $CFLAGS; do
1015       case "$flag" in
1016       -O*)
1017         dnl echo "cut off $flag"
1018         ;;
1019       *)
1020         NEWFLAGS="$NEWFLAGS $flag"
1021         ;;
1022       esac
1023     done
1024     CFLAGS=$NEWFLAGS
1025        ;;
1026   esac ],
1027        AC_MSG_RESULT(no)
1028 )
1029
1030 ares="no"
1031 AC_MSG_CHECKING([whether to enable ares])
1032 AC_ARG_ENABLE(ares,
1033 AC_HELP_STRING([--enable-ares],[Enable using ares for name lookups])
1034 AC_HELP_STRING([--disable-ares],[Disable using ares for name lookups]),
1035 [ case "$enableval" in
1036   no)
1037        AC_MSG_RESULT(no)
1038        ;;
1039   *)   AC_MSG_RESULT(yes)
1040
1041        if test "x$IPV6_ENABLED" = "x1"; then
1042          AC_MSG_ERROR([ares doesn't work with ipv6, disable ipv6 to use ares])
1043        fi
1044
1045        AC_DEFINE(USE_ARES, 1, [Define if you want to enable ares support])
1046
1047        ares="yes"
1048        ;;
1049   esac ],
1050        AC_MSG_RESULT(no)
1051 )
1052
1053 AM_CONDITIONAL(ARES, test x$ares = xyes)
1054
1055 AC_CONFIG_FILES([Makefile \
1056            docs/Makefile \
1057            docs/examples/Makefile \
1058            docs/libcurl/Makefile \
1059            include/Makefile \
1060            include/curl/Makefile \
1061            src/Makefile \
1062            lib/Makefile \
1063            tests/Makefile \
1064            tests/data/Makefile \
1065            tests/server/Makefile \
1066            tests/libtest/Makefile \
1067            packages/Makefile \
1068            packages/Win32/Makefile \
1069            packages/Win32/cygwin/Makefile \
1070            packages/Linux/Makefile \
1071            packages/Linux/RPM/Makefile \
1072            packages/Linux/RPM/curl.spec \
1073            packages/Linux/RPM/curl-ssl.spec \
1074            packages/Solaris/Makefile \
1075            packages/DOS/Makefile \
1076            packages/EPM/curl.list \
1077            packages/EPM/Makefile \
1078            curl-config
1079 ])
1080 AC_OUTPUT