OpenSSL: check for the SSLv2 function in configure
[platform/upstream/curl.git] / configure.ac
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
9 #
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
13 #
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 #***************************************************************************
22 dnl Process this file with autoconf to produce a configure script.
23
24 AC_PREREQ(2.57)
25
26 dnl We don't know the version number "statically" so we use a dash here
27 AC_INIT([curl], [-], [a suitable curl mailing list: http://curl.haxx.se/mail/])
28
29 CURL_OVERRIDE_AUTOCONF
30
31 dnl configure script copyright
32 AC_COPYRIGHT([Copyright (c) 1998 - 2011 Daniel Stenberg, <daniel@haxx.se>
33 This configure script may be copied, distributed and modified under the
34 terms of the curl license; see COPYING for more details])
35
36 AC_CONFIG_SRCDIR([lib/urldata.h])
37 AM_CONFIG_HEADER(lib/curl_config.h src/curl_config.h include/curl/curlbuild.h)
38 AC_CONFIG_MACRO_DIR([m4])
39 AM_MAINTAINER_MODE
40
41 CURL_CHECK_OPTION_DEBUG
42 CURL_CHECK_OPTION_OPTIMIZE
43 CURL_CHECK_OPTION_WARNINGS
44 CURL_CHECK_OPTION_WERROR
45 CURL_CHECK_OPTION_CURLDEBUG
46 CURL_CHECK_OPTION_ARES
47
48 CURL_CHECK_PATH_SEPARATOR_REQUIRED
49
50 #
51 # save the configure arguments
52 #
53 CONFIGURE_OPTIONS="\"$ac_configure_args\""
54 AC_SUBST(CONFIGURE_OPTIONS)
55
56 CURL_CFLAG_EXTRAS=""
57 if test X"$want_werror" = Xyes; then
58   CURL_CFLAG_EXTRAS="-Werror"
59 fi
60 AC_SUBST(CURL_CFLAG_EXTRAS)
61
62 dnl SED is mandatory for configure process and libtool.
63 dnl Set it now, allowing it to be changed later.
64 if test -z "$SED"; then
65   dnl allow it to be overridden
66   AC_PATH_PROG([SED], [sed], [not_found],
67     [$PATH:/usr/bin:/usr/local/bin])
68   if test -z "$SED" || test "$SED" = "not_found"; then
69     AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
70   fi
71 fi
72 AC_SUBST([SED])
73
74 dnl GREP is mandatory for configure process and libtool.
75 dnl Set it now, allowing it to be changed later.
76 if test -z "$GREP"; then
77   dnl allow it to be overridden
78   AC_PATH_PROG([GREP], [grep], [not_found],
79     [$PATH:/usr/bin:/usr/local/bin])
80   if test -z "$GREP" || test "$GREP" = "not_found"; then
81     AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
82   fi
83 fi
84 AC_SUBST([GREP])
85
86 dnl EGREP is mandatory for configure process and libtool.
87 dnl Set it now, allowing it to be changed later.
88 if test -z "$EGREP"; then
89   dnl allow it to be overridden
90   if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
91     AC_MSG_CHECKING([for egrep])
92     EGREP="$GREP -E"
93     AC_MSG_RESULT([$EGREP])
94   else
95     AC_PATH_PROG([EGREP], [egrep], [not_found],
96       [$PATH:/usr/bin:/usr/local/bin])
97   fi
98 fi
99 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
100   AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
101 fi
102 AC_SUBST([EGREP])
103
104 dnl AR is mandatory for configure process and libtool.
105 dnl This is target dependent, so check it as a tool.
106 if test -z "$AR"; then
107   dnl allow it to be overridden
108   AC_PATH_TOOL([AR], [ar], [not_found],
109     [$PATH:/usr/bin:/usr/local/bin])
110   if test -z "$AR" || test "$AR" = "not_found"; then
111     AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
112   fi
113 fi
114 AC_SUBST([AR])
115
116 AC_SUBST(libext)
117
118 dnl Remove non-configure distributed curlbuild.h
119 if test -f ${srcdir}/include/curl/curlbuild.h; then
120   rm -f ${srcdir}/include/curl/curlbuild.h
121 fi
122
123 dnl figure out the libcurl version
124 CURLVERSION=`$SED -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curlver.h`
125 AM_INIT_AUTOMAKE
126 AC_MSG_CHECKING([curl version])
127 AC_MSG_RESULT($CURLVERSION)
128
129 AC_SUBST(CURLVERSION)
130
131 dnl
132 dnl we extract the numerical version for curl-config only
133 VERSIONNUM=`$SED -ne 's/^#define LIBCURL_VERSION_NUM 0x\(.*\)/\1/p' ${srcdir}/include/curl/curlver.h`
134 AC_SUBST(VERSIONNUM)
135
136 dnl Solaris pkgadd support definitions
137 PKGADD_PKG="HAXXcurl"
138 PKGADD_NAME="cURL - a client that groks URLs"
139 PKGADD_VENDOR="curl.haxx.se"
140 AC_SUBST(PKGADD_PKG)
141 AC_SUBST(PKGADD_NAME)
142 AC_SUBST(PKGADD_VENDOR)
143
144 dnl
145 dnl initialize all the info variables
146     curl_ssl_msg="no      (--with-{ssl,gnutls,nss,polarssl,cyassl,axtls} )"
147     curl_ssh_msg="no      (--with-libssh2)"
148    curl_zlib_msg="no      (--with-zlib)"
149    curl_krb4_msg="no      (--with-krb4*)"
150     curl_gss_msg="no      (--with-gssapi)"
151  curl_spnego_msg="no      (--with-spnego)"
152 curl_tls_srp_msg="no      (--enable-tls-srp)"
153     curl_res_msg="default (--enable-ares / --enable-threaded-resolver)"
154    curl_ipv6_msg="no      (--enable-ipv6)"
155     curl_idn_msg="no      (--with-libidn)"
156  curl_manual_msg="no      (--enable-manual)"
157 curl_verbose_msg="enabled (--disable-verbose)"
158    curl_sspi_msg="no      (--enable-sspi)"
159    curl_ldap_msg="no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)"
160   curl_ldaps_msg="no      (--enable-ldaps)"
161    curl_rtsp_msg="no      (--enable-rtsp)"
162    curl_rtmp_msg="no      (--with-librtmp)"
163     init_ssl_msg=${curl_ssl_msg}
164
165 dnl
166 dnl Save anything in $LIBS for later
167 dnl
168 ALL_LIBS=$LIBS
169
170 dnl
171 dnl Detect the canonical host and target build environment
172 dnl
173
174 AC_CANONICAL_HOST
175 dnl Get system canonical name
176 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
177
178 dnl Checks for programs.
179 CURL_CHECK_PROG_CC
180
181 dnl Our curl_off_t internal and external configure settings
182 CURL_CONFIGURE_CURL_OFF_T
183
184 dnl This defines _ALL_SOURCE for AIX
185 CURL_CHECK_AIX_ALL_SOURCE
186
187 dnl Our configure and build reentrant settings
188 CURL_CONFIGURE_THREAD_SAFE
189 CURL_CONFIGURE_REENTRANT
190
191 dnl check for how to do large files
192 AC_SYS_LARGEFILE
193
194 dnl support building of Windows DLLs
195 AC_LIBTOOL_WIN32_DLL
196
197 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
198 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
199 case $host in
200   x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
201     AC_MSG_RESULT([yes])
202     with_pic=yes
203     ;;
204   *)
205     AC_MSG_RESULT([no])
206     ;;
207 esac
208
209 AC_MSG_CHECKING([if compiler is icc (to build with PIC)])
210 case $CC in
211   icc | */icc)
212     AC_MSG_RESULT([yes])
213     with_pic=yes
214     ;;
215   *)
216     AC_MSG_RESULT([no])
217     ;;
218 esac
219
220 dnl libtool setup
221 AC_PROG_LIBTOOL
222
223 AC_MSG_CHECKING([if we need -mimpure-text])
224 mimpure=no
225 case $host in
226   *-*-solaris2*)
227     if test "$GCC" = "yes"; then
228       mimpure="yes"
229     fi
230     ;;
231   *)
232     ;;
233 esac
234 AC_MSG_RESULT($mimpure)
235 AM_CONDITIONAL(MIMPURE, test x$mimpure = xyes)
236
237 dnl 'STATICLIB' is, in spite of its name, not generic but only for static-only
238 dnl builds on Windows
239 AM_CONDITIONAL(STATICLIB, false)
240
241 AC_MSG_CHECKING([if we need BUILDING_LIBCURL])
242 case $host in
243   *-*-mingw*)
244     AC_DEFINE(BUILDING_LIBCURL, 1, [when building libcurl itself])
245     AC_MSG_RESULT(yes)
246     AC_MSG_CHECKING([if we need CURL_STATICLIB])
247     if test "X$enable_shared" = "Xno"
248     then
249       AC_DEFINE(CURL_STATICLIB, 1, [when not building a shared library])
250       AC_MSG_RESULT(yes)
251       AM_CONDITIONAL(STATICLIB, true)
252     else
253       AC_MSG_RESULT(no)
254     fi
255     ;;
256   *)
257     AC_MSG_RESULT(no)
258     ;;
259 esac
260
261 # Determine whether all dependent libraries must be specified when linking
262 if test "X$enable_shared" = "Xyes" -a "X$link_all_deplibs" = "Xno"
263 then
264     REQUIRE_LIB_DEPS=no
265 else
266     REQUIRE_LIB_DEPS=yes
267 fi
268 AC_SUBST(REQUIRE_LIB_DEPS)
269
270 dnl The install stuff has already been taken care of by the automake stuff
271 dnl AC_PROG_INSTALL
272 AC_PROG_MAKE_SET
273
274 dnl check if there's a way to force code inline
275 AC_C_INLINE
276
277 dnl **********************************************************************
278 dnl platform/compiler/architecture specific checks/flags
279 dnl **********************************************************************
280
281 CURL_CHECK_COMPILER
282 CURL_SET_COMPILER_BASIC_OPTS
283 CURL_SET_COMPILER_DEBUG_OPTS
284 CURL_SET_COMPILER_OPTIMIZE_OPTS
285 CURL_SET_COMPILER_WARNING_OPTS
286
287 if test "$compiler_id" = "INTEL_UNIX_C"; then
288   #
289   if test "$compiler_num" -ge "1000"; then
290     dnl icc 10.X or later
291     CFLAGS="$CFLAGS -shared-intel"
292   elif test "$compiler_num" -ge "900"; then
293     dnl icc 9.X specific
294     CFLAGS="$CFLAGS -i-dynamic"
295   fi
296   #
297 fi
298
299 CURL_CHECK_COMPILER_HALT_ON_ERROR
300 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
301
302 CURL_CHECK_NO_UNDEFINED
303 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
304
305 CURL_CHECK_CURLDEBUG
306 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
307
308 supports_unittests=yes
309 # cross-compilation of unit tests static library/programs fails when
310 # libcurl shared library is built. This might be due to a libtool or
311 # automake issue. In this case we disable unit tests.
312 if test "x$cross_compiling" != "xno" &&
313    test "x$enable_shared" != "xno"; then
314   supports_unittests=no
315 fi
316
317 # IRIX 6.5.24 gcc 3.3 autobuilds fail unittests library compilation due to
318 # a problem related with OpenSSL headers and library versions not matching.
319 # Disable unit tests while time to further investigate this is found.
320 case $host in
321   mips-sgi-irix6.5)
322     if test "$compiler_id" = "GNU_C"; then
323       supports_unittests=no
324     fi
325     ;;
326 esac
327
328 # All AIX autobuilds fails unit tests linking against unittests library
329 # due to unittests library being built with no symbols or members. Libtool ?
330 # Disable unit tests while time to further investigate this is found.
331 case $host_os in
332   aix*)
333     supports_unittests=no
334     ;;
335 esac
336
337 dnl Build unit tests when option --enable-debug is given.
338 if test "x$want_debug" = "xyes" &&
339    test "x$supports_unittests" = "xyes"; then
340   want_unittests=yes
341 else
342   want_unittests=no
343 fi
344 AM_CONDITIONAL(BUILD_UNITTESTS, test x$want_unittests = xyes)
345
346 dnl **********************************************************************
347 dnl Compilation based checks should not be done before this point.
348 dnl **********************************************************************
349
350 dnl **********************************************************************
351 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
352 dnl and ws2tcpip.h take precedence over any other further checks which
353 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
354 dnl this specific header files. And do them before its results are used.
355 dnl **********************************************************************
356
357 CURL_CHECK_HEADER_WINDOWS
358 CURL_CHECK_NATIVE_WINDOWS
359 case X-"$ac_cv_native_windows" in
360   X-yes)
361     CURL_CHECK_HEADER_WINSOCK
362     CURL_CHECK_HEADER_WINSOCK2
363     CURL_CHECK_HEADER_WS2TCPIP
364     CURL_CHECK_HEADER_WINLDAP
365     CURL_CHECK_HEADER_WINBER
366     ;;
367   *)
368     ac_cv_header_winsock_h="no"
369     ac_cv_header_winsock2_h="no"
370     ac_cv_header_ws2tcpip_h="no"
371     ac_cv_header_winldap_h="no"
372     ac_cv_header_winber_h="no"
373     ;;
374 esac
375 CURL_CHECK_WIN32_LARGEFILE
376
377 dnl ************************************************************
378 dnl switch off particular protocols
379 dnl
380 AC_MSG_CHECKING([whether to support http])
381 AC_ARG_ENABLE(http,
382 AC_HELP_STRING([--enable-http],[Enable HTTP support])
383 AC_HELP_STRING([--disable-http],[Disable HTTP support]),
384 [ case "$enableval" in
385   no)
386        AC_MSG_RESULT(no)
387        AC_DEFINE(CURL_DISABLE_HTTP, 1, [to disable HTTP])
388        AC_MSG_WARN([disable HTTP disables FTP over proxy and RTSP])
389        AC_SUBST(CURL_DISABLE_HTTP, [1])
390        AC_DEFINE(CURL_DISABLE_RTSP, 1, [to disable RTSP])
391        AC_SUBST(CURL_DISABLE_RTSP, [1])
392        ;;
393   *)   AC_MSG_RESULT(yes)
394        ;;
395   esac ],
396        AC_MSG_RESULT(yes)
397 )
398 AC_MSG_CHECKING([whether to support ftp])
399 AC_ARG_ENABLE(ftp,
400 AC_HELP_STRING([--enable-ftp],[Enable FTP support])
401 AC_HELP_STRING([--disable-ftp],[Disable FTP support]),
402 [ case "$enableval" in
403   no)
404        AC_MSG_RESULT(no)
405        AC_DEFINE(CURL_DISABLE_FTP, 1, [to disable FTP])
406        AC_SUBST(CURL_DISABLE_FTP, [1])
407        ;;
408   *)   AC_MSG_RESULT(yes)
409        ;;
410   esac ],
411        AC_MSG_RESULT(yes)
412 )
413 AC_MSG_CHECKING([whether to support file])
414 AC_ARG_ENABLE(file,
415 AC_HELP_STRING([--enable-file],[Enable FILE support])
416 AC_HELP_STRING([--disable-file],[Disable FILE support]),
417 [ case "$enableval" in
418   no)
419        AC_MSG_RESULT(no)
420        AC_DEFINE(CURL_DISABLE_FILE, 1, [to disable FILE])
421        AC_SUBST(CURL_DISABLE_FILE, [1])
422        ;;
423   *)   AC_MSG_RESULT(yes)
424        ;;
425   esac ],
426        AC_MSG_RESULT(yes)
427 )
428 AC_MSG_CHECKING([whether to support ldap])
429 AC_ARG_ENABLE(ldap,
430 AC_HELP_STRING([--enable-ldap],[Enable LDAP support])
431 AC_HELP_STRING([--disable-ldap],[Disable LDAP support]),
432 [ case "$enableval" in
433   no)
434        AC_MSG_RESULT(no)
435        AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
436        AC_SUBST(CURL_DISABLE_LDAP, [1])
437        ;;
438   *)
439        AC_MSG_RESULT(yes)
440        ;;
441   esac ],[
442        AC_MSG_RESULT(yes) ]
443 )
444 AC_MSG_CHECKING([whether to support ldaps])
445 AC_ARG_ENABLE(ldaps,
446 AC_HELP_STRING([--enable-ldaps],[Enable LDAPS support])
447 AC_HELP_STRING([--disable-ldaps],[Disable LDAPS support]),
448 [ case "$enableval" in
449   no)
450        AC_MSG_RESULT(no)
451        AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
452        AC_SUBST(CURL_DISABLE_LDAPS, [1])
453        ;;
454   *)   if test "x$CURL_DISABLE_LDAP" = "x1" ; then
455          AC_MSG_RESULT(LDAP needs to be enabled to support LDAPS)
456          AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
457          AC_SUBST(CURL_DISABLE_LDAPS, [1])
458        else
459          AC_MSG_RESULT(yes)
460          AC_DEFINE(HAVE_LDAP_SSL, 1, [Use LDAPS implementation])
461          AC_SUBST(HAVE_LDAP_SSL, [1])
462        fi
463        ;;
464   esac ],[
465        if test "x$CURL_DISABLE_LDAP" = "x1" ; then
466          AC_MSG_RESULT(no)
467          AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
468          AC_SUBST(CURL_DISABLE_LDAPS, [1])
469        else
470          AC_MSG_RESULT(yes)
471          AC_DEFINE(HAVE_LDAP_SSL, 1, [Use LDAPS implementation])
472          AC_SUBST(HAVE_LDAP_SSL, [1])
473        fi ]
474 )
475
476 AC_MSG_CHECKING([whether to support rtsp])
477 AC_ARG_ENABLE(rtsp,
478 AC_HELP_STRING([--enable-rtsp],[Enable RTSP support])
479 AC_HELP_STRING([--disable-rtsp],[Disable RTSP support]),
480 [ case "$enableval" in
481   no)
482        AC_MSG_RESULT(no)
483        AC_DEFINE(CURL_DISABLE_RTSP, 1, [to disable RTSP])
484        AC_SUBST(CURL_DISABLE_RTSP, [1])
485        ;;
486   *)   if test x$CURL_DISABLE_HTTP = x1 ; then
487           AC_MSG_ERROR(HTTP support needs to be enabled in order to enable RTSP support!)
488        else
489           AC_MSG_RESULT(yes)
490           curl_rtsp_msg="enabled"
491        fi
492        ;;
493   esac ],
494        if test "x$CURL_DISABLE_HTTP" != "x1"; then
495           AC_MSG_RESULT(yes)
496           curl_rtsp_msg="enabled"
497        else
498           AC_MSG_RESULT(no)
499        fi
500 )
501
502 AC_MSG_CHECKING([whether to support proxies])
503 AC_ARG_ENABLE(proxy,
504 AC_HELP_STRING([--enable-proxy],[Enable proxy support])
505 AC_HELP_STRING([--disable-proxy],[Disable proxy support]),
506 [ case "$enableval" in
507   no)
508        AC_MSG_RESULT(no)
509        AC_DEFINE(CURL_DISABLE_PROXY, 1, [to disable proxies])
510        AC_SUBST(CURL_DISABLE_PROXY, [1])
511        ;;
512   *)   AC_MSG_RESULT(yes)
513        ;;
514   esac ],
515        AC_MSG_RESULT(yes)
516 )
517
518 AC_MSG_CHECKING([whether to support dict])
519 AC_ARG_ENABLE(dict,
520 AC_HELP_STRING([--enable-dict],[Enable DICT support])
521 AC_HELP_STRING([--disable-dict],[Disable DICT support]),
522 [ case "$enableval" in
523   no)
524        AC_MSG_RESULT(no)
525        AC_DEFINE(CURL_DISABLE_DICT, 1, [to disable DICT])
526        AC_SUBST(CURL_DISABLE_DICT, [1])
527        ;;
528   *)   AC_MSG_RESULT(yes)
529        ;;
530   esac ],
531        AC_MSG_RESULT(yes)
532 )
533 AC_MSG_CHECKING([whether to support telnet])
534 AC_ARG_ENABLE(telnet,
535 AC_HELP_STRING([--enable-telnet],[Enable TELNET support])
536 AC_HELP_STRING([--disable-telnet],[Disable TELNET support]),
537 [ case "$enableval" in
538   no)
539        AC_MSG_RESULT(no)
540        AC_DEFINE(CURL_DISABLE_TELNET, 1, [to disable TELNET])
541        AC_SUBST(CURL_DISABLE_TELNET, [1])
542        ;;
543   *)   AC_MSG_RESULT(yes)
544        ;;
545   esac ],
546        AC_MSG_RESULT(yes)
547 )
548 AC_MSG_CHECKING([whether to support tftp])
549 AC_ARG_ENABLE(tftp,
550 AC_HELP_STRING([--enable-tftp],[Enable TFTP support])
551 AC_HELP_STRING([--disable-tftp],[Disable TFTP support]),
552 [ case "$enableval" in
553   no)
554        AC_MSG_RESULT(no)
555        AC_DEFINE(CURL_DISABLE_TFTP, 1, [to disable TFTP])
556        AC_SUBST(CURL_DISABLE_TFTP, [1])
557        ;;
558   *)   AC_MSG_RESULT(yes)
559        ;;
560   esac ],
561        AC_MSG_RESULT(yes)
562 )
563
564 AC_MSG_CHECKING([whether to support pop3])
565 AC_ARG_ENABLE(pop3,
566 AC_HELP_STRING([--enable-pop3],[Enable POP3 support])
567 AC_HELP_STRING([--disable-pop3],[Disable POP3 support]),
568 [ case "$enableval" in
569   no)
570        AC_MSG_RESULT(no)
571        AC_DEFINE(CURL_DISABLE_POP3, 1, [to disable POP3])
572        AC_SUBST(CURL_DISABLE_POP3, [1])
573        ;;
574   *)   AC_MSG_RESULT(yes)
575        ;;
576   esac ],
577        AC_MSG_RESULT(yes)
578 )
579
580
581 AC_MSG_CHECKING([whether to support imap])
582 AC_ARG_ENABLE(imap,
583 AC_HELP_STRING([--enable-imap],[Enable IMAP support])
584 AC_HELP_STRING([--disable-imap],[Disable IMAP support]),
585 [ case "$enableval" in
586   no)
587        AC_MSG_RESULT(no)
588        AC_DEFINE(CURL_DISABLE_IMAP, 1, [to disable IMAP])
589        AC_SUBST(CURL_DISABLE_IMAP, [1])
590        ;;
591   *)   AC_MSG_RESULT(yes)
592        ;;
593   esac ],
594        AC_MSG_RESULT(yes)
595 )
596
597
598 AC_MSG_CHECKING([whether to support smtp])
599 AC_ARG_ENABLE(smtp,
600 AC_HELP_STRING([--enable-smtp],[Enable SMTP support])
601 AC_HELP_STRING([--disable-smtp],[Disable SMTP support]),
602 [ case "$enableval" in
603   no)
604        AC_MSG_RESULT(no)
605        AC_DEFINE(CURL_DISABLE_SMTP, 1, [to disable SMTP])
606        AC_SUBST(CURL_DISABLE_SMTP, [1])
607        ;;
608   *)   AC_MSG_RESULT(yes)
609        ;;
610   esac ],
611        AC_MSG_RESULT(yes)
612 )
613
614 AC_MSG_CHECKING([whether to support gopher])
615 AC_ARG_ENABLE(gopher,
616 AC_HELP_STRING([--enable-gopher],[Enable Gopher support])
617 AC_HELP_STRING([--disable-gopher],[Disable Gopher support]),
618 [ case "$enableval" in
619   no)
620        AC_MSG_RESULT(no)
621        AC_DEFINE(CURL_DISABLE_GOPHER, 1, [to disable Gopher])
622        AC_SUBST(CURL_DISABLE_GOPHER, [1])
623        ;;
624   *)   AC_MSG_RESULT(yes)
625        ;;
626   esac ],
627        AC_MSG_RESULT(yes)
628 )
629
630
631 dnl **********************************************************************
632 dnl Check for built-in manual
633 dnl **********************************************************************
634
635 AC_MSG_CHECKING([whether to provide built-in manual])
636 AC_ARG_ENABLE(manual,
637 AC_HELP_STRING([--enable-manual],[Enable built-in manual])
638 AC_HELP_STRING([--disable-manual],[Disable built-in manual]),
639 [ case "$enableval" in
640   no)
641        AC_MSG_RESULT(no)
642        ;;
643   *)   AC_MSG_RESULT(yes)
644        USE_MANUAL="1"
645        ;;
646   esac ],
647        AC_MSG_RESULT(yes)
648        USE_MANUAL="1"
649 )
650 dnl The actual use of the USE_MANUAL variable is done much later in this
651 dnl script to allow other actions to disable it as well.
652
653 dnl **********************************************************************
654 dnl Checks for libraries.
655 dnl **********************************************************************
656
657 CURL_CHECK_LIB_XNET
658
659 dnl gethostbyname without lib or in the nsl lib?
660 AC_CHECK_FUNC(gethostbyname,
661               [HAVE_GETHOSTBYNAME="1"
662               ],
663               [ AC_CHECK_LIB(nsl, gethostbyname,
664                              [HAVE_GETHOSTBYNAME="1"
665                              LIBS="$LIBS -lnsl"
666                              ])
667               ])
668
669 if test "$HAVE_GETHOSTBYNAME" != "1"
670 then
671   dnl gethostbyname in the socket lib?
672   AC_CHECK_LIB(socket, gethostbyname,
673                [HAVE_GETHOSTBYNAME="1"
674                LIBS="$LIBS -lsocket"
675                ])
676 fi
677
678 dnl At least one system has been identified to require BOTH nsl and socket
679 dnl libs at the same time to link properly.
680 if test "$HAVE_GETHOSTBYNAME" != "1"
681 then
682   AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
683   my_ac_save_LIBS=$LIBS
684   LIBS="-lnsl -lsocket $LIBS"
685   AC_LINK_IFELSE([
686     AC_LANG_PROGRAM([[
687     ]],[[
688       gethostbyname();
689     ]])
690   ],[
691     AC_MSG_RESULT([yes])
692     HAVE_GETHOSTBYNAME="1"
693   ],[
694     AC_MSG_RESULT([no])
695     LIBS=$my_ac_save_LIBS
696   ])
697 fi
698
699 if test "$HAVE_GETHOSTBYNAME" != "1"
700 then
701   dnl This is for winsock systems
702   if test "$ac_cv_header_windows_h" = "yes"; then
703     if test "$ac_cv_header_winsock_h" = "yes"; then
704       case $host in
705         *-*-mingw32ce*)
706           winsock_LIB="-lwinsock"
707           ;;
708         *)
709           winsock_LIB="-lwsock32"
710           ;;
711       esac
712     fi
713     if test "$ac_cv_header_winsock2_h" = "yes"; then
714       winsock_LIB="-lws2_32"
715     fi
716     if test ! -z "$winsock_LIB"; then
717       my_ac_save_LIBS=$LIBS
718       LIBS="$winsock_LIB $LIBS"
719       AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
720       AC_LINK_IFELSE([
721         AC_LANG_PROGRAM([[
722 #ifdef HAVE_WINDOWS_H
723 #ifndef WIN32_LEAN_AND_MEAN
724 #define WIN32_LEAN_AND_MEAN
725 #endif
726 #include <windows.h>
727 #ifdef HAVE_WINSOCK2_H
728 #include <winsock2.h>
729 #else
730 #ifdef HAVE_WINSOCK_H
731 #include <winsock.h>
732 #endif
733 #endif
734 #endif
735         ]],[[
736           gethostbyname("www.dummysite.com");
737         ]])
738       ],[
739         AC_MSG_RESULT([yes])
740         HAVE_GETHOSTBYNAME="1"
741       ],[
742         AC_MSG_RESULT([no])
743         winsock_LIB=""
744         LIBS=$my_ac_save_LIBS
745       ])
746     fi
747   fi
748 fi
749
750 if test "$HAVE_GETHOSTBYNAME" != "1"
751 then
752   dnl This is for Minix 3.1
753   AC_MSG_CHECKING([for gethostbyname for Minix 3])
754   AC_LINK_IFELSE([
755     AC_LANG_PROGRAM([[
756 /* Older Minix versions may need <net/gen/netdb.h> here instead */
757 #include <netdb.h>
758     ]],[[
759       gethostbyname("www.dummysite.com");
760     ]])
761   ],[
762     AC_MSG_RESULT([yes])
763     HAVE_GETHOSTBYNAME="1"
764   ],[
765     AC_MSG_RESULT([no])
766   ])
767 fi
768
769 if test "$HAVE_GETHOSTBYNAME" != "1"
770 then
771   dnl This is for eCos with a stubbed DNS implementation
772   AC_MSG_CHECKING([for gethostbyname for eCos])
773   AC_LINK_IFELSE([
774     AC_LANG_PROGRAM([[
775 #include <stdio.h>
776 #include <netdb.h>
777     ]],[[
778       gethostbyname("www.dummysite.com");
779     ]])
780   ],[
781     AC_MSG_RESULT([yes])
782     HAVE_GETHOSTBYNAME="1"
783   ],[
784     AC_MSG_RESULT([no])
785   ])
786 fi
787
788 if test "$HAVE_GETHOSTBYNAME" != "1"
789 then
790   dnl gethostbyname in the network lib - for Haiku OS
791   AC_CHECK_LIB(network, gethostbyname,
792                [HAVE_GETHOSTBYNAME="1"
793                LIBS="$LIBS -lnetwork"
794                ])
795 fi
796
797 if test "$HAVE_GETHOSTBYNAME" != "1"
798 then
799   dnl gethostbyname in the net lib - for BeOS
800   AC_CHECK_LIB(net, gethostbyname,
801                [HAVE_GETHOSTBYNAME="1"
802                LIBS="$LIBS -lnet"
803                ])
804 fi
805
806
807 if test "$HAVE_GETHOSTBYNAME" != "1"; then
808   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
809 fi
810
811 dnl resolve lib?
812 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
813
814 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
815   AC_CHECK_LIB(resolve, strcasecmp,
816               [LIBS="-lresolve $LIBS"],
817                ,
818                -lnsl)
819 fi
820 ac_cv_func_strcasecmp="no"
821
822 CURL_CHECK_LIBS_CONNECT
823
824 CURL_NETWORK_LIBS=$LIBS
825
826 dnl **********************************************************************
827 dnl In case that function clock_gettime with monotonic timer is available,
828 dnl check for additional required libraries.
829 dnl **********************************************************************
830 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
831
832 dnl **********************************************************************
833 dnl The preceding library checks are all potentially useful for test
834 dnl servers (for providing networking support).  Save the list of required
835 dnl libraries at this point for use while linking those test servers.
836 dnl **********************************************************************
837 TEST_SERVER_LIBS=$LIBS
838
839 dnl **********************************************************************
840 AC_MSG_CHECKING([whether to use libgcc])
841 AC_ARG_ENABLE(libgcc,
842 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
843 [ case "$enableval" in
844   yes)
845         ALL_LIBS="$ALL_LIBS -lgcc"
846        AC_MSG_RESULT(yes)
847        ;;
848   *)   AC_MSG_RESULT(no)
849        ;;
850   esac ],
851        AC_MSG_RESULT(no)
852 )
853
854 dnl **********************************************************************
855 dnl Check for LDAP
856 dnl **********************************************************************
857
858 LDAPLIBNAME=""
859 AC_ARG_WITH(ldap-lib,
860 AC_HELP_STRING([--with-ldap-lib=libname],[Specify name of ldap lib file]),
861  [LDAPLIBNAME="$withval"])
862
863 LBERLIBNAME=""
864 AC_ARG_WITH(lber-lib,
865 AC_HELP_STRING([--with-lber-lib=libname],[Specify name of lber lib file]),
866  [LBERLIBNAME="$withval"])
867
868 if test x$CURL_DISABLE_LDAP != x1 ; then
869
870   CURL_CHECK_HEADER_LBER
871   CURL_CHECK_HEADER_LDAP
872   CURL_CHECK_HEADER_LDAPSSL
873   CURL_CHECK_HEADER_LDAP_SSL
874
875   if test -z "$LDAPLIBNAME" ; then
876     if test "$ac_cv_native_windows" = "yes"; then
877       dnl Windows uses a single and unique LDAP library name
878       LDAPLIBNAME="wldap32"
879       LBERLIBNAME="no"
880     fi
881   fi
882
883   if test "$LDAPLIBNAME" ; then
884     AC_CHECK_LIB("$LDAPLIBNAME", ldap_init,, [
885       AC_MSG_WARN(["$LDAPLIBNAME" is not an LDAP library: LDAP disabled])
886       AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
887       AC_SUBST(CURL_DISABLE_LDAP, [1])])
888       AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
889       AC_SUBST(CURL_DISABLE_LDAPS, [1])
890   else
891     dnl Try to find the right ldap libraries for this system
892     CURL_CHECK_LIBS_LDAP
893     case X-"$curl_cv_ldap_LIBS" in
894       X-unknown)
895         AC_MSG_WARN([Cannot find libraries for LDAP support: LDAP disabled])
896         AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
897         AC_SUBST(CURL_DISABLE_LDAP, [1])
898         AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
899         AC_SUBST(CURL_DISABLE_LDAPS, [1])
900         ;;
901     esac
902   fi
903 fi
904
905 if test x$CURL_DISABLE_LDAP != x1 ; then
906
907   if test "$LBERLIBNAME" ; then
908     dnl If name is "no" then don't define this library at all
909     dnl (it's only needed if libldap.so's dependencies are broken).
910     if test "$LBERLIBNAME" != "no" ; then
911       AC_CHECK_LIB("$LBERLIBNAME", ber_free,, [
912         AC_MSG_WARN(["$LBERLIBNAME" is not an LBER library: LDAP disabled])
913         AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
914         AC_SUBST(CURL_DISABLE_LDAP, [1])])
915         AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
916         AC_SUBST(CURL_DISABLE_LDAPS, [1])
917     fi
918   fi
919 fi
920
921 if test x$CURL_DISABLE_LDAP != x1 ; then
922   AC_CHECK_FUNCS([ldap_url_parse ldap_init_fd])
923
924   if test "$LDAPLIBNAME" = "wldap32"; then
925     curl_ldap_msg="enabled (winldap)"
926     AC_DEFINE(CURL_LDAP_WIN, 1, [Use Windows LDAP implementation])
927   else
928     curl_ldap_msg="enabled (OpenLDAP)"
929     if test "x$ac_cv_func_ldap_init_fd" = "xyes"; then
930       AC_DEFINE(USE_OPENLDAP, 1, [Use OpenLDAP-specific code])
931       AC_SUBST(USE_OPENLDAP, [1])
932     fi
933   fi
934 fi
935
936 if test x$CURL_DISABLE_LDAPS != x1 ; then
937     curl_ldaps_msg="enabled"
938 fi
939
940 dnl **********************************************************************
941 dnl Checks for IPv6
942 dnl **********************************************************************
943
944 AC_MSG_CHECKING([whether to enable ipv6])
945 AC_ARG_ENABLE(ipv6,
946 AC_HELP_STRING([--enable-ipv6],[Enable ipv6 (with ipv4) support])
947 AC_HELP_STRING([--disable-ipv6],[Disable ipv6 support]),
948 [ case "$enableval" in
949   no)
950        AC_MSG_RESULT(no)
951        ipv6=no
952        ;;
953   *)   AC_MSG_RESULT(yes)
954        ipv6=yes
955        ;;
956   esac ],
957
958   AC_TRY_RUN([ /* is AF_INET6 available? */
959 #include <sys/types.h>
960 #include <sys/socket.h>
961 main()
962 {
963  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
964    exit(1);
965  else
966    exit(0);
967 }
968 ],
969   AC_MSG_RESULT(yes)
970   ipv6=yes,
971   AC_MSG_RESULT(no)
972   ipv6=no,
973   AC_MSG_RESULT(no)
974   ipv6=no
975 ))
976
977 if test "$ipv6" = "yes"; then
978   curl_ipv6_msg="enabled"
979 fi
980
981 # Check if struct sockaddr_in6 have sin6_scope_id member
982 if test "$ipv6" = yes; then
983   AC_MSG_CHECKING([if struct sockaddr_in6 has sin6_scope_id member])
984   AC_TRY_COMPILE([
985 #include <sys/types.h>
986 #include <netinet/in.h>] ,
987   struct sockaddr_in6 s; s.sin6_scope_id = 0; , have_sin6_scope_id=yes)
988   if test "$have_sin6_scope_id" = yes; then
989     AC_MSG_RESULT([yes])
990     AC_DEFINE(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID, 1, [Define to 1 if struct sockaddr_in6 has the sin6_scope_id member])
991   else
992     AC_MSG_RESULT([no])
993   fi
994 fi
995
996 dnl **********************************************************************
997 dnl Check if the operating system allows programs to write to their own argv[]
998 dnl **********************************************************************
999
1000 AC_MSG_CHECKING([if argv can be written to])
1001 AC_RUN_IFELSE([
1002   AC_LANG_SOURCE([[
1003 int main(int argc, char ** argv) {
1004     argv[0][0] = ' ';
1005     return (argv[0][0] == ' ')?0:1;
1006 }
1007   ]])
1008 ],[
1009   curl_cv_writable_argv=yes
1010 ],[
1011   curl_cv_writable_argv=no
1012 ],[
1013   curl_cv_writable_argv=cross
1014 ])
1015 case $curl_cv_writable_argv in
1016 yes)
1017         AC_DEFINE(HAVE_WRITABLE_ARGV, 1, [Define this symbol if your OS supports changing the contents of argv])
1018         AC_MSG_RESULT(yes)
1019         ;;
1020 no)
1021         AC_MSG_RESULT(no)
1022         ;;
1023 *)
1024         AC_MSG_RESULT(no)
1025         AC_MSG_WARN([the previous check could not be made default was used])
1026         ;;
1027 esac
1028
1029 dnl **********************************************************************
1030 dnl Check for the presence of Kerberos4 libraries and headers
1031 dnl **********************************************************************
1032
1033 AC_ARG_WITH(krb4-includes,
1034 AC_HELP_STRING([--with-krb4-includes=DIR],
1035                [Specify location of kerberos4 headers]),[
1036  CPPFLAGS="$CPPFLAGS -I$withval"
1037  KRB4INC="$withval"
1038  want_krb4=yes
1039  ])
1040
1041 AC_ARG_WITH(krb4-libs,
1042 AC_HELP_STRING([--with-krb4-libs=DIR],[Specify location of kerberos4 libs]),[
1043  LDFLAGS="$LDFLAGS -L$withval"
1044  KRB4LIB="$withval"
1045  want_krb4=yes
1046  ])
1047
1048
1049 OPT_KRB4=off
1050 AC_ARG_WITH(krb4,dnl
1051 AC_HELP_STRING([--with-krb4=DIR],[where to look for Kerberos4]),[
1052   OPT_KRB4="$withval"
1053   if test X"$OPT_KRB4" != Xno; then
1054     want_krb4="yes"
1055     if test X"$OPT_KRB4" != Xyes; then
1056       LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib$libsuff"
1057       KRB4LIB="$OPT_KRB4/lib$libsuff"
1058       CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
1059       KRB4INC="$OPT_KRB4/include"
1060     fi
1061   fi
1062  ])
1063
1064 AC_MSG_CHECKING([if Kerberos4 support is requested])
1065
1066 if test "$want_krb4" = yes
1067 then
1068   if test "$ipv6" = "yes"; then
1069     echo krb4 is not compatible with IPv6
1070     exit 1
1071   fi
1072   AC_MSG_RESULT(yes)
1073
1074   dnl Check for & handle argument to --with-krb4
1075
1076   AC_MSG_CHECKING(where to look for Kerberos4)
1077   if test X"$OPT_KRB4" = Xyes
1078   then
1079     AC_MSG_RESULT([defaults])
1080   else
1081     AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
1082   fi
1083
1084   dnl Check for DES library
1085   AC_CHECK_LIB(des, des_pcbc_encrypt,
1086   [
1087     AC_CHECK_HEADERS(des.h)
1088
1089     dnl resolv lib?
1090     AC_CHECK_FUNC(res_search, , [AC_CHECK_LIB(resolv, res_search)])
1091
1092     dnl Check for the Kerberos4 library
1093     AC_CHECK_LIB(krb, krb_net_read,
1094     [
1095       dnl Check for header files
1096       AC_CHECK_HEADERS(krb.h)
1097
1098       dnl we found the required libraries, add to LIBS
1099       LIBS="-lkrb -lcom_err -ldes $LIBS"
1100
1101       dnl Check for function krb_get_our_ip_for_realm
1102       dnl this is needed for NAT networks
1103       AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
1104
1105       dnl add define KRB4
1106       AC_DEFINE(HAVE_KRB4, 1,
1107       [if you have the Kerberos4 libraries (including -ldes)])
1108
1109       dnl substitute it too!
1110       KRB4_ENABLED=1
1111       AC_SUBST(KRB4_ENABLED)
1112
1113       curl_krb4_msg="enabled"
1114
1115       dnl the krb4 stuff needs a strlcpy()
1116       AC_CHECK_FUNCS(strlcpy)
1117
1118     ])
1119   ])
1120 else
1121   AC_MSG_RESULT(no)
1122 fi
1123
1124 dnl **********************************************************************
1125 dnl Check for FBopenssl(SPNEGO) libraries
1126 dnl **********************************************************************
1127
1128 AC_ARG_WITH(spnego,
1129   AC_HELP_STRING([--with-spnego=DIR],
1130                  [Specify location of SPNEGO library fbopenssl]), [
1131   SPNEGO_ROOT="$withval"
1132   if test x"$SPNEGO_ROOT" != xno; then
1133     want_spnego="yes"
1134   fi
1135 ])
1136
1137 AC_MSG_CHECKING([if SPNEGO support is requested])
1138 if test x"$want_spnego" = xyes; then
1139
1140   if test X"$SPNEGO_ROOT" = Xyes; then
1141      AC_MSG_ERROR([FBOpenSSL libs and/or directories were not found where specified!])
1142      AC_MSG_RESULT(no)
1143   else
1144      if test -z "$SPNEGO_LIB_DIR"; then
1145         LDFLAGS="$LDFLAGS -L$SPNEGO_ROOT -lfbopenssl"
1146      else
1147         LDFLAGS="$LDFLAGS $SPNEGO_LIB_DIR"
1148      fi
1149
1150      AC_MSG_RESULT(yes)
1151      AC_DEFINE(HAVE_SPNEGO, 1,
1152                [Define this if you have the SPNEGO library fbopenssl])
1153      curl_spnego_msg="enabled"
1154   fi
1155 else
1156   AC_MSG_RESULT(no)
1157 fi
1158
1159 dnl **********************************************************************
1160 dnl Check for GSS-API libraries
1161 dnl **********************************************************************
1162
1163 dnl check for gss stuff in the /usr as default
1164
1165 GSSAPI_ROOT="/usr"
1166 AC_ARG_WITH(gssapi-includes,
1167   AC_HELP_STRING([--with-gssapi-includes=DIR],
1168                  [Specify location of GSSAPI header]),
1169   [ GSSAPI_INCS="-I$withval"
1170     want_gss="yes" ]
1171 )
1172
1173 AC_ARG_WITH(gssapi-libs,
1174   AC_HELP_STRING([--with-gssapi-libs=DIR],
1175                  [Specify location of GSSAPI libs]),
1176   [ GSSAPI_LIB_DIR="-L$withval"
1177     want_gss="yes" ]
1178 )
1179
1180 AC_ARG_WITH(gssapi,
1181   AC_HELP_STRING([--with-gssapi=DIR],
1182                  [Where to look for GSSAPI]), [
1183   GSSAPI_ROOT="$withval"
1184   if test x"$GSSAPI_ROOT" != xno; then
1185     want_gss="yes"
1186     if test x"$GSSAPI_ROOT" = xyes; then
1187       dnl if yes, then use default root
1188       GSSAPI_ROOT="/usr"
1189     fi
1190   fi
1191 ])
1192
1193 save_CPPFLAGS="$CPPFLAGS"
1194 AC_MSG_CHECKING([if GSSAPI support is requested])
1195 if test x"$want_gss" = xyes; then
1196   AC_MSG_RESULT(yes)
1197
1198   if test -z "$GSSAPI_INCS"; then
1199      if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
1200         GSSAPI_INCS=`$GSSAPI_ROOT/bin/krb5-config --cflags gssapi`
1201      elif test "$GSSAPI_ROOT" != "yes"; then
1202         GSSAPI_INCS="-I$GSSAPI_ROOT/include"
1203      fi
1204   fi
1205
1206   CPPFLAGS="$CPPFLAGS $GSSAPI_INCS"
1207
1208   AC_CHECK_HEADER(gss.h,
1209     [
1210       dnl found in the given dirs
1211       AC_DEFINE(HAVE_GSSGNU, 1, [if you have the GNU gssapi libraries])
1212       gnu_gss=yes
1213     ],
1214     [
1215       dnl not found, check Heimdal or MIT
1216       AC_CHECK_HEADERS([gssapi/gssapi.h], [], [not_mit=1])
1217       AC_CHECK_HEADERS(
1218         [gssapi/gssapi_generic.h gssapi/gssapi_krb5.h],
1219         [],
1220         [not_mit=1],
1221         [
1222 AC_INCLUDES_DEFAULT
1223 #ifdef HAVE_GSSAPI_GSSAPI_H
1224 #include <gssapi/gssapi.h>
1225 #endif
1226         ])
1227       if test "x$not_mit" = "x1"; then
1228         dnl MIT not found, check for Heimdal
1229         AC_CHECK_HEADER(gssapi.h,
1230             [
1231               dnl found
1232               AC_DEFINE(HAVE_GSSHEIMDAL, 1, [if you have the Heimdal gssapi libraries])
1233             ],
1234             [
1235               dnl no header found, disabling GSS
1236               want_gss=no
1237               AC_MSG_WARN(disabling GSSAPI since no header files was found)
1238             ]
1239           )
1240       else
1241         dnl MIT found
1242         AC_DEFINE(HAVE_GSSMIT, 1, [if you have the MIT gssapi libraries])
1243         dnl check if we have a really old MIT kerberos (<= 1.2)
1244         AC_MSG_CHECKING([if gssapi headers declare GSS_C_NT_HOSTBASED_SERVICE])
1245         AC_COMPILE_IFELSE([
1246           AC_LANG_PROGRAM([[
1247 #include <gssapi/gssapi.h>
1248 #include <gssapi/gssapi_generic.h>
1249 #include <gssapi/gssapi_krb5.h>
1250           ]],[[
1251             gss_import_name(
1252                             (OM_uint32 *)0,
1253                             (gss_buffer_t)0,
1254                             GSS_C_NT_HOSTBASED_SERVICE,
1255                             (gss_name_t *)0);
1256           ]])
1257         ],[
1258           AC_MSG_RESULT([yes])
1259         ],[
1260           AC_MSG_RESULT([no])
1261           AC_DEFINE(HAVE_OLD_GSSMIT, 1,
1262             [if you have an old MIT gssapi library, lacking GSS_C_NT_HOSTBASED_SERVICE])
1263         ])
1264       fi
1265     ]
1266   )
1267 else
1268   AC_MSG_RESULT(no)
1269 fi
1270 if test x"$want_gss" = xyes; then
1271   AC_DEFINE(HAVE_GSSAPI, 1, [if you have the gssapi libraries])
1272
1273   curl_gss_msg="enabled (MIT/Heimdal)"
1274
1275   if test -n "$gnu_gss"; then
1276     curl_gss_msg="enabled (GNU GSS)"
1277     LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
1278     LIBS="$LIBS -lgss"
1279   elif test -z "$GSSAPI_LIB_DIR"; then
1280      case $host in
1281      *-*-darwin*)
1282         LIBS="$LIBS -lgssapi_krb5 -lresolv"
1283         ;;
1284      *)
1285         if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
1286            dnl krb5-config doesn't have --libs-only-L or similar, put everything
1287            dnl into LIBS
1288            gss_libs=`$GSSAPI_ROOT/bin/krb5-config --libs gssapi`
1289            LIBS="$LIBS $gss_libs"
1290         elif test "$GSSAPI_ROOT" != "yes"; then
1291            LDFLAGS="$LDFLAGS -L$GSSAPI_ROOT/lib$libsuff"
1292            LIBS="$LIBS -lgssapi"
1293         else
1294            LIBS="$LIBS -lgssapi"
1295         fi
1296         ;;
1297      esac
1298   else
1299      LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
1300      LIBS="$LIBS -lgssapi"
1301   fi
1302 else
1303   CPPFLAGS="$save_CPPFLAGS"
1304 fi
1305
1306 dnl **********************************************************************
1307 dnl Check for the presence of SSL libraries and headers
1308 dnl **********************************************************************
1309
1310 dnl Default to compiler & linker defaults for SSL files & libraries.
1311 OPT_SSL=off
1312 dnl Default to no CA bundle
1313 ca="no"
1314 AC_ARG_WITH(ssl,dnl
1315 AC_HELP_STRING([--with-ssl=PATH],[Where to look for OpenSSL, PATH points to the SSL installation (default: /usr/local/ssl); when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
1316 AC_HELP_STRING([--without-ssl], [disable OpenSSL]),
1317   OPT_SSL=$withval)
1318
1319 if test X"$OPT_SSL" != Xno; then
1320   dnl backup the pre-ssl variables
1321   CLEANLDFLAGS="$LDFLAGS"
1322   CLEANCPPFLAGS="$CPPFLAGS"
1323   CLEANLIBS="$LIBS"
1324
1325   case "$OPT_SSL" in
1326   yes)
1327     dnl --with-ssl (without path) used
1328     if test x$cross_compiling != xyes; then
1329       dnl only do pkg-config magic when not cross-compiling
1330       PKGTEST="yes"
1331     fi
1332     PREFIX_OPENSSL=/usr/local/ssl
1333     LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
1334     ;;
1335   off)
1336     dnl no --with-ssl option given, just check default places
1337     if test x$cross_compiling != xyes; then
1338       dnl only do pkg-config magic when not cross-compiling
1339       PKGTEST="yes"
1340     fi
1341     PREFIX_OPENSSL=
1342     ;;
1343   *)
1344     dnl check the given --with-ssl spot
1345     PKGTEST="no"
1346     PREFIX_OPENSSL=$OPT_SSL
1347
1348     dnl Try pkg-config even when cross-compiling.  Since we
1349     dnl specify PKG_CONFIG_LIBDIR we're only looking where
1350     dnl the user told us to look
1351     OPENSSL_PCDIR="$OPT_SSL/lib/pkgconfig"
1352     AC_MSG_NOTICE([PKG_CONFIG_LIBDIR will be set to "$OPENSSL_PCDIR"])
1353     if test -f "$OPENSSL_PCDIR/openssl.pc"; then
1354       PKGTEST="yes"
1355     fi
1356
1357     dnl in case pkg-config comes up empty, use what we got
1358     dnl via --with-ssl
1359     LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
1360     if test "$PREFIX_OPENSSL" != "/usr" ; then
1361       SSL_LDFLAGS="-L$LIB_OPENSSL"
1362       SSL_CPPFLAGS="-I$PREFIX_OPENSSL/include"
1363     fi
1364     SSL_CPPFLAGS="$SSL_CPPFLAGS -I$PREFIX_OPENSSL/include/openssl"
1365     ;;
1366   esac
1367
1368   if test "$PKGTEST" = "yes"; then
1369
1370     CURL_CHECK_PKGCONFIG(openssl, [$OPENSSL_PCDIR])
1371
1372     if test "$PKGCONFIG" != "no" ; then
1373       SSL_LIBS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
1374         $PKGCONFIG --libs-only-l openssl 2>/dev/null`
1375
1376       SSL_LDFLAGS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
1377         $PKGCONFIG --libs-only-L openssl 2>/dev/null`
1378
1379       SSL_CPPFLAGS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
1380         $PKGCONFIG --cflags-only-I openssl 2>/dev/null`
1381
1382       AC_MSG_NOTICE([pkg-config: SSL_LIBS: "$SSL_LIBS"])
1383       AC_MSG_NOTICE([pkg-config: SSL_LDFLAGS: "$SSL_LDFLAGS"])
1384       AC_MSG_NOTICE([pkg-config: SSL_CPPFLAGS: "$SSL_CPPFLAGS"])
1385
1386       LIB_OPENSSL=`echo $SSL_LDFLAGS | sed -e 's/-L//g'`
1387
1388       dnl use the values pkg-config reported.  This is here
1389       dnl instead of below with CPPFLAGS and LDFLAGS because we only
1390       dnl learn about this via pkg-config.  If we only have
1391       dnl the argument to --with-ssl we don't know what
1392       dnl additional libs may be necessary.  Hope that we
1393       dnl don't need any.
1394       LIBS="$LIBS $SSL_LIBS"
1395     fi
1396   fi
1397
1398   dnl finally, set flags to use SSL
1399   CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
1400   LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
1401
1402   dnl This is for Msys/Mingw
1403   case $host in
1404     *-*-msys* | *-*-mingw*)
1405       AC_MSG_CHECKING([for gdi32])
1406       my_ac_save_LIBS=$LIBS
1407       LIBS="-lgdi32 $LIBS"
1408       AC_TRY_LINK([#include <windef.h>
1409                    #include <wingdi.h>],
1410                    [GdiFlush();],
1411                    [ dnl worked!
1412                    AC_MSG_RESULT([yes])],
1413                    [ dnl failed, restore LIBS
1414                    LIBS=$my_ac_save_LIBS
1415                    AC_MSG_RESULT(no)]
1416                   )
1417       ;;
1418   esac
1419
1420   AC_CHECK_LIB(crypto, CRYPTO_lock,[
1421      HAVECRYPTO="yes"
1422      LIBS="-lcrypto $LIBS"
1423      ],[
1424      LDFLAGS="$CLEANLDFLAGS -L$LIB_OPENSSL"
1425      CPPFLAGS="$CLEANCPPFLAGS -I$PREFIX_OPENSSL/include/openssl -I$PREFIX_OPENSSL/include"
1426      AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
1427        HAVECRYPTO="yes"
1428        LIBS="-lcrypto $LIBS"], [
1429        LDFLAGS="$CLEANLDFLAGS"
1430        CPPFLAGS="$CLEANCPPFLAGS"
1431        LIBS="$CLEANLIBS"
1432        ])
1433     ])
1434
1435
1436   if test X"$HAVECRYPTO" = X"yes"; then
1437     dnl This is only reasonable to do if crypto actually is there: check for
1438     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
1439
1440     AC_CHECK_LIB(ssl, SSL_connect)
1441
1442     if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
1443         dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
1444         AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
1445         OLIBS=$LIBS
1446         LIBS="$LIBS -lRSAglue -lrsaref"
1447         AC_CHECK_LIB(ssl, SSL_connect)
1448         if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
1449             dnl still no SSL_connect
1450             AC_MSG_RESULT(no)
1451             LIBS=$OLIBS
1452         else
1453             AC_MSG_RESULT(yes)
1454         fi
1455
1456     else
1457
1458       dnl Have the libraries--check for SSLeay/OpenSSL headers
1459       AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
1460                        openssl/pem.h openssl/ssl.h openssl/err.h,
1461         curl_ssl_msg="enabled (OpenSSL)"
1462         OPENSSL_ENABLED=1
1463         AC_DEFINE(USE_OPENSSL, 1, [if OpenSSL is in use]))
1464
1465       if test $ac_cv_header_openssl_x509_h = no; then
1466         dnl we don't use the "action" part of the AC_CHECK_HEADERS macro
1467         dnl since 'err.h' might in fact find a krb4 header with the same
1468         dnl name
1469         AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h)
1470
1471         if test $ac_cv_header_x509_h = yes &&
1472            test $ac_cv_header_crypto_h = yes &&
1473            test $ac_cv_header_ssl_h = yes; then
1474           dnl three matches
1475           curl_ssl_msg="enabled (OpenSSL)"
1476           OPENSSL_ENABLED=1
1477         fi
1478       fi
1479     fi
1480
1481     if test X"$OPENSSL_ENABLED" = X"1"; then
1482        AC_DEFINE(USE_SSLEAY, 1, [if SSL is enabled])
1483
1484        dnl is there a pkcs12.h header present?
1485        AC_CHECK_HEADERS(openssl/pkcs12.h)
1486     else
1487        LIBS="$CLEANLIBS"
1488     fi
1489     dnl USE_SSLEAY is the historical name for what configure calls
1490     dnl OPENSSL_ENABLED; the names should really be unified
1491     USE_SSLEAY="$OPENSSL_ENABLED"
1492     AC_SUBST(USE_SSLEAY)
1493
1494     if test X"$OPT_SSL" != Xoff &&
1495        test "$OPENSSL_ENABLED" != "1"; then
1496       AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
1497     fi
1498   fi
1499
1500   if test X"$OPENSSL_ENABLED" = X"1"; then
1501     dnl If the ENGINE library seems to be around, check for the OpenSSL engine
1502     dnl stuff, it is kind of "separated" from the main SSL check
1503     AC_CHECK_FUNC(ENGINE_init,
1504               [
1505                 AC_CHECK_HEADERS(openssl/engine.h)
1506                 AC_CHECK_FUNCS( ENGINE_load_builtin_engines )
1507               ])
1508
1509     dnl these can only exist if openssl exists
1510     dnl yassl doesn't have SSL_get_shutdown
1511
1512     AC_CHECK_FUNCS( RAND_status \
1513                     RAND_screen \
1514                     RAND_egd \
1515                     ENGINE_cleanup \
1516                     CRYPTO_cleanup_all_ex_data \
1517                     SSL_get_shutdown \
1518                     SSLv2_client_method )
1519
1520     dnl Make an attempt to detect if this is actually yassl's headers and
1521     dnl OpenSSL emulation layer. We still leave everything else believing
1522     dnl and acting like OpenSSL.
1523
1524     AC_MSG_CHECKING([for yaSSL using OpenSSL compatibility mode])
1525     AC_COMPILE_IFELSE([
1526       AC_LANG_PROGRAM([[
1527 #include <openssl/ssl.h>
1528       ]],[[
1529 #if defined(YASSL_VERSION) && defined(OPENSSL_VERSION_NUMBER)
1530         int dummy = SSL_ERROR_NONE;
1531 #else
1532         Not the yaSSL OpenSSL compatibility header.
1533 #endif
1534       ]])
1535     ],[
1536       AC_MSG_RESULT([yes])
1537       AC_DEFINE_UNQUOTED(USE_YASSLEMUL, 1,
1538         [Define to 1 if using yaSSL in OpenSSL compatibility mode.])
1539       curl_ssl_msg="enabled (OpenSSL emulation by yaSSL)"
1540     ],[
1541       AC_MSG_RESULT([no])
1542     ])
1543   fi
1544
1545   if test "$OPENSSL_ENABLED" = "1"; then
1546     if test -n "$LIB_OPENSSL"; then
1547        dnl when the ssl shared libs were found in a path that the run-time
1548        dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
1549        dnl to prevent further configure tests to fail due to this
1550
1551        LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIB_OPENSSL"
1552        export LD_LIBRARY_PATH
1553        AC_MSG_NOTICE([Added $LIB_OPENSSL to LD_LIBRARY_PATH])
1554     fi
1555     CURL_CHECK_OPENSSL_API
1556   fi
1557
1558 fi
1559
1560 dnl **********************************************************************
1561 dnl Check for the presence of ZLIB libraries and headers
1562 dnl **********************************************************************
1563
1564 dnl Check for & handle argument to --with-zlib.
1565
1566 _cppflags=$CPPFLAGS
1567 _ldflags=$LDFLAGS
1568 AC_ARG_WITH(zlib,
1569 AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH])
1570 AC_HELP_STRING([--without-zlib],[disable use of zlib]),
1571                [OPT_ZLIB="$withval"])
1572
1573 if test "$OPT_ZLIB" = "no" ; then
1574     AC_MSG_WARN([zlib disabled])
1575 else
1576   if test "$OPT_ZLIB" = "yes" ; then
1577      OPT_ZLIB=""
1578   fi
1579
1580   if test -z "$OPT_ZLIB" ; then
1581     dnl check for the lib first without setting any new path, since many
1582     dnl people have it in the default path
1583
1584     AC_CHECK_LIB(z, inflateEnd,
1585                    dnl libz found, set the variable
1586                    [HAVE_LIBZ="1"],
1587                    dnl if no lib found, try /usr/local
1588                    [OPT_ZLIB="/usr/local"])
1589
1590   fi
1591
1592   dnl Add a nonempty path to the compiler flags
1593   if test -n "$OPT_ZLIB"; then
1594      CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
1595      LDFLAGS="$LDFLAGS -L$OPT_ZLIB/lib$libsuff"
1596   fi
1597
1598   AC_CHECK_HEADER(zlib.h,
1599     [
1600     dnl zlib.h was found
1601     HAVE_ZLIB_H="1"
1602     dnl if the lib wasn't found already, try again with the new paths
1603     if test "$HAVE_LIBZ" != "1"; then
1604       AC_CHECK_LIB(z, gzread,
1605                    [
1606                    dnl the lib was found!
1607                    HAVE_LIBZ="1"
1608                    ],
1609                    [ CPPFLAGS=$_cppflags
1610                    LDFLAGS=$_ldflags])
1611     fi
1612     ],
1613     [
1614       dnl zlib.h was not found, restore the flags
1615       CPPFLAGS=$_cppflags
1616       LDFLAGS=$_ldflags]
1617     )
1618
1619   if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
1620   then
1621     AC_MSG_WARN([configure found only the libz lib, not the header file!])
1622     HAVE_LIBZ=""
1623   elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
1624   then
1625     AC_MSG_WARN([configure found only the libz header file, not the lib!])
1626   elif test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" = "1"
1627   then
1628     dnl both header and lib were found!
1629     AC_SUBST(HAVE_LIBZ)
1630     AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
1631     AC_DEFINE(HAVE_LIBZ, 1, [if zlib is available])
1632
1633     CURL_LIBS="$CURL_LIBS -lz"
1634     LIBS="$LIBS -lz"
1635
1636     dnl replace 'HAVE_LIBZ' in the automake makefile.ams
1637     AMFIXLIB="1"
1638     AC_MSG_NOTICE([found both libz and libz.h header])
1639     curl_zlib_msg="enabled"
1640   fi
1641 fi
1642
1643 dnl set variable for use in automakefile(s)
1644 AM_CONDITIONAL(HAVE_LIBZ, test x"$AMFIXLIB" = x1)
1645
1646 dnl **********************************************************************
1647 dnl Check for the random seed preferences
1648 dnl **********************************************************************
1649
1650 if test X"$OPENSSL_ENABLED" = X"1"; then
1651   AC_ARG_WITH(egd-socket,
1652   AC_HELP_STRING([--with-egd-socket=FILE],
1653                  [Entropy Gathering Daemon socket pathname]),
1654       [ EGD_SOCKET="$withval" ]
1655   )
1656   if test -n "$EGD_SOCKET" ; then
1657           AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET",
1658           [your Entropy Gathering Daemon socket pathname] )
1659   fi
1660
1661   dnl Check for user-specified random device
1662   AC_ARG_WITH(random,
1663   AC_HELP_STRING([--with-random=FILE],
1664                  [read randomness from FILE (default=/dev/urandom)]),
1665       [ RANDOM_FILE="$withval" ],
1666       [
1667           if test x$cross_compiling != xyes; then
1668             dnl Check for random device
1669             AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
1670           else
1671             AC_MSG_WARN([skipped the /dev/urandom detection when cross-compiling])
1672           fi
1673       ]
1674   )
1675   if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
1676           AC_SUBST(RANDOM_FILE)
1677           AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
1678           [a suitable file to read random data from])
1679   fi
1680 fi
1681
1682 dnl ---
1683 dnl We require OpenSSL with SRP support.
1684 dnl ---
1685 if test "$OPENSSL_ENABLED" = "1"; then
1686   AC_CHECK_LIB(crypto, SRP_Calc_client_key,
1687    [
1688      AC_DEFINE(HAVE_SSLEAY_SRP, 1, [if you have the function SRP_Calc_client_key])
1689      AC_SUBST(HAVE_SSLEAY_SRP, [1])
1690    ])
1691 fi
1692
1693 dnl ----------------------------------------------------
1694 dnl check for GnuTLS
1695 dnl ----------------------------------------------------
1696
1697 dnl Default to compiler & linker defaults for GnuTLS files & libraries.
1698 OPT_GNUTLS=no
1699
1700 AC_ARG_WITH(gnutls,dnl
1701 AC_HELP_STRING([--with-gnutls=PATH],[where to look for GnuTLS, PATH points to the installation root])
1702 AC_HELP_STRING([--without-gnutls], [disable GnuTLS detection]),
1703   OPT_GNUTLS=$withval)
1704
1705 if test "$OPENSSL_ENABLED" != "1"; then
1706
1707   if test X"$OPT_GNUTLS" != Xno; then
1708
1709     addld=""
1710     if test "x$OPT_GNUTLS" = "xyes"; then
1711       dnl this is with no partiular path given
1712       CURL_CHECK_PKGCONFIG(gnutls)
1713
1714       if test "$PKGCONFIG" != "no" ; then
1715         addlib=`$PKGCONFIG --libs-only-l gnutls`
1716         addld=`$PKGCONFIG --libs-only-L gnutls`
1717         addcflags=`$PKGCONFIG --cflags-only-I gnutls`
1718         version=`$PKGCONFIG --modversion gnutls`
1719         gtlslib=`echo $addld | $SED -e 's/-L//'`
1720       else
1721         dnl without pkg-config, we try libgnutls-config as that was how it
1722         dnl used to be done
1723         check=`libgnutls-config --version 2>/dev/null`
1724         if test -n "$check"; then
1725           addlib=`libgnutls-config --libs`
1726           addcflags=`libgnutls-config --cflags`
1727           version=`libgnutls-config --version`
1728           gtlslib=`libgnutls-config --prefix`/lib$libsuff
1729         fi
1730       fi
1731     else
1732       dnl this is with a given path, first check if there's a libgnutls-config
1733       dnl there and if not, make an educated guess
1734       cfg=$OPT_GNUTLS/bin/libgnutls-config
1735       check=`$cfg --version 2>/dev/null`
1736       if test -n "$check"; then
1737         addlib=`$cfg --libs`
1738         addcflags=`$cfg --cflags`
1739         version=`$cfg --version`
1740         gtlslib=`$cfg --prefix`/lib$libsuff
1741       else
1742         dnl without pkg-config and libgnutls-config, we guess a lot!
1743         addlib=-lgnutls
1744         addld=-L$OPT_GNUTLS/lib$libsuff
1745         addcflags=-I$OPT_GNUTLS/include
1746         version="" # we just don't know
1747         gtlslib=$OPT_GNUTLS/lib$libsuff
1748       fi
1749     fi
1750
1751     if test -z "$version"; then
1752       dnl lots of efforts, still no go
1753       version="unknown"
1754     fi
1755
1756     if test -n "$addlib"; then
1757
1758       CLEANLIBS="$LIBS"
1759       CLEANCPPFLAGS="$CPPFLAGS"
1760       CLEADLDFLAGS="$LDFLAGS"
1761
1762       LIBS="$LIBS $addlib"
1763       LDFLAGS="$LDFLAGS $addld"
1764       if test "$addcflags" != "-I/usr/include"; then
1765          CPPFLAGS="$CPPFLAGS $addcflags"
1766       fi
1767
1768       AC_CHECK_LIB(gnutls, gnutls_check_version,
1769        [
1770        AC_DEFINE(USE_GNUTLS, 1, [if GnuTLS is enabled])
1771        AC_SUBST(USE_GNUTLS, [1])
1772        GNUTLS_ENABLED=1
1773        USE_GNUTLS="yes"
1774        curl_ssl_msg="enabled (GnuTLS)"
1775        ],
1776        [
1777          LIBS="$CLEANLIBS"
1778          CPPFLAGS="$CLEANCPPFLAGS"
1779        ])
1780
1781       if test "x$USE_GNUTLS" = "xyes"; then
1782         AC_MSG_NOTICE([detected GnuTLS version $version])
1783
1784         if test -n "$gtlslib"; then
1785           dnl when shared libs were found in a path that the run-time
1786           dnl linker doesn't search through, we need to add it to
1787           dnl LD_LIBRARY_PATH to prevent further configure tests to fail
1788           dnl due to this
1789
1790           LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$gtlslib"
1791           export LD_LIBRARY_PATH
1792           AC_MSG_NOTICE([Added $gtlslib to LD_LIBRARY_PATH])
1793         fi
1794       fi
1795
1796     fi
1797
1798   fi dnl GNUTLS not disabled
1799
1800 fi dnl OPENSSL != 1
1801
1802 dnl ---
1803 dnl Check which crypto backend GnuTLS uses
1804 dnl ---
1805
1806 if test "$GNUTLS_ENABLED" = "1"; then
1807   USE_GNUTLS_NETTLE=
1808   # First check if we can detect either crypto library via transitive linking
1809   AC_CHECK_LIB(gnutls, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ])
1810   if test "$USE_GNUTLS_NETTLE" = ""; then
1811     AC_CHECK_LIB(gnutls, gcry_control, [ USE_GNUTLS_NETTLE=0 ])
1812   fi
1813   # If not, try linking directly to both of them to see if they are available
1814   if test "$USE_GNUTLS_NETTLE" = ""; then
1815     AC_CHECK_LIB(nettle, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ])
1816   fi
1817   if test "$USE_GNUTLS_NETTLE" = ""; then
1818     AC_CHECK_LIB(gcrypt, gcry_control, [ USE_GNUTLS_NETTLE=0 ])
1819   fi
1820   if test "$USE_GNUTLS_NETTLE" = ""; then
1821     AC_MSG_ERROR([GnuTLS found, but neither gcrypt nor nettle found])
1822   fi
1823   if test "$USE_GNUTLS_NETTLE" = "1"; then
1824     AC_DEFINE(USE_GNUTLS_NETTLE, 1, [if GnuTLS uses nettle as crypto backend])
1825     AC_SUBST(USE_GNUTLS_NETTLE, [1])
1826   fi
1827 fi
1828
1829 dnl ---
1830 dnl We require GnuTLS with SRP support.
1831 dnl ---
1832 if test "$GNUTLS_ENABLED" = "1"; then
1833   AC_CHECK_LIB(gnutls, gnutls_srp_verifier,
1834    [
1835      AC_DEFINE(HAVE_GNUTLS_SRP, 1, [if you have the function gnutls_srp_verifier])
1836      AC_SUBST(HAVE_GNUTLS_SRP, [1])
1837    ])
1838 fi
1839
1840 dnl ----------------------------------------------------
1841 dnl check for PolarSSL
1842 dnl ----------------------------------------------------
1843
1844 dnl Default to compiler & linker defaults for PolarSSL files & libraries.
1845 OPT_POLARSSL=no
1846
1847 _cppflags=$CPPFLAGS
1848 _ldflags=$LDFLAGS
1849 AC_ARG_WITH(polarssl,dnl
1850 AC_HELP_STRING([--with-polarssl=PATH],[where to look for PolarSSL, PATH points to the installation root])
1851 AC_HELP_STRING([--without-polarssl], [disable PolarSSL detection]),
1852   OPT_POLARSSL=$withval)
1853
1854 if test "$OPENSSL_ENABLED" != "1"; then
1855
1856   if test X"$OPT_POLARSSL" != Xno; then
1857
1858     if test "$OPT_POLARSSL" = "yes"; then
1859       OPT_POLARSSL=""
1860     fi
1861
1862     if test -z "$OPT_POLARSSL" ; then
1863       dnl check for lib first without setting any new path
1864
1865       AC_CHECK_LIB(polarssl, havege_init,
1866       dnl libpolarssl found, set the variable
1867        [
1868          AC_DEFINE(USE_POLARSSL, 1, [if PolarSSL is enabled])
1869          AC_SUBST(USE_POLARSSL, [1])
1870          POLARSSL_ENABLED=1
1871          USE_POLARSSL="yes"
1872          curl_ssl_msg="enabled (PolarSSL)"
1873         ])
1874     fi
1875
1876     if test "x$USE_POLARSSL" != "xyes"; then
1877       dnl add the path and test again
1878       addld=-L$OPT_POLARSSL/lib$libsuff
1879       addcflags=-I$OPT_POLARSSL/include
1880       polarssllib=$OPT_POLARSSL/lib$libsuff
1881
1882       LDFLAGS="$LDFLAGS $addld"
1883       if test "$addcflags" != "-I/usr/include"; then
1884          CPPFLAGS="$CPPFLAGS $addcflags"
1885       fi
1886
1887       AC_CHECK_LIB(polarssl, ssl_init,
1888        [
1889        AC_DEFINE(USE_POLARSSL, 1, [if PolarSSL is enabled])
1890        AC_SUBST(USE_POLARSSL, [1])
1891        POLARSSL_ENABLED=1
1892        USE_POLARSSL="yes"
1893        curl_ssl_msg="enabled (PolarSSL)"
1894        ],
1895        [
1896          CPPFLAGS=$_cppflags
1897          LDFLAGS=$_ldflags
1898        ])
1899     fi
1900
1901     if test "x$USE_POLARSSL" = "xyes"; then
1902       AC_MSG_NOTICE([detected PolarSSL])
1903
1904       CURL_LIBS="$CURL_LIBS -lpolarssl"
1905       LIBS="$LIBS -lpolarssl"
1906
1907       if test -n "$polarssllib"; then
1908         dnl when shared libs were found in a path that the run-time
1909         dnl linker doesn't search through, we need to add it to
1910         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
1911         dnl due to this
1912
1913         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$polarssllib"
1914         export LD_LIBRARY_PATH
1915         AC_MSG_NOTICE([Added $polarssllib to LD_LIBRARY_PATH])
1916       fi
1917
1918     fi
1919
1920   fi dnl PolarSSL not disabled
1921
1922 fi dnl OPENSSL != 1
1923
1924 dnl ----------------------------------------------------
1925 dnl check for CyaSSL
1926 dnl ----------------------------------------------------
1927
1928 dnl Default to compiler & linker defaults for CyaSSL files & libraries.
1929 OPT_CYASSL=no
1930
1931 _cppflags=$CPPFLAGS
1932 _ldflags=$LDFLAGS
1933 AC_ARG_WITH(cyassl,dnl
1934 AC_HELP_STRING([--with-cyassl=PATH],[where to look for CyaSSL, PATH points to the installation root (default: /usr/local/cyassl)])
1935 AC_HELP_STRING([--without-cyassl], [disable CyaSSL detection]),
1936   OPT_CYASSL=$withval)
1937
1938 if test "$OPENSSL_ENABLED" != "1"; then
1939
1940   if test X"$OPT_CYASSL" != Xno; then
1941
1942     if test "$OPT_CYASSL" = "yes"; then
1943       OPT_CYASSL=""
1944     fi
1945
1946     if test -z "$OPT_CYASSL" ; then
1947       dnl check for lib in default first
1948
1949       trycyassldir="/usr/local/cyassl"
1950
1951       LDFLAGS="$LDFLAGS -L$trycyassldir/lib"
1952       CPPFLAGS="$CPPFLAGS -I$trycyassldir/include"
1953
1954       AC_CHECK_LIB(cyassl, InitCyaSSL,
1955       dnl libcyassl found, set the variable
1956        [
1957          AC_DEFINE(USE_CYASSL, 1, [if CyaSSL is enabled])
1958          AC_SUBST(USE_CYASSL, [1])
1959          CYASSL_ENABLED=1
1960          USE_CYASSL="yes"
1961          curl_ssl_msg="enabled (CyaSSL)"
1962         ])
1963     fi
1964
1965     if test "x$USE_CYASSL" != "xyes"; then
1966       dnl add the path and test again
1967       addld=-L$OPT_CYASSL/lib$libsuff
1968       addcflags=-I$OPT_CYASSL/include
1969       cyassllib=$OPT_CYASSL/lib$libsuff
1970
1971       LDFLAGS="$LDFLAGS $addld"
1972       if test "$addcflags" != "-I/usr/include"; then
1973          CPPFLAGS="$CPPFLAGS $addcflags"
1974       fi
1975
1976       AC_CHECK_LIB(cyassl, InitCyaSSL,
1977        [
1978        AC_DEFINE(USE_CYASSL, 1, [if CyaSSL is enabled])
1979        AC_SUBST(USE_CYASSL, [1])
1980        CYASSL_ENABLED=1
1981        USE_CYASSL="yes"
1982        curl_ssl_msg="enabled (CyaSSL)"
1983        ],
1984        [
1985          CPPFLAGS=$_cppflags
1986          LDFLAGS=$_ldflags
1987        ])
1988     fi
1989
1990     if test "x$USE_CYASSL" = "xyes"; then
1991       AC_MSG_NOTICE([detected CyaSSL])
1992
1993       CURL_LIBS="$CURL_LIBS -lcyassl -lm"
1994       LIBS="$LIBS -lcyassl -lm"
1995
1996       if test -n "$cyassllib"; then
1997         dnl when shared libs were found in a path that the run-time
1998         dnl linker doesn't search through, we need to add it to
1999         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
2000         dnl due to this
2001
2002         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$cyassllib"
2003         export LD_LIBRARY_PATH
2004         AC_MSG_NOTICE([Added $cyassllib to LD_LIBRARY_PATH])
2005       fi
2006
2007     fi
2008
2009   fi dnl CyaSSL not disabled
2010
2011 fi dnl OPENSSL != 1
2012
2013 dnl ----------------------------------------------------
2014 dnl NSS. Only check if GnuTLS and OpenSSL are not enabled
2015 dnl ----------------------------------------------------
2016
2017 dnl Default to compiler & linker defaults for NSS files & libraries.
2018 OPT_NSS=no
2019
2020 AC_ARG_WITH(nss,dnl
2021 AC_HELP_STRING([--with-nss=PATH],[where to look for NSS, PATH points to the installation root])
2022 AC_HELP_STRING([--without-nss], [disable NSS detection]),
2023   OPT_NSS=$withval)
2024
2025 if test "$OPENSSL_ENABLED" != "1" -a "$GNUTLS_ENABLED" != "1"; then
2026
2027   if test X"$OPT_NSS" != Xno; then
2028     if test "x$OPT_NSS" = "xyes"; then
2029
2030       CURL_CHECK_PKGCONFIG(nss)
2031
2032       if test "$PKGCONFIG" != "no" ; then
2033         addlib=`$PKGCONFIG --libs nss`
2034         addcflags=`$PKGCONFIG --cflags nss`
2035         version=`$PKGCONFIG --modversion nss`
2036         nssprefix=`$PKGCONFIG --variable=prefix nss`
2037       else
2038         dnl Without pkg-config, we check for nss-config
2039
2040         check=`nss-config --version 2>/dev/null`
2041         if test -n "$check"; then
2042           addlib=`nss-config --libs`
2043           addcflags=`nss-config --cflags`
2044           version=`nss-config --version`
2045           nssprefix=`nss-config --prefix`
2046         else
2047           addlib="-lnss3"
2048           addcflags=""
2049           version="unknown"
2050         fi
2051       fi
2052     else
2053         # Without pkg-config, we'll kludge in some defaults
2054         addlib="-L$OPT_NSS/lib -lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl"
2055         addcflags="-I$OPT_NSS/include"
2056         version="unknown"
2057         nssprefix=$OPT_NSS
2058     fi
2059
2060     dnl Check for functionPK11_CreateGenericObject
2061     dnl this is needed for using the PEM PKCS#11 module
2062     AC_CHECK_LIB(nss3, PK11_CreateGenericObject,
2063      [
2064      AC_DEFINE(HAVE_PK11_CREATEGENERICOBJECT, 1, [if you have the function PK11_CreateGenericObject])
2065      AC_SUBST(HAVE_PK11_CREATEGENERICOBJECT, [1])
2066      ])
2067     if test -n "$addlib"; then
2068
2069       CLEANLIBS="$LIBS"
2070       CLEANCPPFLAGS="$CPPFLAGS"
2071
2072       LIBS="$LIBS $addlib"
2073       if test "$addcflags" != "-I/usr/include"; then
2074          CPPFLAGS="$CPPFLAGS $addcflags"
2075       fi
2076
2077       AC_CHECK_LIB(nss3, NSS_Initialize,
2078        [
2079        AC_DEFINE(USE_NSS, 1, [if NSS is enabled])
2080        AC_SUBST(USE_NSS, [1])
2081        USE_NSS="yes"
2082        NSS_ENABLED=1
2083        curl_ssl_msg="enabled (NSS)"
2084        ],
2085        [
2086          LIBS="$CLEANLIBS"
2087          CPPFLAGS="$CLEANCPPFLAGS"
2088        ])
2089
2090       if test "x$USE_NSS" = "xyes"; then
2091         AC_MSG_NOTICE([detected NSS version $version])
2092
2093         dnl when shared libs were found in a path that the run-time
2094         dnl linker doesn't search through, we need to add it to
2095         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
2096         dnl due to this
2097
2098         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$nssprefix/lib$libsuff"
2099         export LD_LIBRARY_PATH
2100         AC_MSG_NOTICE([Added $nssprefix/lib$libsuff to LD_LIBRARY_PATH])
2101       fi
2102
2103     fi
2104
2105   fi dnl NSS not disabled
2106
2107 fi dnl OPENSSL != 1 -a GNUTLS_ENABLED != 1
2108
2109 OPT_AXTLS=off
2110
2111 AC_ARG_WITH(axtls,dnl
2112 AC_HELP_STRING([--with-axtls=PATH],[Where to look for axTLS, PATH points to the axTLS installation prefix (default: /usr/local).  Ignored if another SSL engine is selected.])
2113 AC_HELP_STRING([--without-axtls], [disable axTLS]),
2114   OPT_AXTLS=$withval)
2115
2116 if test "$curl_ssl_msg" = "$init_ssl_msg"; then
2117   if test X"$OPT_AXTLS" != Xno; then
2118     dnl backup the pre-axtls variables
2119     CLEANLDFLAGS="$LDFLAGS"
2120     CLEANCPPFLAGS="$CPPFLAGS"
2121     CLEANLIBS="$LIBS"
2122
2123     case "$OPT_AXTLS" in
2124     yes)
2125       dnl --with-axtls (without path) used
2126       PREFIX_AXTLS=/usr/local
2127       LIB_AXTLS="$PREFIX_AXTLS/lib"
2128       LDFLAGS="$LDFLAGS -L$LIB_AXTLS"
2129       CPPFLAGS="$CPPFLAGS -I$PREFIX_AXTLS/include"
2130       ;;
2131     off)
2132       dnl no --with-axtls option given, just check default places
2133       PREFIX_AXTLS=
2134       ;;
2135     *)
2136       dnl check the given --with-axtls spot
2137       PREFIX_AXTLS=$OPT_AXTLS
2138       LIB_AXTLS="$PREFIX_AXTLS/lib"
2139       LDFLAGS="$LDFLAGS -L$LIB_AXTLS"
2140       CPPFLAGS="$CPPFLAGS -I$PREFIX_AXTLS/include"
2141       ;;
2142     esac
2143
2144     AC_CHECK_LIB(axtls, ssl_version,[
2145       LIBS="-laxtls $LIBS"
2146       AC_DEFINE(USE_AXTLS, 1, [if axTLS is enabled])
2147       AC_SUBST(USE_AXTLS, [1])
2148       AXTLS_ENABLED=1
2149       USE_AXTLS="yes"
2150       curl_ssl_msg="enabled (axTLS)"
2151
2152
2153       LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIB_AXTLS"
2154       export LD_LIBRARY_PATH
2155       AC_MSG_NOTICE([Added $LIB_AXTLS to LD_LIBRARY_PATH])
2156       ],[
2157       LDFLAGS="$CLEANLDFLAGS"
2158       CPPFLAGS="$CLEANCPPFLAGS"
2159       LIBS="$CLEANLIBS"
2160     ])
2161   fi
2162 fi
2163
2164 if test "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$POLARSSL_ENABLED$AXTLS_ENABLED$CYASSL_ENABLED" = "x"; then
2165   AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
2166   AC_MSG_WARN([Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss or --with-axtls to address this.])
2167 else
2168   # SSL is enabled, genericly
2169   AC_SUBST(SSL_ENABLED)
2170   SSL_ENABLED="1"
2171 fi
2172
2173 dnl **********************************************************************
2174 dnl Check for the CA bundle
2175 dnl **********************************************************************
2176
2177 CURL_CHECK_CA_BUNDLE
2178
2179 dnl **********************************************************************
2180 dnl Check for the presence of LIBSSH2 libraries and headers
2181 dnl **********************************************************************
2182
2183 dnl Default to compiler & linker defaults for LIBSSH2 files & libraries.
2184 OPT_LIBSSH2=off
2185 AC_ARG_WITH(libssh2,dnl
2186 AC_HELP_STRING([--with-libssh2=PATH],[Where to look for libssh2, PATH points to the LIBSSH2 installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
2187 AC_HELP_STRING([--without-libssh2], [disable LIBSSH2]),
2188   OPT_LIBSSH2=$withval)
2189
2190 if test X"$OPT_LIBSSH2" != Xno; then
2191   dnl backup the pre-libssh2 variables
2192   CLEANLDFLAGS="$LDFLAGS"
2193   CLEANCPPFLAGS="$CPPFLAGS"
2194   CLEANLIBS="$LIBS"
2195
2196   case "$OPT_LIBSSH2" in
2197   yes)
2198     dnl --with-libssh2 (without path) used
2199     CURL_CHECK_PKGCONFIG(libssh2)
2200
2201     if test "$PKGCONFIG" != "no" ; then
2202       LIB_SSH2=`$PKGCONFIG --libs-only-l libssh2`
2203       LD_SSH2=`$PKGCONFIG --libs-only-L libssh2`
2204       CPP_SSH2=`$PKGCONFIG --cflags-only-I libssh2`
2205       version=`$PKGCONFIG --modversion libssh2`
2206       DIR_SSH2=`echo $LD_SSH2 | $SED -e 's/-L//'`
2207     fi
2208
2209     ;;
2210   off)
2211     dnl no --with-libssh2 option given, just check default places
2212     ;;
2213   *)
2214     dnl use the given --with-libssh2 spot
2215     PREFIX_SSH2=$OPT_LIBSSH2
2216     ;;
2217   esac
2218
2219   dnl if given with a prefix, we set -L and -I based on that
2220   if test -n "$PREFIX_SSH2"; then
2221     LIB_SSH2="-lssh2"
2222     LD_SSH2=-L${PREFIX_SSH2}/lib$libsuff
2223     CPP_SSH2=-I${PREFIX_SSH2}/include
2224     DIR_SSH2=${PREFIX_SSH2}/lib$libsuff
2225   fi
2226
2227   LDFLAGS="$LDFLAGS $LD_SSH2"
2228   CPPFLAGS="$CPPFLAGS $CPP_SSH2"
2229   LIBS="$LIBS $LIB_SSH2"
2230
2231   AC_CHECK_LIB(ssh2, libssh2_channel_open_ex)
2232
2233   AC_CHECK_HEADERS(libssh2.h,
2234     curl_ssh_msg="enabled (libSSH2)"
2235     LIBSSH2_ENABLED=1
2236     AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use])
2237     AC_SUBST(USE_LIBSSH2, [1])
2238   )
2239
2240   if test X"$OPT_LIBSSH2" != Xoff &&
2241      test "$LIBSSH2_ENABLED" != "1"; then
2242     AC_MSG_ERROR([libSSH2 libs and/or directories were not found where specified!])
2243   fi
2244
2245   if test "$LIBSSH2_ENABLED" = "1"; then
2246     if test -n "$DIR_SSH2"; then
2247        dnl when the libssh2 shared libs were found in a path that the run-time
2248        dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
2249        dnl to prevent further configure tests to fail due to this
2250
2251        dnl libssh2_version is a post 1.0 addition
2252        dnl libssh2_init and libssh2_exit were added in 1.2.5
2253        dnl libssh2_scp_send64 was added in 1.2.6
2254        dnl libssh2_session_handshake was added in 1.2.8
2255        AC_CHECK_FUNCS( libssh2_version libssh2_init libssh2_exit \
2256                        libssh2_scp_send64 libssh2_session_handshake)
2257
2258        LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DIR_SSH2"
2259        export LD_LIBRARY_PATH
2260        AC_MSG_NOTICE([Added $DIR_SSH2 to LD_LIBRARY_PATH])
2261     fi
2262   else
2263     dnl no libssh2, revert back to clean variables
2264     LDFLAGS=$CLEANLDFLAGS
2265     CPPFLAGS=$CLEANCPPFLAGS
2266     LIBS=$CLEANLIBS
2267   fi
2268 fi
2269
2270 dnl **********************************************************************
2271 dnl Check for the presence of LIBRTMP libraries and headers
2272 dnl **********************************************************************
2273
2274 dnl Default to compiler & linker defaults for LIBRTMP files & libraries.
2275 OPT_LIBRTMP=off
2276 AC_ARG_WITH(librtmp,dnl
2277 AC_HELP_STRING([--with-librtmp=PATH],[Where to look for librtmp, PATH points to the LIBRTMP installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
2278 AC_HELP_STRING([--without-librtmp], [disable LIBRTMP]),
2279   OPT_LIBRTMP=$withval)
2280
2281 if test X"$OPT_LIBRTMP" != Xno; then
2282   dnl backup the pre-librtmp variables
2283   CLEANLDFLAGS="$LDFLAGS"
2284   CLEANCPPFLAGS="$CPPFLAGS"
2285   CLEANLIBS="$LIBS"
2286
2287   case "$OPT_LIBRTMP" in
2288   yes)
2289     dnl --with-librtmp (without path) used
2290     CURL_CHECK_PKGCONFIG(librtmp)
2291
2292     if test "$PKGCONFIG" != "no" ; then
2293       LIB_RTMP=`$PKGCONFIG --libs-only-l librtmp`
2294       LD_RTMP=`$PKGCONFIG --libs-only-L librtmp`
2295       CPP_RTMP=`$PKGCONFIG --cflags-only-I librtmp`
2296       version=`$PKGCONFIG --modversion librtmp`
2297       DIR_RTMP=`echo $LD_RTMP | $SED -e 's/-L//'`
2298     else
2299       dnl To avoid link errors, we do not allow --librtmp without
2300       dnl a pkgconfig file
2301       AC_MSG_ERROR([--librtmp was specified but could not find librtmp pkgconfig file.])
2302     fi
2303
2304     ;;
2305   off)
2306     dnl no --with-librtmp option given, just check default places
2307     LIB_RTMP="-lrtmp"
2308     ;;
2309   *)
2310     dnl use the given --with-librtmp spot
2311     PREFIX_RTMP=$OPT_LIBRTMP
2312     ;;
2313   esac
2314
2315   dnl if given with a prefix, we set -L and -I based on that
2316   if test -n "$PREFIX_RTMP"; then
2317     LD_RTMP=-L${PREFIX_RTMP}/lib$libsuff
2318     CPP_RTMP=-I${PREFIX_RTMP}/include
2319     DIR_RTMP=${PREFIX_RTMP}/lib$libsuff
2320   fi
2321
2322   LDFLAGS="$LDFLAGS $LD_RTMP"
2323   CPPFLAGS="$CPPFLAGS $CPP_RTMP"
2324   LIBS="$LIBS $LIB_RTMP"
2325
2326   AC_CHECK_LIB(rtmp, RTMP_Init,
2327     [
2328      AC_CHECK_HEADERS(librtmp/rtmp.h,
2329         curl_rtmp_msg="enabled (librtmp)"
2330         LIBRTMP_ENABLED=1
2331         AC_DEFINE(USE_LIBRTMP, 1, [if librtmp is in use])
2332         AC_SUBST(USE_LIBRTMP, [1])
2333      )
2334     ],
2335       dnl not found, revert back to clean variables
2336       LDFLAGS=$CLEANLDFLAGS
2337       CPPFLAGS=$CLEANCPPFLAGS
2338       LIBS=$CLEANLIBS
2339   )
2340
2341   if test X"$OPT_LIBRTMP" != Xoff &&
2342      test "$LIBRTMP_ENABLED" != "1"; then
2343     AC_MSG_ERROR([librtmp libs and/or directories were not found where specified!])
2344   fi
2345
2346 fi
2347
2348 dnl **********************************************************************
2349 dnl Check for the presence of IDN libraries and headers
2350 dnl **********************************************************************
2351
2352 AC_MSG_CHECKING([whether to build with libidn])
2353 OPT_IDN="default"
2354 AC_ARG_WITH(libidn,
2355 AC_HELP_STRING([--with-libidn=PATH],[Enable libidn usage])
2356 AC_HELP_STRING([--without-libidn],[Disable libidn usage]),
2357   [OPT_IDN=$withval])
2358 case "$OPT_IDN" in
2359   no)
2360     dnl --without-libidn option used
2361     want_idn="no"
2362     AC_MSG_RESULT([no])
2363     ;;
2364   default)
2365     dnl configure option not specified
2366     want_idn="yes"
2367     want_idn_path="default"
2368     AC_MSG_RESULT([(assumed) yes])
2369     ;;
2370   yes)
2371     dnl --with-libidn option used without path
2372     want_idn="yes"
2373     want_idn_path="default"
2374     AC_MSG_RESULT([yes])
2375     ;;
2376   *)
2377     dnl --with-libidn option used with path
2378     want_idn="yes"
2379     want_idn_path="$withval"
2380     AC_MSG_RESULT([yes ($withval)])
2381     ;;
2382 esac
2383
2384 if test "$want_idn" = "yes"; then
2385   dnl idn library support has been requested
2386   clean_CPPFLAGS="$CPPFLAGS"
2387   clean_LDFLAGS="$LDFLAGS"
2388   clean_LIBS="$LIBS"
2389   PKGCONFIG="no"
2390   #
2391   if test "$want_idn_path" != "default"; then
2392     dnl path has been specified
2393     IDN_PCDIR="$want_idn_path/lib$libsuff/pkgconfig"
2394     CURL_CHECK_PKGCONFIG(libidn, [$IDN_PCDIR])
2395     if test "$PKGCONFIG" != "no"; then
2396       IDN_LIBS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
2397         $PKGCONFIG --libs-only-l libidn 2>/dev/null`
2398       IDN_LDFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
2399         $PKGCONFIG --libs-only-L libidn 2>/dev/null`
2400       IDN_CPPFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
2401         $PKGCONFIG --cflags-only-I libidn 2>/dev/null`
2402       IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
2403     else
2404       dnl pkg-config not available or provides no info
2405       IDN_LIBS="-lidn"
2406       IDN_LDFLAGS="-L$want_idn_path/lib$libsuff"
2407       IDN_CPPFLAGS="-I$want_idn_path/include"
2408       IDN_DIR="$want_idn_path/lib$libsuff"
2409     fi
2410   else
2411     dnl path not specified
2412     CURL_CHECK_PKGCONFIG(libidn)
2413     if test "$PKGCONFIG" != "no"; then
2414       IDN_LIBS=`$PKGCONFIG --libs-only-l libidn 2>/dev/null`
2415       IDN_LDFLAGS=`$PKGCONFIG --libs-only-L libidn 2>/dev/null`
2416       IDN_CPPFLAGS=`$PKGCONFIG --cflags-only-I libidn 2>/dev/null`
2417       IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
2418     else
2419       dnl pkg-config not available or provides no info
2420       IDN_LIBS="-lidn"
2421     fi
2422   fi
2423   #
2424   if test "$PKGCONFIG" != "no"; then
2425     AC_MSG_NOTICE([pkg-config: IDN_LIBS: "$IDN_LIBS"])
2426     AC_MSG_NOTICE([pkg-config: IDN_LDFLAGS: "$IDN_LDFLAGS"])
2427     AC_MSG_NOTICE([pkg-config: IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
2428     AC_MSG_NOTICE([pkg-config: IDN_DIR: "$IDN_DIR"])
2429   else
2430     AC_MSG_NOTICE([IDN_LIBS: "$IDN_LIBS"])
2431     AC_MSG_NOTICE([IDN_LDFLAGS: "$IDN_LDFLAGS"])
2432     AC_MSG_NOTICE([IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
2433     AC_MSG_NOTICE([IDN_DIR: "$IDN_DIR"])
2434   fi
2435   #
2436   CPPFLAGS="$IDN_CPPFLAGS $CPPFLAGS"
2437   LDFLAGS="$IDN_LDFLAGS $LDFLAGS"
2438   LIBS="$IDN_LIBS $LIBS"
2439   #
2440   AC_MSG_CHECKING([if idna_to_ascii_4i can be linked])
2441   AC_LINK_IFELSE([
2442     AC_LANG_FUNC_LINK_TRY([idna_to_ascii_4i])
2443   ],[
2444     AC_MSG_RESULT([yes])
2445     tst_links_libidn="yes"
2446   ],[
2447     AC_MSG_RESULT([no])
2448     tst_links_libidn="no"
2449   ])
2450   if test "$tst_links_libidn" = "no"; then
2451     AC_MSG_CHECKING([if idna_to_ascii_lz can be linked])
2452     AC_LINK_IFELSE([
2453       AC_LANG_FUNC_LINK_TRY([idna_to_ascii_lz])
2454     ],[
2455       AC_MSG_RESULT([yes])
2456       tst_links_libidn="yes"
2457     ],[
2458       AC_MSG_RESULT([no])
2459       tst_links_libidn="no"
2460     ])
2461   fi
2462   #
2463   if test "$tst_links_libidn" = "yes"; then
2464     AC_DEFINE(HAVE_LIBIDN, 1, [Define to 1 if you have the `idn' library (-lidn).])
2465     dnl different versions of libidn have different setups of these:
2466     AC_CHECK_FUNCS( idn_free idna_strerror tld_strerror )
2467     AC_CHECK_HEADERS( idn-free.h tld.h )
2468     if test "x$ac_cv_header_tld_h" = "xyes"; then
2469       AC_SUBST([IDN_ENABLED], [1])
2470       curl_idn_msg="enabled"
2471       if test -n "$IDN_DIR"; then
2472         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$IDN_DIR"
2473         export LD_LIBRARY_PATH
2474         AC_MSG_NOTICE([Added $IDN_DIR to LD_LIBRARY_PATH])
2475       fi
2476     else
2477       AC_MSG_WARN([Libraries for IDN support too old: IDN disabled])
2478       CPPFLAGS="$clean_CPPFLAGS"
2479       LDFLAGS="$clean_LDFLAGS"
2480       LIBS="$clean_LIBS"
2481     fi
2482   else
2483     AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
2484     CPPFLAGS="$clean_CPPFLAGS"
2485     LDFLAGS="$clean_LDFLAGS"
2486     LIBS="$clean_LIBS"
2487   fi
2488 fi
2489
2490
2491 dnl Let's hope this split URL remains working:
2492 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
2493 dnl genprogc/thread_quick_ref.htm
2494
2495
2496 dnl **********************************************************************
2497 dnl Back to "normal" configuring
2498 dnl **********************************************************************
2499
2500 dnl Checks for header files.
2501 AC_HEADER_STDC
2502
2503 CURL_CHECK_HEADER_MALLOC
2504 CURL_CHECK_HEADER_MEMORY
2505
2506 dnl Now check for the very most basic headers. Then we can use these
2507 dnl ones as default-headers when checking for the rest!
2508 AC_CHECK_HEADERS(
2509         sys/types.h \
2510         sys/time.h \
2511         sys/select.h \
2512         sys/socket.h \
2513         sys/ioctl.h \
2514         sys/uio.h \
2515         assert.h \
2516         unistd.h \
2517         stdlib.h \
2518         limits.h \
2519         arpa/inet.h \
2520         net/if.h \
2521         netinet/in.h \
2522         sys/un.h \
2523         netinet/tcp.h \
2524         netdb.h \
2525         sys/sockio.h \
2526         sys/stat.h \
2527         sys/param.h \
2528         termios.h \
2529         termio.h \
2530         sgtty.h \
2531         fcntl.h \
2532         alloca.h \
2533         time.h \
2534         io.h \
2535         pwd.h \
2536         utime.h \
2537         sys/utime.h \
2538         sys/poll.h \
2539         poll.h \
2540         socket.h \
2541         sys/resource.h \
2542         libgen.h \
2543         locale.h \
2544         errno.h \
2545         stdbool.h \
2546         arpa/tftp.h \
2547         sys/filio.h \
2548         sys/wait.h \
2549         setjmp.h,
2550 dnl to do if not found
2551 [],
2552 dnl to do if found
2553 [],
2554 dnl default includes
2555 [
2556 #ifdef HAVE_SYS_TYPES_H
2557 #include <sys/types.h>
2558 #endif
2559 #ifdef HAVE_SYS_TIME_H
2560 #include <sys/time.h>
2561 #endif
2562 #ifdef HAVE_SYS_SELECT_H
2563 #include <sys/select.h>
2564 #endif
2565 #ifdef HAVE_SYS_SOCKET_H
2566 #include <sys/socket.h>
2567 #endif
2568 #ifdef HAVE_NETINET_IN_H
2569 #include <netinet/in.h>
2570 #endif
2571 #ifdef HAVE_SYS_UN_H
2572 #include <sys/un.h>
2573 #endif
2574 ]
2575 )
2576
2577 dnl Checks for typedefs, structures, and compiler characteristics.
2578 AC_C_CONST
2579 CURL_CHECK_VARIADIC_MACROS
2580 AC_TYPE_SIZE_T
2581 AC_HEADER_TIME
2582 CURL_CHECK_STRUCT_TIMEVAL
2583 CURL_VERIFY_RUNTIMELIBS
2584
2585 AC_CHECK_SIZEOF(size_t)
2586 AC_CHECK_SIZEOF(long)
2587 AC_CHECK_SIZEOF(int)
2588 AC_CHECK_SIZEOF(short)
2589 CURL_CONFIGURE_LONG
2590 AC_CHECK_SIZEOF(time_t)
2591 AC_CHECK_SIZEOF(off_t)
2592
2593 soname_bump=no
2594 if test x"$ac_cv_native_windows" != "xyes" &&
2595    test $ac_cv_sizeof_off_t -ne $curl_sizeof_curl_off_t; then
2596   AC_MSG_WARN([This libcurl built is probably not ABI compatible with previous])
2597   AC_MSG_WARN([builds! You MUST read lib/README.curl_off_t to figure it out.])
2598   soname_bump=yes
2599 fi
2600
2601
2602 AC_CHECK_TYPE(long long,
2603    [AC_DEFINE(HAVE_LONGLONG, 1,
2604       [Define to 1 if the compiler supports the 'long long' data type.])]
2605    longlong="yes"
2606 )
2607
2608 if test "xyes" = "x$longlong"; then
2609   AC_MSG_CHECKING([if numberLL works])
2610   AC_COMPILE_IFELSE([
2611     AC_LANG_PROGRAM([[
2612     ]],[[
2613       long long val = 1000LL;
2614     ]])
2615   ],[
2616     AC_MSG_RESULT([yes])
2617     AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
2618   ],[
2619     AC_MSG_RESULT([no])
2620   ])
2621 fi
2622
2623
2624 # check for ssize_t
2625 AC_CHECK_TYPE(ssize_t, ,
2626    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
2627
2628 # check for bool type
2629 AC_CHECK_TYPE([bool],[
2630   AC_DEFINE(HAVE_BOOL_T, 1,
2631     [Define to 1 if bool is an available type.])
2632 ], ,[
2633 #ifdef HAVE_SYS_TYPES_H
2634 #include <sys/types.h>
2635 #endif
2636 #ifdef HAVE_STDBOOL_H
2637 #include <stdbool.h>
2638 #endif
2639 ])
2640
2641 CURL_CONFIGURE_CURL_SOCKLEN_T
2642
2643 TYPE_IN_ADDR_T
2644
2645 TYPE_SOCKADDR_STORAGE
2646
2647 TYPE_SIG_ATOMIC_T
2648
2649 AC_TYPE_SIGNAL
2650
2651 CURL_CHECK_FUNC_SELECT
2652
2653 CURL_CHECK_FUNC_RECV
2654 CURL_CHECK_FUNC_RECVFROM
2655 CURL_CHECK_FUNC_SEND
2656 CURL_CHECK_MSG_NOSIGNAL
2657
2658 CURL_CHECK_FUNC_ALARM
2659 CURL_CHECK_FUNC_BASENAME
2660 CURL_CHECK_FUNC_CLOSESOCKET
2661 CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
2662 CURL_CHECK_FUNC_CONNECT
2663 CURL_CHECK_FUNC_FCNTL
2664 CURL_CHECK_FUNC_FDOPEN
2665 CURL_CHECK_FUNC_FREEADDRINFO
2666 CURL_CHECK_FUNC_FREEIFADDRS
2667 CURL_CHECK_FUNC_FSETXATTR
2668 CURL_CHECK_FUNC_FTRUNCATE
2669 CURL_CHECK_FUNC_GETADDRINFO
2670 CURL_CHECK_FUNC_GAI_STRERROR
2671 CURL_CHECK_FUNC_GETHOSTBYADDR
2672 CURL_CHECK_FUNC_GETHOSTBYADDR_R
2673 CURL_CHECK_FUNC_GETHOSTBYNAME
2674 CURL_CHECK_FUNC_GETHOSTBYNAME_R
2675 CURL_CHECK_FUNC_GETHOSTNAME
2676 CURL_CHECK_FUNC_GETIFADDRS
2677 CURL_CHECK_FUNC_GETSERVBYPORT_R
2678 CURL_CHECK_FUNC_GMTIME_R
2679 CURL_CHECK_FUNC_INET_NTOA_R
2680 CURL_CHECK_FUNC_INET_NTOP
2681 CURL_CHECK_FUNC_INET_PTON
2682 CURL_CHECK_FUNC_IOCTL
2683 CURL_CHECK_FUNC_IOCTLSOCKET
2684 CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
2685 CURL_CHECK_FUNC_LOCALTIME_R
2686 CURL_CHECK_FUNC_MEMRCHR
2687 CURL_CHECK_FUNC_POLL
2688 CURL_CHECK_FUNC_SETSOCKOPT
2689 CURL_CHECK_FUNC_SIGACTION
2690 CURL_CHECK_FUNC_SIGINTERRUPT
2691 CURL_CHECK_FUNC_SIGNAL
2692 CURL_CHECK_FUNC_SIGSETJMP
2693 CURL_CHECK_FUNC_SOCKET
2694 CURL_CHECK_FUNC_SOCKETPAIR
2695 CURL_CHECK_FUNC_STRCASECMP
2696 CURL_CHECK_FUNC_STRCASESTR
2697 CURL_CHECK_FUNC_STRCMPI
2698 CURL_CHECK_FUNC_STRDUP
2699 CURL_CHECK_FUNC_STRERROR_R
2700 CURL_CHECK_FUNC_STRICMP
2701 CURL_CHECK_FUNC_STRLCAT
2702 CURL_CHECK_FUNC_STRNCASECMP
2703 CURL_CHECK_FUNC_STRNCMPI
2704 CURL_CHECK_FUNC_STRNICMP
2705 CURL_CHECK_FUNC_STRSTR
2706 CURL_CHECK_FUNC_STRTOK_R
2707 CURL_CHECK_FUNC_STRTOLL
2708 CURL_CHECK_FUNC_WRITEV
2709
2710 case $host in
2711   *msdosdjgpp)
2712      ac_cv_func_pipe=no
2713      skipcheck_pipe=yes
2714      AC_MSG_NOTICE([skip check for pipe on msdosdjgpp])
2715     ;;
2716 esac
2717
2718 AC_CHECK_FUNCS([fork \
2719   geteuid \
2720   getpass_r \
2721   getppid \
2722   getprotobyname \
2723   getpwuid \
2724   getrlimit \
2725   gettimeofday \
2726   inet_addr \
2727   perror \
2728   pipe \
2729   setlocale \
2730   setmode \
2731   setrlimit \
2732   uname \
2733   utime
2734 ],[
2735 ],[
2736   func="$ac_func"
2737   eval skipcheck=\$skipcheck_$func
2738   if test "x$skipcheck" != "xyes"; then
2739     AC_MSG_CHECKING([deeper for $func])
2740     AC_LINK_IFELSE([
2741       AC_LANG_PROGRAM([[
2742       ]],[[
2743         $func ();
2744       ]])
2745     ],[
2746       AC_MSG_RESULT([yes])
2747       eval "ac_cv_func_$func=yes"
2748       AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
2749         [Define to 1 if you have the $func function.])
2750     ],[
2751       AC_MSG_RESULT([but still no])
2752     ])
2753   fi
2754 ])
2755
2756 dnl Check if the getnameinfo function is available
2757 dnl and get the types of five of its arguments.
2758 CURL_CHECK_FUNC_GETNAMEINFO
2759
2760 if test "$ipv6" = "yes"; then
2761   if test "$ac_cv_func_getaddrinfo" = "yes"; then
2762     AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
2763     IPV6_ENABLED=1
2764     AC_SUBST(IPV6_ENABLED)
2765   fi
2766   CURL_CHECK_NI_WITHSCOPEID
2767 fi
2768
2769 dnl ************************************************************
2770 dnl enable non-blocking communications
2771 dnl
2772 CURL_CHECK_OPTION_NONBLOCKING
2773 CURL_CHECK_NONBLOCKING_SOCKET
2774
2775 dnl ************************************************************
2776 dnl nroff tool stuff
2777 dnl
2778
2779 AC_PATH_PROG( PERL, perl, ,
2780   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
2781 AC_SUBST(PERL)
2782
2783 AC_PATH_PROGS( NROFF, gnroff nroff, ,
2784   $PATH:/usr/bin/:/usr/local/bin )
2785 AC_SUBST(NROFF)
2786
2787 if test -n "$NROFF"; then
2788   dnl only check for nroff options if an nroff command was found
2789
2790   AC_MSG_CHECKING([how to use *nroff to get plain text from man pages])
2791   MANOPT="-man"
2792   mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
2793   if test -z "$mancheck"; then
2794     MANOPT="-mandoc"
2795    mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
2796     if test -z "$mancheck"; then
2797       MANOPT=""
2798       AC_MSG_RESULT([failed])
2799       AC_MSG_WARN([found no *nroff option to get plaintext from man pages])
2800     else
2801       AC_MSG_RESULT([$MANOPT])
2802     fi
2803   else
2804     AC_MSG_RESULT([$MANOPT])
2805   fi
2806   AC_SUBST(MANOPT)
2807 fi
2808
2809 if test -z "$MANOPT"
2810 then
2811   dnl if no nroff tool was found, or no option that could convert man pages
2812   dnl was found, then disable the built-in manual stuff
2813   AC_MSG_WARN([disabling built-in manual])
2814   USE_MANUAL="no";
2815 fi
2816
2817 dnl *************************************************************************
2818 dnl If the manual variable still is set, then we go with providing a built-in
2819 dnl manual
2820
2821 if test "$USE_MANUAL" = "1"; then
2822   AC_DEFINE(USE_MANUAL, 1, [If you want to build curl with the built-in manual])
2823   curl_manual_msg="enabled"
2824 fi
2825
2826 dnl set variable for use in automakefile(s)
2827 AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1)
2828
2829 CURL_CHECK_LIB_ARES
2830 AM_CONDITIONAL(USE_EMBEDDED_ARES, test x$embedded_ares = xyes)
2831
2832 if test "x$ac_cv_native_windows" != "xyes" &&
2833    test "x$enable_shared" = "xyes"; then
2834   build_libhostname=yes
2835 else
2836   build_libhostname=no
2837 fi
2838 AM_CONDITIONAL(BUILD_LIBHOSTNAME, test x$build_libhostname = xyes)
2839
2840 CURL_CHECK_OPTION_THREADED_RESOLVER
2841
2842 if test "x$want_thres" = xyes && test "x$want_ares" = xyes; then
2843   AC_MSG_ERROR(
2844 [Options --enable-threaded-resolver and --enable-ares are mutually exclusive])
2845 fi
2846
2847 if test "$want_thres" = "yes"; then
2848   AC_CHECK_HEADER(pthread.h,
2849     [ AC_DEFINE(HAVE_PTHREAD_H, 1, [if you have <pthread.h>])
2850       save_CFLAGS="$CFLAGS"
2851       CFLAGS="$CFLAGS -pthread"
2852       AC_CHECK_LIB(pthread, pthread_create,
2853         [ AC_MSG_NOTICE([using POSIX threaded DNS lookup])
2854           AC_DEFINE(USE_THREADS_POSIX, 1, [if you want POSIX threaded DNS lookup])
2855           USE_THREADS_POSIX=1
2856           curl_res_msg="threaded"
2857         ],
2858         [ CFLAGS="$save_CFLAGS"])
2859   ])
2860 fi
2861
2862 dnl ************************************************************
2863 dnl disable verbose text strings
2864 dnl
2865 AC_MSG_CHECKING([whether to enable verbose strings])
2866 AC_ARG_ENABLE(verbose,
2867 AC_HELP_STRING([--enable-verbose],[Enable verbose strings])
2868 AC_HELP_STRING([--disable-verbose],[Disable verbose strings]),
2869 [ case "$enableval" in
2870   no)
2871        AC_MSG_RESULT(no)
2872        AC_DEFINE(CURL_DISABLE_VERBOSE_STRINGS, 1, [to disable verbose strings])
2873        curl_verbose_msg="no"
2874        ;;
2875   *)   AC_MSG_RESULT(yes)
2876        ;;
2877   esac ],
2878        AC_MSG_RESULT(yes)
2879 )
2880
2881 dnl ************************************************************
2882 dnl enable SSPI support
2883 dnl
2884 AC_MSG_CHECKING([whether to enable SSPI support (Windows native builds only)])
2885 AC_ARG_ENABLE(sspi,
2886 AC_HELP_STRING([--enable-sspi],[Enable SSPI])
2887 AC_HELP_STRING([--disable-sspi],[Disable SSPI]),
2888 [ case "$enableval" in
2889   yes)
2890        if test "$ac_cv_native_windows" = "yes"; then
2891          AC_MSG_RESULT(yes)
2892          AC_DEFINE(USE_WINDOWS_SSPI, 1, [to enable SSPI support])
2893          AC_SUBST(USE_WINDOWS_SSPI, [1])
2894          curl_sspi_msg="enabled"
2895        else
2896          AC_MSG_RESULT(no)
2897          AC_MSG_WARN([--enable-sspi Ignored. Only supported on native Windows builds.])
2898        fi
2899        ;;
2900   *)
2901        AC_MSG_RESULT(no)
2902        ;;
2903   esac ],
2904        AC_MSG_RESULT(no)
2905 )
2906
2907 dnl ************************************************************
2908 dnl disable cryptographic authentication
2909 dnl
2910 AC_MSG_CHECKING([whether to enable cryptographic authentication methods])
2911 AC_ARG_ENABLE(crypto-auth,
2912 AC_HELP_STRING([--enable-crypto-auth],[Enable cryptographic authentication])
2913 AC_HELP_STRING([--disable-crypto-auth],[Disable cryptographic authentication]),
2914 [ case "$enableval" in
2915   no)
2916        AC_MSG_RESULT(no)
2917        AC_DEFINE(CURL_DISABLE_CRYPTO_AUTH, 1, [to disable cryptographic authentication])
2918        ;;
2919   *)   AC_MSG_RESULT(yes)
2920        ;;
2921   esac ],
2922        AC_MSG_RESULT(yes)
2923 )
2924
2925 CURL_CHECK_OPTION_NTLM_WB
2926
2927 CURL_CHECK_NTLM_WB
2928
2929 dnl ************************************************************
2930 dnl disable TLS-SRP authentication
2931 dnl
2932 AC_MSG_CHECKING([whether to enable TLS-SRP authentication])
2933 AC_ARG_ENABLE(tls-srp,
2934 AC_HELP_STRING([--enable-tls-srp],[Enable TLS-SRP authentication])
2935 AC_HELP_STRING([--disable-tls-srp],[Disable TLS-SRP authentication]),
2936 [ case "$enableval" in
2937   no)
2938        AC_MSG_RESULT(no)
2939        AC_DEFINE(CURL_DISABLE_TLS_SRP, 1, [to disable TLS-SRP authentication])
2940        want_tls_srp=no
2941        ;;
2942   *)   AC_MSG_RESULT(yes)
2943        want_tls_srp=yes
2944        ;;
2945   esac ],
2946        AC_MSG_RESULT(yes)
2947        want_tls_srp=yes
2948 )
2949
2950 if test "$want_tls_srp" = "yes" && ( test "x$HAVE_GNUTLS_SRP" = "x1" || test "x$HAVE_SSLEAY_SRP" = "x1") ; then
2951    AC_DEFINE(USE_TLS_SRP, 1, [Use TLS-SRP authentication])
2952    USE_TLS_SRP=1
2953    curl_tls_srp_msg="enabled"
2954 fi
2955
2956 dnl ************************************************************
2957 dnl disable cookies support
2958 dnl
2959 AC_MSG_CHECKING([whether to enable support for cookies])
2960 AC_ARG_ENABLE(cookies,
2961 AC_HELP_STRING([--enable-cookies],[Enable cookies support])
2962 AC_HELP_STRING([--disable-cookies],[Disable cookies support]),
2963 [ case "$enableval" in
2964   no)
2965        AC_MSG_RESULT(no)
2966        AC_DEFINE(CURL_DISABLE_COOKIES, 1, [to disable cookies support])
2967        ;;
2968   *)   AC_MSG_RESULT(yes)
2969        ;;
2970   esac ],
2971        AC_MSG_RESULT(yes)
2972 )
2973
2974 dnl ************************************************************
2975 dnl Enable hiding of internal symbols in library to reduce its size and
2976 dnl speed dynamic linking of applications.  This currently is only supported
2977 dnl on gcc >= 4.0 and SunPro C.
2978 dnl
2979 AC_MSG_CHECKING([whether to enable hidden symbols in the library])
2980 AC_ARG_ENABLE(hidden-symbols,
2981 AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library])
2982 AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]),
2983 [ case "$enableval" in
2984   no)
2985        AC_MSG_RESULT(no)
2986        ;;
2987   *)
2988        AC_MSG_CHECKING([whether $CC supports it])
2989        if test "$GCC" = yes ; then
2990          if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ||
2991            dnl clang always supports -fvisibility= but it doesn't show up
2992            dnl under --help.
2993            test "$compiler_id" = "CLANG"; then
2994            AC_MSG_RESULT(yes)
2995            AC_DEFINE(CURL_HIDDEN_SYMBOLS, 1, [to enable hidden symbols])
2996            AC_DEFINE(CURL_EXTERN_SYMBOL, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
2997            CFLAGS="$CFLAGS -fvisibility=hidden"
2998          else
2999             AC_MSG_RESULT(no)
3000           fi
3001
3002        else
3003          dnl Test for SunPro cc
3004          if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
3005            AC_MSG_RESULT(yes)
3006            AC_DEFINE(CURL_HIDDEN_SYMBOLS, 1, [to enable hidden symbols])
3007            AC_DEFINE(CURL_EXTERN_SYMBOL, [__global], [to make a symbol visible])
3008            CFLAGS="$CFLAGS -xldscope=hidden"
3009          else
3010            AC_MSG_RESULT(no)
3011          fi
3012        fi
3013        ;;
3014   esac ],
3015        AC_MSG_RESULT(no)
3016 )
3017
3018 dnl ************************************************************
3019 dnl enforce SONAME bump
3020 dnl
3021
3022 AC_MSG_CHECKING([whether to enforce SONAME bump])
3023 AC_ARG_ENABLE(soname-bump,
3024 AC_HELP_STRING([--enable-soname-bump],[Enable enforced SONAME bump])
3025 AC_HELP_STRING([--disable-soname-bump],[Disable enforced SONAME bump]),
3026 [ case "$enableval" in
3027   yes)   AC_MSG_RESULT(yes)
3028          soname_bump=yes
3029          ;;
3030   *)
3031          AC_MSG_RESULT(no)
3032          ;;
3033   esac ],
3034         AC_MSG_RESULT($soname_bump)
3035 )
3036 AM_CONDITIONAL(SONAME_BUMP, test x$soname_bump = xyes)
3037
3038
3039 dnl ************************************************************
3040 if test ! -z "$winsock_LIB"; then
3041
3042   dnl If ws2_32 is wanted, make sure it is the _last_ lib in LIBS (makes
3043   dnl things work when built with c-ares). But we can't just move it last
3044   dnl since then other stuff (SSL) won't build. So we simply append it to the
3045   dnl end.
3046
3047   LIBS="$LIBS $winsock_LIB"
3048   TEST_SERVER_LIBS="$TEST_SERVER_LIBS $winsock_LIB"
3049
3050 fi
3051
3052 dnl
3053 dnl All the library dependencies put into $LIB apply to libcurl only.
3054 dnl Those in $CURL_LIBS apply to the curl command-line client only.
3055 dnl Those in $TEST_SERVER_LIBS apply to test servers only.
3056 dnl Those in $ALL_LIBS apply to all targets, including test targets.
3057 dnl
3058 LIBCURL_LIBS=$LIBS
3059
3060 AC_SUBST(LIBCURL_LIBS)
3061 AC_SUBST(CURL_LIBS)
3062 AC_SUBST(TEST_SERVER_LIBS)
3063 AC_SUBST(CURL_NETWORK_LIBS)
3064 LIBS=$ALL_LIBS  dnl LIBS is a magic variable that's used for every link
3065
3066 AM_CONDITIONAL(CROSSCOMPILING, test x$cross_compiling = xyes)
3067
3068 dnl yes or no
3069 ENABLE_SHARED="$enable_shared"
3070 AC_SUBST(ENABLE_SHARED)
3071
3072 dnl
3073 dnl For keeping supported features and protocols also in pkg-config file
3074 dnl since it is more cross-compile frient than curl-config
3075 dnl
3076
3077 if test "x$USE_SSLEAY" = "x1"; then
3078   SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
3079 elif test -n "$SSL_ENABLED"; then
3080   SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
3081 fi
3082 if test "@KRB4_ENABLED@" = "x1"; then
3083   SUPPORT_FEATURES="$SUPPORT_FEATURES KRB4"
3084 fi
3085 if test "x$IPV6_ENABLED" = "x1"; then
3086   SUPPORT_FEATURES="$SUPPORT_FEATURES IPv6"
3087 fi
3088 if test "x$HAVE_LIBZ" = "x1"; then
3089   SUPPORT_FEATURES="$SUPPORT_FEATURES libz"
3090 fi
3091 if test "x$USE_ARES" = "x1" -o "x$USE_THREADS_POSIX" = "x1"; then
3092   SUPPORT_FEATURES="$SUPPORT_FEATURES AsynchDNS"
3093 fi
3094 if test "x$IDN_ENABLED" = "x1"; then
3095   SUPPORT_FEATURES="$SUPPORT_FEATURES IDN"
3096 fi
3097 if test "x$USE_WINDOWS_SSPI" = "x1"; then
3098   SUPPORT_FEATURES="$SUPPORT_FEATURES SSPI"
3099 fi
3100 if test "x$CURL_DISABLE_HTTP" != "x1"; then
3101   if test "x$USE_SSLEAY" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \
3102       -o "x$GNUTLS_ENABLED" = "x1" -o "x$NSS_ENABLED" = "x1"; then
3103     SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM"
3104     if test "x$NTLM_WB_ENABLED" = "x1"; then
3105       SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM_WB"
3106     fi
3107   fi
3108 fi
3109 if test "x$USE_TLS_SRP" = "x1"; then
3110   SUPPORT_FEATURES="$SUPPORT_FEATURES TLS-SRP"
3111 fi
3112
3113 AC_SUBST(SUPPORT_FEATURES)
3114
3115 dnl For supported protocols in pkg-config file
3116 if test "x$CURL_DISABLE_HTTP" != "x1"; then
3117   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTP"
3118   if test "x$SSL_ENABLED" = "x1"; then
3119     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTPS"
3120   fi
3121 fi
3122 if test "x$CURL_DISABLE_FTP" != "x1"; then
3123   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTP"
3124   if test "x$SSL_ENABLED" = "x1"; then
3125     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTPS"
3126   fi
3127 fi
3128 if test "x$CURL_DISABLE_FILE" != "x1"; then
3129   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FILE"
3130 fi
3131 if test "x$CURL_DISABLE_TELNET" != "x1"; then
3132   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TELNET"
3133 fi
3134 if test "x$CURL_DISABLE_LDAP" != "x1"; then
3135   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAP"
3136   if test "x$CURL_DISABLE_LDAPS" != "x1"; then
3137     if (test "x$USE_OPENLDAP" = "x1" && test "x$SSL_ENABLED" = "x1") ||
3138       (test "x$USE_OPENLDAP" != "x1"  && test "x$HAVE_LDAP_SSL" = "x1"); then
3139       SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAPS"
3140     fi
3141   fi
3142 fi
3143 if test "x$CURL_DISABLE_DICT" != "x1"; then
3144   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS DICT"
3145 fi
3146 if test "x$CURL_DISABLE_TFTP" != "x1"; then
3147   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TFTP"
3148 fi
3149 if test "x$CURL_DISABLE_GOPHER" != "x1"; then
3150   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS GOPHER"
3151 fi
3152 if test "x$CURL_DISABLE_POP3" != "x1"; then
3153   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3"
3154   if test "x$SSL_ENABLED" = "x1"; then
3155     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3S"
3156   fi
3157 fi
3158 if test "x$CURL_DISABLE_IMAP" != "x1"; then
3159   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAP"
3160   if test "x$SSL_ENABLED" = "x1"; then
3161     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAPS"
3162   fi
3163 fi
3164 if test "x$CURL_DISABLE_SMTP" != "x1"; then
3165   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTP"
3166   if test "x$SSL_ENABLED" = "x1"; then
3167     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTPS"
3168   fi
3169 fi
3170 if test "x$USE_LIBSSH2" = "x1"; then
3171   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
3172   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
3173 fi
3174 if test "x$CURL_DISABLE_RTSP" != "x1"; then
3175   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTSP"
3176 fi
3177 if test "x$USE_LIBRTMP" = "x1"; then
3178   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTMP"
3179 fi
3180
3181 dnl replace spaces with newlines
3182 dnl sort the lines
3183 dnl replace the newlines back to spaces
3184 SUPPORT_PROTOCOLS=`echo $SUPPORT_PROTOCOLS | tr ' ' '\012' | sort | tr '\012' ' '`
3185
3186 AC_SUBST(SUPPORT_PROTOCOLS)
3187
3188 dnl squeeze whitespace out of some variables
3189
3190 squeeze CFLAGS
3191 squeeze CPPFLAGS
3192 squeeze DEFS
3193 squeeze LDFLAGS
3194 squeeze LIBS
3195
3196 squeeze CURL_LIBS
3197 squeeze LIBCURL_LIBS
3198 squeeze TEST_SERVER_LIBS
3199 squeeze CURL_NETWORK_LIBS
3200
3201 squeeze SUPPORT_FEATURES
3202 squeeze SUPPORT_PROTOCOLS
3203
3204 if test "x$want_curldebug_assumed" = "xyes" &&
3205   test "x$want_curldebug" = "xyes" && test "x$USE_ARES" = "x1"; then
3206   ac_configure_args="$ac_configure_args --enable-curldebug"
3207 fi
3208
3209 AC_CONFIG_FILES([Makefile \
3210            docs/Makefile \
3211            docs/examples/Makefile \
3212            docs/libcurl/Makefile \
3213            include/Makefile \
3214            include/curl/Makefile \
3215            src/Makefile \
3216            lib/Makefile \
3217            tests/Makefile \
3218            tests/data/Makefile \
3219            tests/server/Makefile \
3220            tests/libtest/Makefile \
3221            tests/unit/Makefile \
3222            packages/Makefile \
3223            packages/Win32/Makefile \
3224            packages/Win32/cygwin/Makefile \
3225            packages/Linux/Makefile \
3226            packages/Linux/RPM/Makefile \
3227            packages/Linux/RPM/curl.spec \
3228            packages/Linux/RPM/curl-ssl.spec \
3229            packages/Solaris/Makefile \
3230            packages/EPM/curl.list \
3231            packages/EPM/Makefile \
3232            packages/vms/Makefile \
3233            packages/AIX/Makefile \
3234            packages/AIX/RPM/Makefile \
3235            packages/AIX/RPM/curl.spec \
3236            curl-config \
3237            libcurl.pc
3238 ])
3239 AC_OUTPUT
3240
3241 CURL_GENERATE_CONFIGUREHELP_PM
3242
3243 AC_MSG_NOTICE([Configured to build curl/libcurl:
3244
3245   curl version:    ${CURLVERSION}
3246   Host setup:      ${host}
3247   Install prefix:  ${prefix}
3248   Compiler:        ${CC}
3249   SSL support:     ${curl_ssl_msg}
3250   SSH support:     ${curl_ssh_msg}
3251   zlib support:    ${curl_zlib_msg}
3252   krb4 support:    ${curl_krb4_msg}
3253   GSSAPI support:  ${curl_gss_msg}
3254   SPNEGO support:  ${curl_spnego_msg}
3255   TLS-SRP support: ${curl_tls_srp_msg}
3256   resolver:        ${curl_res_msg}
3257   ipv6 support:    ${curl_ipv6_msg}
3258   IDN support:     ${curl_idn_msg}
3259   Build libcurl:   Shared=${enable_shared}, Static=${enable_static}
3260   Built-in manual: ${curl_manual_msg}
3261   Verbose errors:  ${curl_verbose_msg}
3262   SSPI support:    ${curl_sspi_msg}
3263   ca cert bundle:  ${ca}
3264   ca cert path:    ${capath}
3265   LDAP support:    ${curl_ldap_msg}
3266   LDAPS support:   ${curl_ldaps_msg}
3267   RTSP support:    ${curl_rtsp_msg}
3268   RTMP support:    ${curl_rtmp_msg}
3269   Protocols:       ${SUPPORT_PROTOCOLS}
3270 ])
3271
3272 if test "x$soname_bump" = "xyes"; then
3273
3274 cat <<EOM
3275   SONAME bump:     yes - WARNING: this library will be built with the SONAME
3276                    number bumped due to (a detected) ABI breakage.
3277                    See lib/README.curl_off_t for details on this.
3278 EOM
3279
3280 fi
3281