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