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