• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2019, 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 https://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#***************************************************************************
22dnl Process this file with autoconf to produce a configure script.
23
24AC_PREREQ(2.57)
25
26dnl We don't know the version number "statically" so we use a dash here
27AC_INIT([curl], [-], [a suitable curl mailing list: https://curl.haxx.se/mail/])
28
29XC_OVR_ZZ50
30XC_OVR_ZZ60
31CURL_OVERRIDE_AUTOCONF
32
33dnl configure script copyright
34AC_COPYRIGHT([Copyright (c) 1998 - 2019 Daniel Stenberg, <daniel@haxx.se>
35This configure script may be copied, distributed and modified under the
36terms of the curl license; see COPYING for more details])
37
38AC_CONFIG_SRCDIR([lib/urldata.h])
39AC_CONFIG_HEADERS(lib/curl_config.h)
40AC_CONFIG_MACRO_DIR([m4])
41AM_MAINTAINER_MODE
42m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
43
44CURL_CHECK_OPTION_DEBUG
45CURL_CHECK_OPTION_OPTIMIZE
46CURL_CHECK_OPTION_WARNINGS
47CURL_CHECK_OPTION_WERROR
48CURL_CHECK_OPTION_CURLDEBUG
49CURL_CHECK_OPTION_SYMBOL_HIDING
50CURL_CHECK_OPTION_ARES
51CURL_CHECK_OPTION_RT
52
53XC_CHECK_PATH_SEPARATOR
54
55#
56# save the configure arguments
57#
58CONFIGURE_OPTIONS="\"$ac_configure_args\""
59AC_SUBST(CONFIGURE_OPTIONS)
60
61CURL_CFLAG_EXTRAS=""
62if test X"$want_werror" = Xyes; then
63  CURL_CFLAG_EXTRAS="-Werror"
64  if test "$compiler_id" = "GNU_C"; then
65    dnl enable -pedantic-errors for GCC 5 and later,
66    dnl as before that it was the same as -Werror=pedantic
67    if test "$compiler_num" -ge "500"; then
68      CURL_CFLAG_EXTRAS="$CURL_CFLAG_EXTRAS -pedantic-errors"
69    fi
70  fi
71fi
72AC_SUBST(CURL_CFLAG_EXTRAS)
73
74dnl SED is mandatory for configure process and libtool.
75dnl Set it now, allowing it to be changed later.
76if test -z "$SED"; then
77  dnl allow it to be overridden
78  AC_PATH_PROG([SED], [sed], [not_found],
79    [$PATH:/usr/bin:/usr/local/bin])
80  if test -z "$SED" || test "$SED" = "not_found"; then
81    AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
82  fi
83fi
84AC_SUBST([SED])
85
86dnl GREP is mandatory for configure process and libtool.
87dnl Set it now, allowing it to be changed later.
88if test -z "$GREP"; then
89  dnl allow it to be overridden
90  AC_PATH_PROG([GREP], [grep], [not_found],
91    [$PATH:/usr/bin:/usr/local/bin])
92  if test -z "$GREP" || test "$GREP" = "not_found"; then
93    AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
94  fi
95fi
96AC_SUBST([GREP])
97
98dnl EGREP is mandatory for configure process and libtool.
99dnl Set it now, allowing it to be changed later.
100if test -z "$EGREP"; then
101  dnl allow it to be overridden
102  if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
103    AC_MSG_CHECKING([for egrep])
104    EGREP="$GREP -E"
105    AC_MSG_RESULT([$EGREP])
106  else
107    AC_PATH_PROG([EGREP], [egrep], [not_found],
108      [$PATH:/usr/bin:/usr/local/bin])
109  fi
110fi
111if test -z "$EGREP" || test "$EGREP" = "not_found"; then
112  AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
113fi
114AC_SUBST([EGREP])
115
116dnl AR is mandatory for configure process and libtool.
117dnl This is target dependent, so check it as a tool.
118if test -z "$AR"; then
119  dnl allow it to be overridden
120  AC_PATH_TOOL([AR], [ar], [not_found],
121    [$PATH:/usr/bin:/usr/local/bin])
122  if test -z "$AR" || test "$AR" = "not_found"; then
123    AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
124  fi
125fi
126AC_SUBST([AR])
127
128AC_SUBST(libext)
129
130dnl figure out the libcurl version
131CURLVERSION=`$SED -ne 's/^#define LIBCURL_VERSION "\(.*\)".*/\1/p' ${srcdir}/include/curl/curlver.h`
132XC_CHECK_PROG_CC
133
134dnl for --enable-code-coverage
135CURL_COVERAGE
136
137XC_AUTOMAKE
138AC_MSG_CHECKING([curl version])
139AC_MSG_RESULT($CURLVERSION)
140
141AC_SUBST(CURLVERSION)
142
143dnl
144dnl we extract the numerical version for curl-config only
145VERSIONNUM=`$SED -ne 's/^#define LIBCURL_VERSION_NUM 0x\([0-9A-Fa-f]*\).*/\1/p' ${srcdir}/include/curl/curlver.h`
146AC_SUBST(VERSIONNUM)
147
148dnl Solaris pkgadd support definitions
149PKGADD_PKG="HAXXcurl"
150PKGADD_NAME="curl - a client that groks URLs"
151PKGADD_VENDOR="curl.haxx.se"
152AC_SUBST(PKGADD_PKG)
153AC_SUBST(PKGADD_NAME)
154AC_SUBST(PKGADD_VENDOR)
155
156dnl
157dnl initialize all the info variables
158    curl_ssl_msg="no      (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,schannel,secure-transport,mesalink,amissl} )"
159    curl_ssh_msg="no      (--with-libssh2)"
160   curl_zlib_msg="no      (--with-zlib)"
161 curl_brotli_msg="no      (--with-brotli)"
162    curl_gss_msg="no      (--with-gssapi)"
163curl_tls_srp_msg="no      (--enable-tls-srp)"
164    curl_res_msg="default (--enable-ares / --enable-threaded-resolver)"
165   curl_ipv6_msg="no      (--enable-ipv6)"
166curl_unix_sockets_msg="no      (--enable-unix-sockets)"
167    curl_idn_msg="no      (--with-{libidn2,winidn})"
168 curl_manual_msg="no      (--enable-manual)"
169curl_libcurl_msg="enabled (--disable-libcurl-option)"
170curl_verbose_msg="enabled (--disable-verbose)"
171   curl_sspi_msg="no      (--enable-sspi)"
172   curl_ldap_msg="no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)"
173  curl_ldaps_msg="no      (--enable-ldaps)"
174   curl_rtsp_msg="no      (--enable-rtsp)"
175   curl_rtmp_msg="no      (--with-librtmp)"
176  curl_mtlnk_msg="no      (--with-libmetalink)"
177    curl_psl_msg="no      (--with-libpsl)"
178
179    ssl_backends=
180
181dnl
182dnl Save some initial values the user might have provided
183dnl
184INITIAL_LDFLAGS=$LDFLAGS
185INITIAL_LIBS=$LIBS
186
187dnl
188dnl Detect the canonical host and target build environment
189dnl
190
191AC_CANONICAL_HOST
192dnl Get system canonical name
193AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
194
195# Silence warning: ar: 'u' modifier ignored since 'D' is the default
196AC_SUBST(AR_FLAGS, [cr])
197
198dnl This defines _ALL_SOURCE for AIX
199CURL_CHECK_AIX_ALL_SOURCE
200
201dnl Our configure and build reentrant settings
202CURL_CONFIGURE_THREAD_SAFE
203CURL_CONFIGURE_REENTRANT
204
205dnl check for how to do large files
206AC_SYS_LARGEFILE
207
208XC_LIBTOOL
209
210#
211# Automake conditionals based on libtool related checks
212#
213
214AM_CONDITIONAL([CURL_LT_SHLIB_USE_VERSION_INFO],
215  [test "x$xc_lt_shlib_use_version_info" = 'xyes'])
216AM_CONDITIONAL([CURL_LT_SHLIB_USE_NO_UNDEFINED],
217  [test "x$xc_lt_shlib_use_no_undefined" = 'xyes'])
218AM_CONDITIONAL([CURL_LT_SHLIB_USE_MIMPURE_TEXT],
219  [test "x$xc_lt_shlib_use_mimpure_text" = 'xyes'])
220
221#
222# Due to libtool and automake machinery limitations of not allowing
223# specifying separate CPPFLAGS or CFLAGS when compiling objects for
224# inclusion of these in shared or static libraries, we are forced to
225# build using separate configure runs for shared and static libraries
226# on systems where different CPPFLAGS or CFLAGS are mandatory in order
227# to compile objects for each kind of library. Notice that relying on
228# the '-DPIC' CFLAG that libtool provides is not valid given that the
229# user might for example choose to build static libraries with PIC.
230#
231
232#
233# Make our Makefile.am files use the staticlib CPPFLAG only when strictly
234# targeting a static library and not building its shared counterpart.
235#
236
237AM_CONDITIONAL([USE_CPPFLAG_CURL_STATICLIB],
238  [test "x$xc_lt_build_static_only" = 'xyes'])
239
240#
241# Make staticlib CPPFLAG variable and its definition visible in output
242# files unconditionally, providing an empty definition unless strictly
243# targeting a static library and not building its shared counterpart.
244#
245
246CPPFLAG_CURL_STATICLIB=
247if test "x$xc_lt_build_static_only" = 'xyes'; then
248  CPPFLAG_CURL_STATICLIB='-DCURL_STATICLIB'
249fi
250AC_SUBST([CPPFLAG_CURL_STATICLIB])
251
252
253# Determine whether all dependent libraries must be specified when linking
254if test "X$enable_shared" = "Xyes" -a "X$link_all_deplibs" = "Xno"
255then
256    REQUIRE_LIB_DEPS=no
257else
258    REQUIRE_LIB_DEPS=yes
259fi
260AC_SUBST(REQUIRE_LIB_DEPS)
261AM_CONDITIONAL(USE_EXPLICIT_LIB_DEPS, test x$REQUIRE_LIB_DEPS = xyes)
262
263dnl check if there's a way to force code inline
264AC_C_INLINE
265
266dnl **********************************************************************
267dnl platform/compiler/architecture specific checks/flags
268dnl **********************************************************************
269
270CURL_CHECK_COMPILER
271CURL_SET_COMPILER_BASIC_OPTS
272CURL_SET_COMPILER_DEBUG_OPTS
273CURL_SET_COMPILER_OPTIMIZE_OPTS
274CURL_SET_COMPILER_WARNING_OPTS
275
276if test "$compiler_id" = "INTEL_UNIX_C"; then
277  #
278  if test "$compiler_num" -ge "1000"; then
279    dnl icc 10.X or later
280    CFLAGS="$CFLAGS -shared-intel"
281  elif test "$compiler_num" -ge "900"; then
282    dnl icc 9.X specific
283    CFLAGS="$CFLAGS -i-dynamic"
284  fi
285  #
286fi
287
288CURL_CHECK_COMPILER_HALT_ON_ERROR
289CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
290CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH
291CURL_CHECK_COMPILER_SYMBOL_HIDING
292
293CURL_CHECK_CURLDEBUG
294AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
295
296supports_unittests=yes
297# cross-compilation of unit tests static library/programs fails when
298# libcurl shared library is built. This might be due to a libtool or
299# automake issue. In this case we disable unit tests.
300if test "x$cross_compiling" != "xno" &&
301   test "x$enable_shared" != "xno"; then
302  supports_unittests=no
303fi
304
305# IRIX 6.5.24 gcc 3.3 autobuilds fail unittests library compilation due to
306# a problem related with OpenSSL headers and library versions not matching.
307# Disable unit tests while time to further investigate this is found.
308case $host in
309  mips-sgi-irix6.5)
310    if test "$compiler_id" = "GNU_C"; then
311      supports_unittests=no
312    fi
313    ;;
314esac
315
316# All AIX autobuilds fails unit tests linking against unittests library
317# due to unittests library being built with no symbols or members. Libtool ?
318# Disable unit tests while time to further investigate this is found.
319case $host_os in
320  aix*)
321    supports_unittests=no
322    ;;
323esac
324
325dnl Build unit tests when option --enable-debug is given.
326if test "x$want_debug" = "xyes" &&
327   test "x$supports_unittests" = "xyes"; then
328  want_unittests=yes
329else
330  want_unittests=no
331fi
332AM_CONDITIONAL(BUILD_UNITTESTS, test x$want_unittests = xyes)
333
334dnl **********************************************************************
335dnl Compilation based checks should not be done before this point.
336dnl **********************************************************************
337
338dnl **********************************************************************
339dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
340dnl and ws2tcpip.h take precedence over any other further checks which
341dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
342dnl this specific header files. And do them before its results are used.
343dnl **********************************************************************
344
345CURL_CHECK_HEADER_WINDOWS
346CURL_CHECK_NATIVE_WINDOWS
347case X-"$curl_cv_native_windows" in
348  X-yes)
349    CURL_CHECK_HEADER_WINSOCK
350    CURL_CHECK_HEADER_WINSOCK2
351    CURL_CHECK_HEADER_WS2TCPIP
352    CURL_CHECK_HEADER_WINLDAP
353    CURL_CHECK_HEADER_WINBER
354    ;;
355  *)
356    curl_cv_header_winsock_h="no"
357    curl_cv_header_winsock2_h="no"
358    curl_cv_header_ws2tcpip_h="no"
359    curl_cv_header_winldap_h="no"
360    curl_cv_header_winber_h="no"
361    ;;
362esac
363CURL_CHECK_WIN32_LARGEFILE
364
365CURL_MAC_CFLAGS
366CURL_SUPPORTS_BUILTIN_AVAILABLE
367
368
369dnl ************************************************************
370dnl switch off particular protocols
371dnl
372AC_MSG_CHECKING([whether to support http])
373AC_ARG_ENABLE(http,
374AC_HELP_STRING([--enable-http],[Enable HTTP support])
375AC_HELP_STRING([--disable-http],[Disable HTTP support]),
376[ case "$enableval" in
377  no)
378       AC_MSG_RESULT(no)
379       AC_DEFINE(CURL_DISABLE_HTTP, 1, [to disable HTTP])
380       disable_http="yes"
381       AC_MSG_WARN([disable HTTP disables FTP over proxy and RTSP])
382       AC_SUBST(CURL_DISABLE_HTTP, [1])
383       AC_DEFINE(CURL_DISABLE_RTSP, 1, [to disable RTSP])
384       AC_SUBST(CURL_DISABLE_RTSP, [1])
385       ;;
386  *)   AC_MSG_RESULT(yes)
387       ;;
388  esac ],
389       AC_MSG_RESULT(yes)
390)
391AC_MSG_CHECKING([whether to support ftp])
392AC_ARG_ENABLE(ftp,
393AC_HELP_STRING([--enable-ftp],[Enable FTP support])
394AC_HELP_STRING([--disable-ftp],[Disable FTP support]),
395[ case "$enableval" in
396  no)
397       AC_MSG_RESULT(no)
398       AC_DEFINE(CURL_DISABLE_FTP, 1, [to disable FTP])
399       AC_SUBST(CURL_DISABLE_FTP, [1])
400       ;;
401  *)   AC_MSG_RESULT(yes)
402       ;;
403  esac ],
404       AC_MSG_RESULT(yes)
405)
406AC_MSG_CHECKING([whether to support file])
407AC_ARG_ENABLE(file,
408AC_HELP_STRING([--enable-file],[Enable FILE support])
409AC_HELP_STRING([--disable-file],[Disable FILE support]),
410[ case "$enableval" in
411  no)
412       AC_MSG_RESULT(no)
413       AC_DEFINE(CURL_DISABLE_FILE, 1, [to disable FILE])
414       AC_SUBST(CURL_DISABLE_FILE, [1])
415       ;;
416  *)   AC_MSG_RESULT(yes)
417       ;;
418  esac ],
419       AC_MSG_RESULT(yes)
420)
421AC_MSG_CHECKING([whether to support ldap])
422AC_ARG_ENABLE(ldap,
423AC_HELP_STRING([--enable-ldap],[Enable LDAP support])
424AC_HELP_STRING([--disable-ldap],[Disable LDAP support]),
425[ case "$enableval" in
426  no)
427       AC_MSG_RESULT(no)
428       AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
429       AC_SUBST(CURL_DISABLE_LDAP, [1])
430       ;;
431  *)
432       AC_MSG_RESULT(yes)
433       ;;
434  esac ],[
435       AC_MSG_RESULT(yes) ]
436)
437AC_MSG_CHECKING([whether to support ldaps])
438AC_ARG_ENABLE(ldaps,
439AC_HELP_STRING([--enable-ldaps],[Enable LDAPS support])
440AC_HELP_STRING([--disable-ldaps],[Disable LDAPS support]),
441[ case "$enableval" in
442  no)
443       AC_MSG_RESULT(no)
444       AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
445       AC_SUBST(CURL_DISABLE_LDAPS, [1])
446       ;;
447  *)   if test "x$CURL_DISABLE_LDAP" = "x1" ; then
448         AC_MSG_RESULT(LDAP needs to be enabled to support LDAPS)
449         AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
450         AC_SUBST(CURL_DISABLE_LDAPS, [1])
451       else
452         AC_MSG_RESULT(yes)
453         AC_DEFINE(HAVE_LDAP_SSL, 1, [Use LDAPS implementation])
454         AC_SUBST(HAVE_LDAP_SSL, [1])
455       fi
456       ;;
457  esac ],[
458       if test "x$CURL_DISABLE_LDAP" = "x1" ; then
459         AC_MSG_RESULT(no)
460         AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
461         AC_SUBST(CURL_DISABLE_LDAPS, [1])
462       else
463         AC_MSG_RESULT(yes)
464         AC_DEFINE(HAVE_LDAP_SSL, 1, [Use LDAPS implementation])
465         AC_SUBST(HAVE_LDAP_SSL, [1])
466       fi ]
467)
468
469AC_MSG_CHECKING([whether to support rtsp])
470AC_ARG_ENABLE(rtsp,
471AC_HELP_STRING([--enable-rtsp],[Enable RTSP support])
472AC_HELP_STRING([--disable-rtsp],[Disable RTSP support]),
473[ case "$enableval" in
474  no)
475       AC_MSG_RESULT(no)
476       AC_DEFINE(CURL_DISABLE_RTSP, 1, [to disable RTSP])
477       AC_SUBST(CURL_DISABLE_RTSP, [1])
478       ;;
479  *)   if test x$CURL_DISABLE_HTTP = x1 ; then
480          AC_MSG_ERROR(HTTP support needs to be enabled in order to enable RTSP support!)
481       else
482          AC_MSG_RESULT(yes)
483          curl_rtsp_msg="enabled"
484       fi
485       ;;
486  esac ],
487       if test "x$CURL_DISABLE_HTTP" != "x1"; then
488          AC_MSG_RESULT(yes)
489          curl_rtsp_msg="enabled"
490       else
491          AC_MSG_RESULT(no)
492       fi
493)
494
495AC_MSG_CHECKING([whether to support proxies])
496AC_ARG_ENABLE(proxy,
497AC_HELP_STRING([--enable-proxy],[Enable proxy support])
498AC_HELP_STRING([--disable-proxy],[Disable proxy support]),
499[ case "$enableval" in
500  no)
501       AC_MSG_RESULT(no)
502       AC_DEFINE(CURL_DISABLE_PROXY, 1, [to disable proxies])
503       AC_SUBST(CURL_DISABLE_PROXY, [1])
504       ;;
505  *)   AC_MSG_RESULT(yes)
506       ;;
507  esac ],
508       AC_MSG_RESULT(yes)
509)
510
511AC_MSG_CHECKING([whether to support dict])
512AC_ARG_ENABLE(dict,
513AC_HELP_STRING([--enable-dict],[Enable DICT support])
514AC_HELP_STRING([--disable-dict],[Disable DICT support]),
515[ case "$enableval" in
516  no)
517       AC_MSG_RESULT(no)
518       AC_DEFINE(CURL_DISABLE_DICT, 1, [to disable DICT])
519       AC_SUBST(CURL_DISABLE_DICT, [1])
520       ;;
521  *)   AC_MSG_RESULT(yes)
522       ;;
523  esac ],
524       AC_MSG_RESULT(yes)
525)
526AC_MSG_CHECKING([whether to support telnet])
527AC_ARG_ENABLE(telnet,
528AC_HELP_STRING([--enable-telnet],[Enable TELNET support])
529AC_HELP_STRING([--disable-telnet],[Disable TELNET support]),
530[ case "$enableval" in
531  no)
532       AC_MSG_RESULT(no)
533       AC_DEFINE(CURL_DISABLE_TELNET, 1, [to disable TELNET])
534       AC_SUBST(CURL_DISABLE_TELNET, [1])
535       ;;
536  *)   AC_MSG_RESULT(yes)
537       ;;
538  esac ],
539       AC_MSG_RESULT(yes)
540)
541AC_MSG_CHECKING([whether to support tftp])
542AC_ARG_ENABLE(tftp,
543AC_HELP_STRING([--enable-tftp],[Enable TFTP support])
544AC_HELP_STRING([--disable-tftp],[Disable TFTP support]),
545[ case "$enableval" in
546  no)
547       AC_MSG_RESULT(no)
548       AC_DEFINE(CURL_DISABLE_TFTP, 1, [to disable TFTP])
549       AC_SUBST(CURL_DISABLE_TFTP, [1])
550       ;;
551  *)   AC_MSG_RESULT(yes)
552       ;;
553  esac ],
554       AC_MSG_RESULT(yes)
555)
556
557AC_MSG_CHECKING([whether to support pop3])
558AC_ARG_ENABLE(pop3,
559AC_HELP_STRING([--enable-pop3],[Enable POP3 support])
560AC_HELP_STRING([--disable-pop3],[Disable POP3 support]),
561[ case "$enableval" in
562  no)
563       AC_MSG_RESULT(no)
564       AC_DEFINE(CURL_DISABLE_POP3, 1, [to disable POP3])
565       AC_SUBST(CURL_DISABLE_POP3, [1])
566       ;;
567  *)   AC_MSG_RESULT(yes)
568       ;;
569  esac ],
570       AC_MSG_RESULT(yes)
571)
572
573
574AC_MSG_CHECKING([whether to support imap])
575AC_ARG_ENABLE(imap,
576AC_HELP_STRING([--enable-imap],[Enable IMAP support])
577AC_HELP_STRING([--disable-imap],[Disable IMAP support]),
578[ case "$enableval" in
579  no)
580       AC_MSG_RESULT(no)
581       AC_DEFINE(CURL_DISABLE_IMAP, 1, [to disable IMAP])
582       AC_SUBST(CURL_DISABLE_IMAP, [1])
583       ;;
584  *)   AC_MSG_RESULT(yes)
585       ;;
586  esac ],
587       AC_MSG_RESULT(yes)
588)
589
590
591AC_MSG_CHECKING([whether to support smb])
592AC_ARG_ENABLE(smb,
593AC_HELP_STRING([--enable-smb],[Enable SMB/CIFS support])
594AC_HELP_STRING([--disable-smb],[Disable SMB/CIFS support]),
595[ case "$enableval" in
596  no)
597       AC_MSG_RESULT(no)
598       AC_DEFINE(CURL_DISABLE_SMB, 1, [to disable SMB/CIFS])
599       AC_SUBST(CURL_DISABLE_SMB, [1])
600       ;;
601  *)   AC_MSG_RESULT(yes)
602       ;;
603  esac ],
604       AC_MSG_RESULT(yes)
605)
606
607AC_MSG_CHECKING([whether to support smtp])
608AC_ARG_ENABLE(smtp,
609AC_HELP_STRING([--enable-smtp],[Enable SMTP support])
610AC_HELP_STRING([--disable-smtp],[Disable SMTP support]),
611[ case "$enableval" in
612  no)
613       AC_MSG_RESULT(no)
614       AC_DEFINE(CURL_DISABLE_SMTP, 1, [to disable SMTP])
615       AC_SUBST(CURL_DISABLE_SMTP, [1])
616       ;;
617  *)   AC_MSG_RESULT(yes)
618       ;;
619  esac ],
620       AC_MSG_RESULT(yes)
621)
622
623AC_MSG_CHECKING([whether to support gopher])
624AC_ARG_ENABLE(gopher,
625AC_HELP_STRING([--enable-gopher],[Enable Gopher support])
626AC_HELP_STRING([--disable-gopher],[Disable Gopher support]),
627[ case "$enableval" in
628  no)
629       AC_MSG_RESULT(no)
630       AC_DEFINE(CURL_DISABLE_GOPHER, 1, [to disable Gopher])
631       AC_SUBST(CURL_DISABLE_GOPHER, [1])
632       ;;
633  *)   AC_MSG_RESULT(yes)
634       ;;
635  esac ],
636       AC_MSG_RESULT(yes)
637)
638
639
640dnl **********************************************************************
641dnl Check for built-in manual
642dnl **********************************************************************
643
644AC_MSG_CHECKING([whether to provide built-in manual])
645AC_ARG_ENABLE(manual,
646AC_HELP_STRING([--enable-manual],[Enable built-in manual])
647AC_HELP_STRING([--disable-manual],[Disable built-in manual]),
648[ case "$enableval" in
649  no)
650       AC_MSG_RESULT(no)
651       ;;
652  *)   AC_MSG_RESULT(yes)
653       USE_MANUAL="1"
654       ;;
655  esac ],
656       AC_MSG_RESULT(yes)
657       USE_MANUAL="1"
658)
659dnl The actual use of the USE_MANUAL variable is done much later in this
660dnl script to allow other actions to disable it as well.
661
662dnl ************************************************************
663dnl disable C code generation support
664dnl
665AC_MSG_CHECKING([whether to enable generation of C code])
666AC_ARG_ENABLE(libcurl_option,
667AC_HELP_STRING([--enable-libcurl-option],[Enable --libcurl C code generation support])
668AC_HELP_STRING([--disable-libcurl-option],[Disable --libcurl C code generation support]),
669[ case "$enableval" in
670  no)
671       AC_MSG_RESULT(no)
672       AC_DEFINE(CURL_DISABLE_LIBCURL_OPTION, 1, [to disable --libcurl C code generation option])
673       curl_libcurl_msg="no"
674       ;;
675  *)   AC_MSG_RESULT(yes)
676       ;;
677  esac ],
678       AC_MSG_RESULT(yes)
679)
680
681dnl **********************************************************************
682dnl Checks for libraries.
683dnl **********************************************************************
684
685AC_MSG_CHECKING([whether to use libgcc])
686AC_ARG_ENABLE(libgcc,
687AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
688[ case "$enableval" in
689  yes)
690       LIBS="-lgcc $LIBS"
691       AC_MSG_RESULT(yes)
692       ;;
693  *)   AC_MSG_RESULT(no)
694       ;;
695  esac ],
696       AC_MSG_RESULT(no)
697)
698
699CURL_CHECK_LIB_XNET
700
701dnl gethostbyname without lib or in the nsl lib?
702AC_CHECK_FUNC(gethostbyname,
703              [HAVE_GETHOSTBYNAME="1"
704              ],
705              [ AC_CHECK_LIB(nsl, gethostbyname,
706                             [HAVE_GETHOSTBYNAME="1"
707                             LIBS="-lnsl $LIBS"
708                             ])
709              ])
710
711if test "$HAVE_GETHOSTBYNAME" != "1"
712then
713  dnl gethostbyname in the socket lib?
714  AC_CHECK_LIB(socket, gethostbyname,
715               [HAVE_GETHOSTBYNAME="1"
716               LIBS="-lsocket $LIBS"
717               ])
718fi
719
720if test "$HAVE_GETHOSTBYNAME" != "1"
721then
722  dnl gethostbyname in the watt lib?
723  AC_CHECK_LIB(watt, gethostbyname,
724               [HAVE_GETHOSTBYNAME="1"
725               CPPFLAGS="-I/dev/env/WATT_ROOT/inc"
726               LDFLAGS="-L/dev/env/WATT_ROOT/lib"
727               LIBS="-lwatt $LIBS"
728               ])
729fi
730
731dnl At least one system has been identified to require BOTH nsl and socket
732dnl libs at the same time to link properly.
733if test "$HAVE_GETHOSTBYNAME" != "1"
734then
735  AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
736  my_ac_save_LIBS=$LIBS
737  LIBS="-lnsl -lsocket $LIBS"
738  AC_LINK_IFELSE([
739    AC_LANG_PROGRAM([[
740    ]],[[
741      gethostbyname();
742    ]])
743  ],[
744    AC_MSG_RESULT([yes])
745    HAVE_GETHOSTBYNAME="1"
746  ],[
747    AC_MSG_RESULT([no])
748    LIBS=$my_ac_save_LIBS
749  ])
750fi
751
752if test "$HAVE_GETHOSTBYNAME" != "1"
753then
754  dnl This is for winsock systems
755  if test "$curl_cv_header_windows_h" = "yes"; then
756    if test "$curl_cv_header_winsock_h" = "yes"; then
757      case $host in
758        *-*-mingw32ce*)
759          winsock_LIB="-lwinsock"
760          ;;
761        *)
762          winsock_LIB="-lwsock32"
763          ;;
764      esac
765    fi
766    if test "$curl_cv_header_winsock2_h" = "yes"; then
767      winsock_LIB="-lws2_32"
768    fi
769    if test ! -z "$winsock_LIB"; then
770      my_ac_save_LIBS=$LIBS
771      LIBS="$winsock_LIB $LIBS"
772      AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
773      AC_LINK_IFELSE([
774        AC_LANG_PROGRAM([[
775#ifdef HAVE_WINDOWS_H
776#ifndef WIN32_LEAN_AND_MEAN
777#define WIN32_LEAN_AND_MEAN
778#endif
779#include <windows.h>
780#ifdef HAVE_WINSOCK2_H
781#include <winsock2.h>
782#else
783#ifdef HAVE_WINSOCK_H
784#include <winsock.h>
785#endif
786#endif
787#endif
788        ]],[[
789          gethostbyname("www.dummysite.com");
790        ]])
791      ],[
792        AC_MSG_RESULT([yes])
793        HAVE_GETHOSTBYNAME="1"
794      ],[
795        AC_MSG_RESULT([no])
796        winsock_LIB=""
797        LIBS=$my_ac_save_LIBS
798      ])
799    fi
800  fi
801fi
802
803if test "$HAVE_GETHOSTBYNAME" != "1"
804then
805  dnl This is for Minix 3.1
806  AC_MSG_CHECKING([for gethostbyname for Minix 3])
807  AC_LINK_IFELSE([
808    AC_LANG_PROGRAM([[
809/* Older Minix versions may need <net/gen/netdb.h> here instead */
810#include <netdb.h>
811    ]],[[
812      gethostbyname("www.dummysite.com");
813    ]])
814  ],[
815    AC_MSG_RESULT([yes])
816    HAVE_GETHOSTBYNAME="1"
817  ],[
818    AC_MSG_RESULT([no])
819  ])
820fi
821
822if test "$HAVE_GETHOSTBYNAME" != "1"
823then
824  dnl This is for eCos with a stubbed DNS implementation
825  AC_MSG_CHECKING([for gethostbyname for eCos])
826  AC_LINK_IFELSE([
827    AC_LANG_PROGRAM([[
828#include <stdio.h>
829#include <netdb.h>
830    ]],[[
831      gethostbyname("www.dummysite.com");
832    ]])
833  ],[
834    AC_MSG_RESULT([yes])
835    HAVE_GETHOSTBYNAME="1"
836  ],[
837    AC_MSG_RESULT([no])
838  ])
839fi
840
841if test "$HAVE_GETHOSTBYNAME" != "1"
842then
843  dnl This is for AmigaOS with bsdsocket.library - needs testing before -lnet
844  AC_MSG_CHECKING([for gethostbyname for AmigaOS bsdsocket.library])
845  AC_LINK_IFELSE([
846    AC_LANG_PROGRAM([[
847#include <proto/bsdsocket.h>
848struct Library *SocketBase = NULL;
849    ]],[[
850      gethostbyname("www.dummysite.com");
851    ]])
852  ],[
853    AC_MSG_RESULT([yes])
854    HAVE_GETHOSTBYNAME="1"
855    HAVE_PROTO_BSDSOCKET_H="1"
856    AC_DEFINE(HAVE_PROTO_BSDSOCKET_H, 1, [if Amiga bsdsocket.library is in use])
857    AC_SUBST(HAVE_PROTO_BSDSOCKET_H, [1])
858  ],[
859    AC_MSG_RESULT([no])
860  ])
861fi
862
863if test "$HAVE_GETHOSTBYNAME" != "1"
864then
865  dnl gethostbyname in the network lib - for Haiku OS
866  AC_CHECK_LIB(network, gethostbyname,
867               [HAVE_GETHOSTBYNAME="1"
868               LIBS="-lnetwork $LIBS"
869               ])
870fi
871
872if test "$HAVE_GETHOSTBYNAME" != "1"
873then
874  dnl gethostbyname in the net lib - for BeOS
875  AC_CHECK_LIB(net, gethostbyname,
876               [HAVE_GETHOSTBYNAME="1"
877               LIBS="-lnet $LIBS"
878               ])
879fi
880
881
882if test "$HAVE_GETHOSTBYNAME" != "1"; then
883  AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
884fi
885
886CURL_CHECK_LIBS_CONNECT
887
888CURL_NETWORK_LIBS=$LIBS
889
890dnl **********************************************************************
891dnl In case that function clock_gettime with monotonic timer is available,
892dnl check for additional required libraries.
893dnl **********************************************************************
894CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
895
896dnl **********************************************************************
897dnl The preceding library checks are all potentially useful for test
898dnl servers and libtest cases which require networking and clock_gettime
899dnl support.  Save the list of required libraries at this point for use
900dnl while linking those test servers and programs.
901dnl **********************************************************************
902CURL_NETWORK_AND_TIME_LIBS=$LIBS
903
904dnl **********************************************************************
905dnl Check for the presence of ZLIB libraries and headers
906dnl **********************************************************************
907
908dnl Check for & handle argument to --with-zlib.
909
910clean_CPPFLAGS=$CPPFLAGS
911clean_LDFLAGS=$LDFLAGS
912clean_LIBS=$LIBS
913ZLIB_LIBS=""
914AC_ARG_WITH(zlib,
915AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH])
916AC_HELP_STRING([--without-zlib],[disable use of zlib]),
917               [OPT_ZLIB="$withval"])
918
919if test "$OPT_ZLIB" = "no" ; then
920    AC_MSG_WARN([zlib disabled])
921else
922  if test "$OPT_ZLIB" = "yes" ; then
923    OPT_ZLIB=""
924  fi
925
926  if test -z "$OPT_ZLIB" ; then
927    CURL_CHECK_PKGCONFIG(zlib)
928
929    if test "$PKGCONFIG" != "no" ; then
930      LIBS="`$PKGCONFIG --libs-only-l zlib` $LIBS"
931      LDFLAGS="$LDFLAGS `$PKGCONFIG --libs-only-L zlib`"
932      CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags-only-I zlib`"
933      OPT_ZLIB=""
934      HAVE_LIBZ="1"
935    fi
936
937    if test -z "$HAVE_LIBZ"; then
938
939      dnl Check for the lib without setting any new path, since many
940      dnl people have it in the default path
941
942      AC_CHECK_LIB(z, inflateEnd,
943                   dnl libz found, set the variable
944                   [HAVE_LIBZ="1"
945                    LIBS="-lz $LIBS"],
946                   dnl if no lib found, try /usr/local
947                   [OPT_ZLIB="/usr/local"])
948    fi
949  fi
950
951  dnl Add a nonempty path to the compiler flags
952  if test -n "$OPT_ZLIB"; then
953     CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
954     LDFLAGS="$LDFLAGS -L$OPT_ZLIB/lib$libsuff"
955  fi
956
957  AC_CHECK_HEADER(zlib.h,
958    [
959    dnl zlib.h was found
960    HAVE_ZLIB_H="1"
961    dnl if the lib wasn't found already, try again with the new paths
962    if test "$HAVE_LIBZ" != "1"; then
963      AC_CHECK_LIB(z, gzread,
964                   [
965                   dnl the lib was found!
966                   HAVE_LIBZ="1"
967                   LIBS="-lz $LIBS"
968                   ],
969                   [ CPPFLAGS=$clean_CPPFLAGS
970                   LDFLAGS=$clean_LDFLAGS])
971    fi
972    ],
973    [
974      dnl zlib.h was not found, restore the flags
975      CPPFLAGS=$clean_CPPFLAGS
976      LDFLAGS=$clean_LDFLAGS]
977    )
978
979  if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
980  then
981    AC_MSG_WARN([configure found only the libz lib, not the header file!])
982    HAVE_LIBZ=""
983    CPPFLAGS=$clean_CPPFLAGS
984    LDFLAGS=$clean_LDFLAGS
985    LIBS=$clean_LIBS
986  elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
987  then
988    AC_MSG_WARN([configure found only the libz header file, not the lib!])
989    CPPFLAGS=$clean_CPPFLAGS
990    LDFLAGS=$clean_LDFLAGS
991    LIBS=$clean_LIBS
992  elif test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" = "1"
993  then
994    dnl both header and lib were found!
995    AC_SUBST(HAVE_LIBZ)
996    AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
997    AC_DEFINE(HAVE_LIBZ, 1, [if zlib is available])
998
999    ZLIB_LIBS="-lz"
1000    LIBS="-lz $clean_LIBS"
1001
1002    dnl replace 'HAVE_LIBZ' in the automake makefile.ams
1003    AMFIXLIB="1"
1004    AC_MSG_NOTICE([found both libz and libz.h header])
1005    curl_zlib_msg="enabled"
1006  fi
1007fi
1008
1009dnl set variable for use in automakefile(s)
1010AM_CONDITIONAL(HAVE_LIBZ, test x"$AMFIXLIB" = x1)
1011AC_SUBST(ZLIB_LIBS)
1012
1013dnl **********************************************************************
1014dnl Check for the presence of BROTLI decoder libraries and headers
1015dnl **********************************************************************
1016
1017dnl Brotli project home page: https://github.com/google/brotli
1018
1019dnl Default to compiler & linker defaults for BROTLI files & libraries.
1020OPT_BROTLI=off
1021AC_ARG_WITH(brotli,dnl
1022AC_HELP_STRING([--with-brotli=PATH],[Where to look for brotli, PATH points to the BROTLI installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
1023AC_HELP_STRING([--without-brotli], [disable BROTLI]),
1024  OPT_BROTLI=$withval)
1025
1026if test X"$OPT_BROTLI" != Xno; then
1027  dnl backup the pre-brotli variables
1028  CLEANLDFLAGS="$LDFLAGS"
1029  CLEANCPPFLAGS="$CPPFLAGS"
1030  CLEANLIBS="$LIBS"
1031
1032  case "$OPT_BROTLI" in
1033  yes)
1034    dnl --with-brotli (without path) used
1035    CURL_CHECK_PKGCONFIG(libbrotlidec)
1036
1037    if test "$PKGCONFIG" != "no" ; then
1038      LIB_BROTLI=`$PKGCONFIG --libs-only-l libbrotlidec`
1039      LD_BROTLI=`$PKGCONFIG --libs-only-L libbrotlidec`
1040      CPP_BROTLI=`$PKGCONFIG --cflags-only-I libbrotlidec`
1041      version=`$PKGCONFIG --modversion libbrotlidec`
1042      DIR_BROTLI=`echo $LD_BROTLI | $SED -e 's/-L//'`
1043    fi
1044
1045    ;;
1046  off)
1047    dnl no --with-brotli option given, just check default places
1048    ;;
1049  *)
1050    dnl use the given --with-brotli spot
1051    PREFIX_BROTLI=$OPT_BROTLI
1052    ;;
1053  esac
1054
1055  dnl if given with a prefix, we set -L and -I based on that
1056  if test -n "$PREFIX_BROTLI"; then
1057    LIB_BROTLI="-lbrotlidec"
1058    LD_BROTLI=-L${PREFIX_BROTLI}/lib$libsuff
1059    CPP_BROTLI=-I${PREFIX_BROTLI}/include
1060    DIR_BROTLI=${PREFIX_BROTLI}/lib$libsuff
1061  fi
1062
1063  LDFLAGS="$LDFLAGS $LD_BROTLI"
1064  CPPFLAGS="$CPPFLAGS $CPP_BROTLI"
1065  LIBS="$LIB_BROTLI $LIBS"
1066
1067  AC_CHECK_LIB(brotlidec, BrotliDecoderDecompress)
1068
1069  AC_CHECK_HEADERS(brotli/decode.h,
1070    curl_brotli_msg="enabled (libbrotlidec)"
1071    HAVE_BROTLI=1
1072    AC_DEFINE(HAVE_BROTLI, 1, [if BROTLI is in use])
1073    AC_SUBST(HAVE_BROTLI, [1])
1074  )
1075
1076  if test X"$OPT_BROTLI" != Xoff &&
1077     test "$HAVE_BROTLI" != "1"; then
1078    AC_MSG_ERROR([BROTLI libs and/or directories were not found where specified!])
1079  fi
1080
1081  if test "$HAVE_BROTLI" = "1"; then
1082    if test -n "$DIR_BROTLI"; then
1083       dnl when the brotli shared libs were found in a path that the run-time
1084       dnl linker doesn't search through, we need to add it to CURL_LIBRARY_PATH
1085       dnl to prevent further configure tests to fail due to this
1086
1087       if test "x$cross_compiling" != "xyes"; then
1088         CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_BROTLI"
1089         export CURL_LIBRARY_PATH
1090         AC_MSG_NOTICE([Added $DIR_BROTLI to CURL_LIBRARY_PATH])
1091       fi
1092    fi
1093  else
1094    dnl no brotli, revert back to clean variables
1095    LDFLAGS=$CLEANLDFLAGS
1096    CPPFLAGS=$CLEANCPPFLAGS
1097    LIBS=$CLEANLIBS
1098  fi
1099fi
1100
1101dnl **********************************************************************
1102dnl Check for LDAP
1103dnl **********************************************************************
1104
1105LDAPLIBNAME=""
1106AC_ARG_WITH(ldap-lib,
1107AC_HELP_STRING([--with-ldap-lib=libname],[Specify name of ldap lib file]),
1108 [LDAPLIBNAME="$withval"])
1109
1110LBERLIBNAME=""
1111AC_ARG_WITH(lber-lib,
1112AC_HELP_STRING([--with-lber-lib=libname],[Specify name of lber lib file]),
1113 [LBERLIBNAME="$withval"])
1114
1115if test x$CURL_DISABLE_LDAP != x1 ; then
1116
1117  CURL_CHECK_HEADER_LBER
1118  CURL_CHECK_HEADER_LDAP
1119  CURL_CHECK_HEADER_LDAPSSL
1120  CURL_CHECK_HEADER_LDAP_SSL
1121
1122  if test -z "$LDAPLIBNAME" ; then
1123    if test "$curl_cv_native_windows" = "yes"; then
1124      dnl Windows uses a single and unique LDAP library name
1125      LDAPLIBNAME="wldap32"
1126      LBERLIBNAME="no"
1127    fi
1128  fi
1129
1130  if test "$LDAPLIBNAME" ; then
1131    AC_CHECK_LIB("$LDAPLIBNAME", ldap_init,, [
1132      AC_MSG_WARN(["$LDAPLIBNAME" is not an LDAP library: LDAP disabled])
1133      AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
1134      AC_SUBST(CURL_DISABLE_LDAP, [1])
1135      AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
1136      AC_SUBST(CURL_DISABLE_LDAPS, [1])])
1137  else
1138    dnl Try to find the right ldap libraries for this system
1139    CURL_CHECK_LIBS_LDAP
1140    case X-"$curl_cv_ldap_LIBS" in
1141      X-unknown)
1142        AC_MSG_WARN([Cannot find libraries for LDAP support: LDAP disabled])
1143        AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
1144        AC_SUBST(CURL_DISABLE_LDAP, [1])
1145        AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
1146        AC_SUBST(CURL_DISABLE_LDAPS, [1])
1147        ;;
1148    esac
1149  fi
1150fi
1151
1152if test x$CURL_DISABLE_LDAP != x1 ; then
1153
1154  if test "$LBERLIBNAME" ; then
1155    dnl If name is "no" then don't define this library at all
1156    dnl (it's only needed if libldap.so's dependencies are broken).
1157    if test "$LBERLIBNAME" != "no" ; then
1158      AC_CHECK_LIB("$LBERLIBNAME", ber_free,, [
1159        AC_MSG_WARN(["$LBERLIBNAME" is not an LBER library: LDAP disabled])
1160        AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
1161        AC_SUBST(CURL_DISABLE_LDAP, [1])
1162        AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
1163        AC_SUBST(CURL_DISABLE_LDAPS, [1])])
1164    fi
1165  fi
1166fi
1167
1168if test x$CURL_DISABLE_LDAP != x1 ; then
1169  AC_CHECK_FUNCS([ldap_url_parse ldap_init_fd])
1170
1171  if test "$LDAPLIBNAME" = "wldap32"; then
1172    curl_ldap_msg="enabled (winldap)"
1173    AC_DEFINE(USE_WIN32_LDAP, 1, [Use Windows LDAP implementation])
1174  else
1175    curl_ldap_msg="enabled (OpenLDAP)"
1176    if test "x$ac_cv_func_ldap_init_fd" = "xyes"; then
1177      AC_DEFINE(USE_OPENLDAP, 1, [Use OpenLDAP-specific code])
1178      AC_SUBST(USE_OPENLDAP, [1])
1179    fi
1180  fi
1181fi
1182
1183if test x$CURL_DISABLE_LDAPS != x1 ; then
1184    curl_ldaps_msg="enabled"
1185fi
1186
1187dnl **********************************************************************
1188dnl Checks for IPv6
1189dnl **********************************************************************
1190
1191AC_MSG_CHECKING([whether to enable IPv6])
1192AC_ARG_ENABLE(ipv6,
1193AC_HELP_STRING([--enable-ipv6],[Enable IPv6 (with IPv4) support])
1194AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),
1195[ case "$enableval" in
1196  no)
1197       AC_MSG_RESULT(no)
1198       ipv6=no
1199       ;;
1200  *)   AC_MSG_RESULT(yes)
1201       ipv6=yes
1202       ;;
1203  esac ],
1204
1205  AC_TRY_RUN([ /* is AF_INET6 available? */
1206#include <sys/types.h>
1207#ifdef HAVE_WINSOCK2_H
1208#include <winsock2.h>
1209#else
1210#include <sys/socket.h>
1211#endif
1212#include <stdlib.h> /* for exit() */
1213main()
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(yes)
1226  ipv6=yes
1227))
1228
1229if test "$ipv6" = "yes"; then
1230  curl_ipv6_msg="enabled"
1231fi
1232
1233# Check if struct sockaddr_in6 have sin6_scope_id member
1234if 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#ifdef HAVE_WINSOCK2_H
1239#include <winsock2.h>
1240#include <ws2tcpip.h>
1241#else
1242#include <netinet/in.h>
1243#if defined (__TANDEM)
1244# include <netinet/in6.h>
1245#endif
1246#endif] ,
1247  struct sockaddr_in6 s; s.sin6_scope_id = 0; , have_sin6_scope_id=yes)
1248  if test "$have_sin6_scope_id" = yes; then
1249    AC_MSG_RESULT([yes])
1250    AC_DEFINE(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID, 1, [Define to 1 if struct sockaddr_in6 has the sin6_scope_id member])
1251  else
1252    AC_MSG_RESULT([no])
1253  fi
1254fi
1255
1256dnl **********************************************************************
1257dnl Check if the operating system allows programs to write to their own argv[]
1258dnl **********************************************************************
1259
1260AC_MSG_CHECKING([if argv can be written to])
1261CURL_RUN_IFELSE([
1262int main(int argc, char ** argv) {
1263    argv[0][0] = ' ';
1264    return (argv[0][0] == ' ')?0:1;
1265}
1266],[
1267  curl_cv_writable_argv=yes
1268],[
1269  curl_cv_writable_argv=no
1270],[
1271  curl_cv_writable_argv=cross
1272])
1273case $curl_cv_writable_argv in
1274yes)
1275        AC_DEFINE(HAVE_WRITABLE_ARGV, 1, [Define this symbol if your OS supports changing the contents of argv])
1276        AC_MSG_RESULT(yes)
1277        ;;
1278no)
1279        AC_MSG_RESULT(no)
1280        ;;
1281*)
1282        AC_MSG_RESULT(no)
1283        AC_MSG_WARN([the previous check could not be made default was used])
1284        ;;
1285esac
1286
1287dnl **********************************************************************
1288dnl Check for GSS-API libraries
1289dnl **********************************************************************
1290
1291dnl check for GSS-API stuff in the /usr as default
1292
1293GSSAPI_ROOT="/usr"
1294AC_ARG_WITH(gssapi-includes,
1295  AC_HELP_STRING([--with-gssapi-includes=DIR],
1296                 [Specify location of GSS-API headers]),
1297  [ GSSAPI_INCS="-I$withval"
1298    want_gss="yes" ]
1299)
1300
1301AC_ARG_WITH(gssapi-libs,
1302  AC_HELP_STRING([--with-gssapi-libs=DIR],
1303                 [Specify location of GSS-API libs]),
1304  [ GSSAPI_LIB_DIR="-L$withval"
1305    want_gss="yes" ]
1306)
1307
1308AC_ARG_WITH(gssapi,
1309  AC_HELP_STRING([--with-gssapi=DIR],
1310                 [Where to look for GSS-API]), [
1311  GSSAPI_ROOT="$withval"
1312  if test x"$GSSAPI_ROOT" != xno; then
1313    want_gss="yes"
1314    if test x"$GSSAPI_ROOT" = xyes; then
1315      dnl if yes, then use default root
1316      GSSAPI_ROOT="/usr"
1317    fi
1318  fi
1319])
1320
1321: ${KRB5CONFIG:="$GSSAPI_ROOT/bin/krb5-config"}
1322
1323save_CPPFLAGS="$CPPFLAGS"
1324AC_MSG_CHECKING([if GSS-API support is requested])
1325if test x"$want_gss" = xyes; then
1326  AC_MSG_RESULT(yes)
1327
1328  if test -z "$GSSAPI_INCS"; then
1329     if test -n "$host_alias" -a -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then
1330        GSSAPI_INCS=`$GSSAPI_ROOT/bin/$host_alias-krb5-config --cflags gssapi`
1331     elif test -f "$KRB5CONFIG"; then
1332        GSSAPI_INCS=`$KRB5CONFIG --cflags gssapi`
1333     elif test "$GSSAPI_ROOT" != "yes"; then
1334        GSSAPI_INCS="-I$GSSAPI_ROOT/include"
1335     fi
1336  fi
1337
1338  CPPFLAGS="$CPPFLAGS $GSSAPI_INCS"
1339
1340  AC_CHECK_HEADER(gss.h,
1341    [
1342      dnl found in the given dirs
1343      AC_DEFINE(HAVE_GSSGNU, 1, [if you have GNU GSS])
1344      gnu_gss=yes
1345    ],
1346    [
1347      dnl not found, check Heimdal or MIT
1348      AC_CHECK_HEADERS([gssapi/gssapi.h], [], [not_mit=1])
1349      AC_CHECK_HEADERS(
1350        [gssapi/gssapi_generic.h gssapi/gssapi_krb5.h],
1351        [],
1352        [not_mit=1],
1353        [
1354AC_INCLUDES_DEFAULT
1355#ifdef HAVE_GSSAPI_GSSAPI_H
1356#include <gssapi/gssapi.h>
1357#endif
1358        ])
1359      if test "x$not_mit" = "x1"; then
1360        dnl MIT not found, check for Heimdal
1361        AC_CHECK_HEADER(gssapi.h,
1362            [
1363              dnl found
1364              AC_DEFINE(HAVE_GSSHEIMDAL, 1, [if you have Heimdal])
1365            ],
1366            [
1367              dnl no header found, disabling GSS
1368              want_gss=no
1369              AC_MSG_WARN(disabling GSS-API support since no header files were found)
1370            ]
1371          )
1372      else
1373        dnl MIT found
1374        AC_DEFINE(HAVE_GSSMIT, 1, [if you have MIT Kerberos])
1375        dnl check if we have a really old MIT Kerberos version (<= 1.2)
1376        AC_MSG_CHECKING([if GSS-API headers declare GSS_C_NT_HOSTBASED_SERVICE])
1377        AC_COMPILE_IFELSE([
1378          AC_LANG_PROGRAM([[
1379#include <gssapi/gssapi.h>
1380#include <gssapi/gssapi_generic.h>
1381#include <gssapi/gssapi_krb5.h>
1382          ]],[[
1383            gss_import_name(
1384                            (OM_uint32 *)0,
1385                            (gss_buffer_t)0,
1386                            GSS_C_NT_HOSTBASED_SERVICE,
1387                            (gss_name_t *)0);
1388          ]])
1389        ],[
1390          AC_MSG_RESULT([yes])
1391        ],[
1392          AC_MSG_RESULT([no])
1393          AC_DEFINE(HAVE_OLD_GSSMIT, 1,
1394            [if you have an old MIT Kerberos version, lacking GSS_C_NT_HOSTBASED_SERVICE])
1395        ])
1396      fi
1397    ]
1398  )
1399else
1400  AC_MSG_RESULT(no)
1401fi
1402if test x"$want_gss" = xyes; then
1403  AC_DEFINE(HAVE_GSSAPI, 1, [if you have GSS-API libraries])
1404  HAVE_GSSAPI=1
1405  curl_gss_msg="enabled (MIT Kerberos/Heimdal)"
1406
1407  if test -n "$gnu_gss"; then
1408    curl_gss_msg="enabled (GNU GSS)"
1409    LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
1410    LIBS="-lgss $LIBS"
1411  elif test -z "$GSSAPI_LIB_DIR"; then
1412     case $host in
1413     *-*-darwin*)
1414        LIBS="-lgssapi_krb5 -lresolv $LIBS"
1415        ;;
1416     *)
1417        if test -n "$host_alias" -a -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then
1418           dnl krb5-config doesn't have --libs-only-L or similar, put everything
1419           dnl into LIBS
1420           gss_libs=`$GSSAPI_ROOT/bin/$host_alias-krb5-config --libs gssapi`
1421           LIBS="$gss_libs $LIBS"
1422        elif test -f "$KRB5CONFIG"; then
1423           dnl krb5-config doesn't have --libs-only-L or similar, put everything
1424           dnl into LIBS
1425           gss_libs=`$KRB5CONFIG --libs gssapi`
1426           LIBS="$gss_libs $LIBS"
1427        else
1428           case $host in
1429           *-hp-hpux*)
1430              gss_libname="gss"
1431              ;;
1432           *)
1433              gss_libname="gssapi"
1434              ;;
1435           esac
1436
1437           if test "$GSSAPI_ROOT" != "yes"; then
1438              LDFLAGS="$LDFLAGS -L$GSSAPI_ROOT/lib$libsuff"
1439              LIBS="-l$gss_libname $LIBS"
1440           else
1441              LIBS="-l$gss_libname $LIBS"
1442           fi
1443        fi
1444        ;;
1445     esac
1446  else
1447     LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
1448     case $host in
1449     *-hp-hpux*)
1450        LIBS="-lgss $LIBS"
1451        ;;
1452     *)
1453        LIBS="-lgssapi $LIBS"
1454        ;;
1455     esac
1456  fi
1457else
1458  CPPFLAGS="$save_CPPFLAGS"
1459fi
1460
1461build_libstubgss=no
1462if test x"$want_gss" = "xyes"; then
1463  build_libstubgss=yes
1464fi
1465
1466AM_CONDITIONAL(BUILD_STUB_GSS, test "x$build_libstubgss" = "xyes")
1467
1468dnl -------------------------------------------------------------
1469dnl parse --with-default-ssl-backend so it can be validated below
1470dnl -------------------------------------------------------------
1471
1472DEFAULT_SSL_BACKEND=no
1473VALID_DEFAULT_SSL_BACKEND=
1474AC_ARG_WITH(default-ssl-backend,
1475AC_HELP_STRING([--with-default-ssl-backend=NAME],[Use NAME as default SSL backend])
1476AC_HELP_STRING([--without-default-ssl-backend],[Use implicit default SSL backend]),
1477  [DEFAULT_SSL_BACKEND=$withval])
1478case "$DEFAULT_SSL_BACKEND" in
1479  no)
1480    dnl --without-default-ssl-backend option used
1481    ;;
1482  default|yes)
1483    dnl --with-default-ssl-backend option used without name
1484    AC_MSG_ERROR([The name of the default SSL backend is required.])
1485    ;;
1486  *)
1487    dnl --with-default-ssl-backend option used with name
1488    AC_SUBST(DEFAULT_SSL_BACKEND)
1489    dnl needs to be validated below
1490    VALID_DEFAULT_SSL_BACKEND=no
1491    ;;
1492esac
1493
1494dnl **********************************************************************
1495
1496dnl -------------------------------------------------
1497dnl check winssl option before other SSL libraries
1498dnl -------------------------------------------------
1499
1500OPT_WINSSL=no
1501AC_ARG_WITH(winssl,dnl
1502AC_HELP_STRING([--with-winssl],[enable Windows native SSL/TLS])
1503AC_HELP_STRING([--without-winssl], [disable Windows native SSL/TLS]),
1504  OPT_WINSSL=$withval)
1505
1506AC_ARG_WITH(schannel,dnl
1507AC_HELP_STRING([--with-schannel],[enable Windows native SSL/TLS])
1508AC_HELP_STRING([--without-schannel], [disable Windows native SSL/TLS]),
1509  OPT_WINSSL=$withval)
1510
1511AC_MSG_CHECKING([whether to enable Windows native SSL/TLS (Windows native builds only)])
1512if test -z "$ssl_backends" -o "x$OPT_WINSSL" != xno; then
1513  ssl_msg=
1514  if test "x$OPT_WINSSL" != "xno"  &&
1515     test "x$curl_cv_native_windows" = "xyes"; then
1516    AC_MSG_RESULT(yes)
1517    AC_DEFINE(USE_SCHANNEL, 1, [to enable Windows native SSL/TLS support])
1518    AC_SUBST(USE_SCHANNEL, [1])
1519    ssl_msg="Windows-native"
1520    test schannel != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
1521    WINSSL_ENABLED=1
1522    # --with-winssl implies --enable-sspi
1523    AC_DEFINE(USE_WINDOWS_SSPI, 1, [to enable SSPI support])
1524    AC_SUBST(USE_WINDOWS_SSPI, [1])
1525    curl_sspi_msg="enabled"
1526    LIBS="-lcrypt32 $LIBS"
1527  else
1528    AC_MSG_RESULT(no)
1529  fi
1530  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
1531else
1532  AC_MSG_RESULT(no)
1533fi
1534
1535OPT_SECURETRANSPORT=no
1536AC_ARG_WITH(darwinssl,dnl
1537AC_HELP_STRING([--with-darwinssl],[enable Apple OS native SSL/TLS])
1538AC_HELP_STRING([--without-darwinssl], [disable Apple OS native SSL/TLS]),
1539  OPT_SECURETRANSPORT=$withval)
1540
1541AC_ARG_WITH(secure-transport,dnl
1542AC_HELP_STRING([--with-secure-transport],[enable Apple OS native SSL/TLS])
1543AC_HELP_STRING([--without-secure-transport], [disable Apple OS native SSL/TLS]),
1544  OPT_SECURETRANSPORT=$withval)
1545
1546AC_MSG_CHECKING([whether to enable Secure Transport])
1547if test -z "$ssl_backends" -o "x$OPT_SECURETRANSPORT" != xno; then
1548  if test "x$OPT_SECURETRANSPORT" != "xno" &&
1549     test -d "/System/Library/Frameworks/Security.framework"; then
1550    AC_MSG_RESULT(yes)
1551    AC_DEFINE(USE_SECTRANSP, 1, [enable Secure Transport])
1552    AC_SUBST(USE_SECTRANSP, [1])
1553    ssl_msg="Secure Transport"
1554    test secure-transport != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
1555    SECURETRANSPORT_ENABLED=1
1556    LDFLAGS="$LDFLAGS -framework CoreFoundation -framework Security"
1557  else
1558    AC_MSG_RESULT(no)
1559  fi
1560  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
1561else
1562  AC_MSG_RESULT(no)
1563fi
1564
1565OPT_AMISSL=no
1566AC_ARG_WITH(amissl,dnl
1567AC_HELP_STRING([--with-amissl],[enable Amiga native SSL/TLS (AmiSSL)])
1568AC_HELP_STRING([--without-amissl], [disable Amiga native SSL/TLS (AmiSSL)]),
1569  OPT_AMISSL=$withval)
1570
1571AC_MSG_CHECKING([whether to enable Amiga native SSL/TLS (AmiSSL)])
1572if test "$HAVE_PROTO_BSDSOCKET_H" == "1"; then
1573  if test -z "$ssl_backends" -o "x$OPT_AMISSL" != xno; then
1574    ssl_msg=
1575    if test "x$OPT_AMISSL" != "xno"; then
1576      AC_MSG_RESULT(yes)
1577      ssl_msg="AmiSSL"
1578      test amissl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
1579      AMISSL_ENABLED=1
1580      LIBS="-lamisslauto $LIBS"
1581      AC_DEFINE(USE_AMISSL, 1, [if AmiSSL is in use])
1582      AC_DEFINE(USE_OPENSSL, 1, [if OpenSSL is in use])
1583    else
1584      AC_MSG_RESULT(no)
1585    fi
1586    test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
1587  else
1588    AC_MSG_RESULT(no)
1589  fi
1590else
1591  AC_MSG_RESULT(no)
1592fi
1593
1594dnl **********************************************************************
1595dnl Check for the presence of SSL libraries and headers
1596dnl **********************************************************************
1597
1598dnl Default to compiler & linker defaults for SSL files & libraries.
1599OPT_SSL=off
1600dnl Default to no CA bundle
1601ca="no"
1602AC_ARG_WITH(ssl,dnl
1603AC_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])
1604AC_HELP_STRING([--without-ssl], [disable OpenSSL]),
1605  OPT_SSL=$withval)
1606
1607if test -z "$ssl_backends" -o "x$OPT_SSL" != xno &&
1608   test X"$OPT_SSL" != Xno; then
1609  ssl_msg=
1610
1611  dnl backup the pre-ssl variables
1612  CLEANLDFLAGS="$LDFLAGS"
1613  CLEANCPPFLAGS="$CPPFLAGS"
1614  CLEANLIBS="$LIBS"
1615
1616  dnl This is for Msys/Mingw
1617  case $host in
1618    *-*-msys* | *-*-mingw*)
1619      AC_MSG_CHECKING([for gdi32])
1620      my_ac_save_LIBS=$LIBS
1621      LIBS="-lgdi32 $LIBS"
1622      AC_TRY_LINK([#include <windef.h>
1623                   #include <wingdi.h>],
1624                   [GdiFlush();],
1625                   [ dnl worked!
1626                   AC_MSG_RESULT([yes])],
1627                   [ dnl failed, restore LIBS
1628                   LIBS=$my_ac_save_LIBS
1629                   AC_MSG_RESULT(no)]
1630                  )
1631      ;;
1632  esac
1633
1634  case "$OPT_SSL" in
1635  yes)
1636    dnl --with-ssl (without path) used
1637    if test x$cross_compiling != xyes; then
1638      dnl only do pkg-config magic when not cross-compiling
1639      PKGTEST="yes"
1640    fi
1641    PREFIX_OPENSSL=/usr/local/ssl
1642    LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
1643    ;;
1644  off)
1645    dnl no --with-ssl option given, just check default places
1646    if test x$cross_compiling != xyes; then
1647      dnl only do pkg-config magic when not cross-compiling
1648      PKGTEST="yes"
1649    fi
1650    PREFIX_OPENSSL=
1651    ;;
1652  *)
1653    dnl check the given --with-ssl spot
1654    PKGTEST="no"
1655    PREFIX_OPENSSL=$OPT_SSL
1656
1657    dnl Try pkg-config even when cross-compiling.  Since we
1658    dnl specify PKG_CONFIG_LIBDIR we're only looking where
1659    dnl the user told us to look
1660    OPENSSL_PCDIR="$OPT_SSL/lib/pkgconfig"
1661    if test -f "$OPENSSL_PCDIR/openssl.pc"; then
1662      AC_MSG_NOTICE([PKG_CONFIG_LIBDIR will be set to "$OPENSSL_PCDIR"])
1663      PKGTEST="yes"
1664    elif test ! -f "$PREFIX_OPENSSL/include/openssl/ssl.h"; then
1665      AC_MSG_ERROR([$PREFIX_OPENSSL is a bad --with-ssl prefix!])
1666    fi
1667
1668    dnl in case pkg-config comes up empty, use what we got
1669    dnl via --with-ssl
1670    LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
1671    if test "$PREFIX_OPENSSL" != "/usr" ; then
1672      SSL_LDFLAGS="-L$LIB_OPENSSL"
1673      SSL_CPPFLAGS="-I$PREFIX_OPENSSL/include"
1674    fi
1675    SSL_CPPFLAGS="$SSL_CPPFLAGS -I$PREFIX_OPENSSL/include/openssl"
1676    ;;
1677  esac
1678
1679  if test "$PKGTEST" = "yes"; then
1680
1681    CURL_CHECK_PKGCONFIG(openssl, [$OPENSSL_PCDIR])
1682
1683    if test "$PKGCONFIG" != "no" ; then
1684      SSL_LIBS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
1685        $PKGCONFIG --libs-only-l --libs-only-other openssl 2>/dev/null`
1686
1687      SSL_LDFLAGS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
1688        $PKGCONFIG --libs-only-L openssl 2>/dev/null`
1689
1690      SSL_CPPFLAGS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
1691        $PKGCONFIG --cflags-only-I openssl 2>/dev/null`
1692
1693      AC_SUBST(SSL_LIBS)
1694      AC_MSG_NOTICE([pkg-config: SSL_LIBS: "$SSL_LIBS"])
1695      AC_MSG_NOTICE([pkg-config: SSL_LDFLAGS: "$SSL_LDFLAGS"])
1696      AC_MSG_NOTICE([pkg-config: SSL_CPPFLAGS: "$SSL_CPPFLAGS"])
1697
1698      LIB_OPENSSL=`echo $SSL_LDFLAGS | sed -e 's/-L//g'`
1699
1700      dnl use the values pkg-config reported.  This is here
1701      dnl instead of below with CPPFLAGS and LDFLAGS because we only
1702      dnl learn about this via pkg-config.  If we only have
1703      dnl the argument to --with-ssl we don't know what
1704      dnl additional libs may be necessary.  Hope that we
1705      dnl don't need any.
1706      LIBS="$SSL_LIBS $LIBS"
1707    fi
1708  fi
1709
1710  dnl finally, set flags to use SSL
1711  CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
1712  LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
1713
1714  AC_CHECK_LIB(crypto, HMAC_Update,[
1715     HAVECRYPTO="yes"
1716     LIBS="-lcrypto $LIBS"
1717     ],[
1718     LDFLAGS="$CLEANLDFLAGS -L$LIB_OPENSSL"
1719     if test "$PKGCONFIG" = "no" ; then
1720       # only set this if pkg-config wasn't used
1721       CPPFLAGS="$CLEANCPPFLAGS -I$PREFIX_OPENSSL/include/openssl -I$PREFIX_OPENSSL/include"
1722     fi
1723     AC_CHECK_LIB(crypto, HMAC_Init_ex,[
1724       HAVECRYPTO="yes"
1725       LIBS="-lcrypto $LIBS"], [
1726
1727       dnl still no, but what about with -ldl?
1728       AC_MSG_CHECKING([OpenSSL linking with -ldl])
1729       LIBS="$CLEANLIBS -lcrypto -ldl"
1730       AC_TRY_LINK(
1731       [
1732         #include <openssl/err.h>
1733       ],
1734       [
1735         ERR_clear_error();
1736       ],
1737       [
1738         AC_MSG_RESULT(yes)
1739         HAVECRYPTO="yes"
1740       ],
1741       [
1742         AC_MSG_RESULT(no)
1743         dnl ok, so what about both -ldl and -lpthread?
1744
1745         AC_MSG_CHECKING([OpenSSL linking with -ldl and -lpthread])
1746         LIBS="$CLEANLIBS -lcrypto -ldl -lpthread"
1747         AC_TRY_LINK(
1748         [
1749           #include <openssl/err.h>
1750         ],
1751         [
1752           ERR_clear_error();
1753         ],
1754         [
1755           AC_MSG_RESULT(yes)
1756           HAVECRYPTO="yes"
1757         ],
1758         [
1759           AC_MSG_RESULT(no)
1760           LDFLAGS="$CLEANLDFLAGS"
1761           CPPFLAGS="$CLEANCPPFLAGS"
1762           LIBS="$CLEANLIBS"
1763
1764         ])
1765
1766       ])
1767
1768     ])
1769  ])
1770
1771  if test X"$HAVECRYPTO" = X"yes"; then
1772    dnl This is only reasonable to do if crypto actually is there: check for
1773    dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
1774
1775    AC_CHECK_LIB(ssl, SSL_connect)
1776
1777    if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
1778        dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
1779        AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
1780        OLIBS=$LIBS
1781        LIBS="-lRSAglue -lrsaref $LIBS"
1782        AC_CHECK_LIB(ssl, SSL_connect)
1783        if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
1784            dnl still no SSL_connect
1785            AC_MSG_RESULT(no)
1786            LIBS=$OLIBS
1787        else
1788            AC_MSG_RESULT(yes)
1789        fi
1790
1791    else
1792
1793      dnl Have the libraries--check for OpenSSL headers
1794      AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
1795                       openssl/pem.h openssl/ssl.h openssl/err.h,
1796        ssl_msg="OpenSSL"
1797	test openssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
1798        OPENSSL_ENABLED=1
1799        AC_DEFINE(USE_OPENSSL, 1, [if OpenSSL is in use]))
1800
1801      if test $ac_cv_header_openssl_x509_h = no; then
1802        dnl we don't use the "action" part of the AC_CHECK_HEADERS macro
1803        dnl since 'err.h' might in fact find a krb4 header with the same
1804        dnl name
1805        AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h)
1806
1807        if test $ac_cv_header_x509_h = yes &&
1808           test $ac_cv_header_crypto_h = yes &&
1809           test $ac_cv_header_ssl_h = yes; then
1810          dnl three matches
1811          ssl_msg="OpenSSL"
1812          OPENSSL_ENABLED=1
1813        fi
1814      fi
1815    fi
1816
1817    if test X"$OPENSSL_ENABLED" != X"1"; then
1818       LIBS="$CLEANLIBS"
1819    fi
1820
1821    if test X"$OPT_SSL" != Xoff &&
1822       test "$OPENSSL_ENABLED" != "1"; then
1823      AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
1824    fi
1825  fi
1826
1827  if test X"$OPENSSL_ENABLED" = X"1"; then
1828    dnl These can only exist if OpenSSL exists
1829    dnl Older versions of Cyassl (some time before 2.9.4) don't have
1830    dnl SSL_get_shutdown (but this check won't actually detect it there
1831    dnl as it's a macro that needs the header files be included)
1832    dnl OpenSSL_version is introduced in 3.0.0
1833
1834    AC_CHECK_FUNCS( RAND_egd \
1835                    SSL_get_shutdown \
1836                    SSLv2_client_method \
1837                    OpenSSL_version )
1838
1839    AC_MSG_CHECKING([for BoringSSL])
1840    AC_COMPILE_IFELSE([
1841        AC_LANG_PROGRAM([[
1842                #include <openssl/base.h>
1843                ]],[[
1844                #ifndef OPENSSL_IS_BORINGSSL
1845                #error not boringssl
1846                #endif
1847       ]])
1848    ],[
1849        AC_MSG_RESULT([yes])
1850        AC_DEFINE_UNQUOTED(HAVE_BORINGSSL, 1,
1851                           [Define to 1 if using BoringSSL.])
1852        ssl_msg="BoringSSL"
1853    ],[
1854        AC_MSG_RESULT([no])
1855    ])
1856
1857    AC_MSG_CHECKING([for libressl])
1858    AC_COMPILE_IFELSE([
1859      AC_LANG_PROGRAM([[
1860#include <openssl/opensslv.h>
1861      ]],[[
1862        int dummy = LIBRESSL_VERSION_NUMBER;
1863      ]])
1864    ],[
1865      AC_MSG_RESULT([yes])
1866      AC_DEFINE_UNQUOTED(HAVE_LIBRESSL, 1,
1867        [Define to 1 if using libressl.])
1868      ssl_msg="libressl"
1869    ],[
1870      AC_MSG_RESULT([no])
1871    ])
1872  fi
1873
1874  if test "$OPENSSL_ENABLED" = "1"; then
1875    if test -n "$LIB_OPENSSL"; then
1876       dnl when the ssl shared libs were found in a path that the run-time
1877       dnl linker doesn't search through, we need to add it to CURL_LIBRARY_PATH
1878       dnl to prevent further configure tests to fail due to this
1879       if test "x$cross_compiling" != "xyes"; then
1880         CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$LIB_OPENSSL"
1881         export CURL_LIBRARY_PATH
1882         AC_MSG_NOTICE([Added $LIB_OPENSSL to CURL_LIBRARY_PATH])
1883       fi
1884    fi
1885    CURL_CHECK_OPENSSL_API
1886    check_for_ca_bundle=1
1887  fi
1888
1889  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
1890fi
1891
1892dnl **********************************************************************
1893dnl Check for the random seed preferences
1894dnl **********************************************************************
1895
1896if test X"$OPENSSL_ENABLED" = X"1"; then
1897  AC_ARG_WITH(egd-socket,
1898  AC_HELP_STRING([--with-egd-socket=FILE],
1899                 [Entropy Gathering Daemon socket pathname]),
1900      [ EGD_SOCKET="$withval" ]
1901  )
1902  if test -n "$EGD_SOCKET" ; then
1903          AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET",
1904          [your Entropy Gathering Daemon socket pathname] )
1905  fi
1906
1907  dnl Check for user-specified random device
1908  AC_ARG_WITH(random,
1909  AC_HELP_STRING([--with-random=FILE],
1910                 [read randomness from FILE (default=/dev/urandom)]),
1911      [ RANDOM_FILE="$withval" ],
1912      [
1913          if test x$cross_compiling != xyes; then
1914            dnl Check for random device
1915            AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
1916          else
1917            AC_MSG_WARN([skipped the /dev/urandom detection when cross-compiling])
1918          fi
1919      ]
1920  )
1921  if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
1922          AC_SUBST(RANDOM_FILE)
1923          AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
1924          [a suitable file to read random data from])
1925  fi
1926fi
1927
1928dnl ---
1929dnl We require OpenSSL with SRP support.
1930dnl ---
1931if test "$OPENSSL_ENABLED" = "1"; then
1932  AC_CHECK_LIB(crypto, SRP_Calc_client_key,
1933   [
1934     AC_DEFINE(HAVE_OPENSSL_SRP, 1, [if you have the function SRP_Calc_client_key])
1935     AC_SUBST(HAVE_OPENSSL_SRP, [1])
1936   ])
1937fi
1938
1939dnl ---
1940dnl Whether the OpenSSL configuration will be loaded automatically
1941dnl ---
1942if test X"$OPENSSL_ENABLED" = X"1"; then
1943AC_ARG_ENABLE(openssl-auto-load-config,
1944AC_HELP_STRING([--enable-openssl-auto-load-config],[Enable automatic loading of OpenSSL configuration])
1945AC_HELP_STRING([--disable-openssl-auto-load-config],[Disable automatic loading of OpenSSL configuration]),
1946[ if test X"$enableval" = X"no"; then
1947    AC_MSG_NOTICE([automatic loading of OpenSSL configuration disabled])
1948    AC_DEFINE(CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG, 1, [if the OpenSSL configuration won't be loaded automatically])
1949  fi
1950])
1951fi
1952
1953dnl ----------------------------------------------------
1954dnl check for GnuTLS
1955dnl ----------------------------------------------------
1956
1957dnl Default to compiler & linker defaults for GnuTLS files & libraries.
1958OPT_GNUTLS=no
1959
1960AC_ARG_WITH(gnutls,dnl
1961AC_HELP_STRING([--with-gnutls=PATH],[where to look for GnuTLS, PATH points to the installation root])
1962AC_HELP_STRING([--without-gnutls], [disable GnuTLS detection]),
1963  OPT_GNUTLS=$withval)
1964
1965if test -z "$ssl_backends" -o "x$OPT_GNUTLS" != xno; then
1966  ssl_msg=
1967
1968  if test X"$OPT_GNUTLS" != Xno; then
1969
1970    addld=""
1971    addlib=""
1972    gtlslib=""
1973    version=""
1974    addcflags=""
1975
1976    if test "x$OPT_GNUTLS" = "xyes"; then
1977      dnl this is with no partiular path given
1978      CURL_CHECK_PKGCONFIG(gnutls)
1979
1980      if test "$PKGCONFIG" != "no" ; then
1981        addlib=`$PKGCONFIG --libs-only-l gnutls`
1982        addld=`$PKGCONFIG --libs-only-L gnutls`
1983        addcflags=`$PKGCONFIG --cflags-only-I gnutls`
1984        version=`$PKGCONFIG --modversion gnutls`
1985        gtlslib=`echo $addld | $SED -e 's/-L//'`
1986      else
1987        dnl without pkg-config, we try libgnutls-config as that was how it
1988        dnl used to be done
1989        check=`libgnutls-config --version 2>/dev/null`
1990        if test -n "$check"; then
1991          addlib=`libgnutls-config --libs`
1992          addcflags=`libgnutls-config --cflags`
1993          version=`libgnutls-config --version`
1994          gtlslib=`libgnutls-config --prefix`/lib$libsuff
1995        fi
1996      fi
1997    else
1998      dnl this is with a given path, first check if there's a libgnutls-config
1999      dnl there and if not, make an educated guess
2000      cfg=$OPT_GNUTLS/bin/libgnutls-config
2001      check=`$cfg --version 2>/dev/null`
2002      if test -n "$check"; then
2003        addlib=`$cfg --libs`
2004        addcflags=`$cfg --cflags`
2005        version=`$cfg --version`
2006        gtlslib=`$cfg --prefix`/lib$libsuff
2007      else
2008        dnl without pkg-config and libgnutls-config, we guess a lot!
2009        addlib=-lgnutls
2010        addld=-L$OPT_GNUTLS/lib$libsuff
2011        addcflags=-I$OPT_GNUTLS/include
2012        version="" # we just don't know
2013        gtlslib=$OPT_GNUTLS/lib$libsuff
2014      fi
2015    fi
2016
2017    if test -z "$version"; then
2018      dnl lots of efforts, still no go
2019      version="unknown"
2020    fi
2021
2022    if test -n "$addlib"; then
2023
2024      CLEANLIBS="$LIBS"
2025      CLEANCPPFLAGS="$CPPFLAGS"
2026      CLEANLDFLAGS="$LDFLAGS"
2027
2028      LIBS="$addlib $LIBS"
2029      LDFLAGS="$LDFLAGS $addld"
2030      if test "$addcflags" != "-I/usr/include"; then
2031         CPPFLAGS="$CPPFLAGS $addcflags"
2032      fi
2033
2034      AC_CHECK_LIB(gnutls, gnutls_check_version,
2035       [
2036       AC_DEFINE(USE_GNUTLS, 1, [if GnuTLS is enabled])
2037       AC_SUBST(USE_GNUTLS, [1])
2038       GNUTLS_ENABLED=1
2039       USE_GNUTLS="yes"
2040       ssl_msg="GnuTLS"
2041       test gnutls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2042       ],
2043       [
2044         LIBS="$CLEANLIBS"
2045         CPPFLAGS="$CLEANCPPFLAGS"
2046       ])
2047
2048      if test "x$USE_GNUTLS" = "xyes"; then
2049        AC_MSG_NOTICE([detected GnuTLS version $version])
2050        check_for_ca_bundle=1
2051        if test -n "$gtlslib"; then
2052          dnl when shared libs were found in a path that the run-time
2053          dnl linker doesn't search through, we need to add it to
2054          dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
2055          dnl due to this
2056          if test "x$cross_compiling" != "xyes"; then
2057            CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$gtlslib"
2058            export CURL_LIBRARY_PATH
2059            AC_MSG_NOTICE([Added $gtlslib to CURL_LIBRARY_PATH])
2060          fi
2061        fi
2062        AC_CHECK_FUNCS([gnutls_certificate_set_x509_key_file2 gnutls_alpn_set_protocols gnutls_ocsp_req_init])
2063      fi
2064
2065    fi
2066
2067  fi dnl GNUTLS not disabled
2068
2069  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
2070fi
2071
2072dnl ---
2073dnl Check which crypto backend GnuTLS uses
2074dnl ---
2075
2076if test "$GNUTLS_ENABLED" = "1"; then
2077  USE_GNUTLS_NETTLE=
2078  # First check if we can detect either crypto library via transitive linking
2079  AC_CHECK_LIB(gnutls, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ])
2080  if test "$USE_GNUTLS_NETTLE" = ""; then
2081    AC_CHECK_LIB(gnutls, gcry_control, [ USE_GNUTLS_NETTLE=0 ])
2082  fi
2083  # If not, try linking directly to both of them to see if they are available
2084  if test "$USE_GNUTLS_NETTLE" = ""; then
2085    AC_CHECK_LIB(nettle, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ])
2086  fi
2087  if test "$USE_GNUTLS_NETTLE" = ""; then
2088    AC_CHECK_LIB(gcrypt, gcry_control, [ USE_GNUTLS_NETTLE=0 ])
2089  fi
2090  if test "$USE_GNUTLS_NETTLE" = ""; then
2091    AC_MSG_ERROR([GnuTLS found, but neither gcrypt nor nettle found])
2092  fi
2093  if test "$USE_GNUTLS_NETTLE" = "1"; then
2094    AC_DEFINE(USE_GNUTLS_NETTLE, 1, [if GnuTLS uses nettle as crypto backend])
2095    AC_SUBST(USE_GNUTLS_NETTLE, [1])
2096    LIBS="-lnettle $LIBS"
2097  else
2098    LIBS="-lgcrypt $LIBS"
2099  fi
2100fi
2101
2102dnl ---
2103dnl We require GnuTLS with SRP support.
2104dnl ---
2105if test "$GNUTLS_ENABLED" = "1"; then
2106  AC_CHECK_LIB(gnutls, gnutls_srp_verifier,
2107   [
2108     AC_DEFINE(HAVE_GNUTLS_SRP, 1, [if you have the function gnutls_srp_verifier])
2109     AC_SUBST(HAVE_GNUTLS_SRP, [1])
2110   ])
2111fi
2112
2113dnl ----------------------------------------------------
2114dnl check for PolarSSL
2115dnl ----------------------------------------------------
2116
2117dnl Default to compiler & linker defaults for PolarSSL files & libraries.
2118OPT_POLARSSL=no
2119
2120_cppflags=$CPPFLAGS
2121_ldflags=$LDFLAGS
2122AC_ARG_WITH(polarssl,dnl
2123AC_HELP_STRING([--with-polarssl=PATH],[where to look for PolarSSL, PATH points to the installation root])
2124AC_HELP_STRING([--without-polarssl], [disable PolarSSL detection]),
2125  OPT_POLARSSL=$withval)
2126
2127if test -z "$ssl_backends" -o "x$OPT_POLARSSL" != xno; then
2128  ssl_msg=
2129
2130  if test X"$OPT_POLARSSL" != Xno; then
2131
2132    if test "$OPT_POLARSSL" = "yes"; then
2133      OPT_POLARSSL=""
2134    fi
2135
2136    if test -z "$OPT_POLARSSL" ; then
2137      dnl check for lib first without setting any new path
2138
2139      AC_CHECK_LIB(polarssl, havege_init,
2140      dnl libpolarssl found, set the variable
2141       [
2142         AC_DEFINE(USE_POLARSSL, 1, [if PolarSSL is enabled])
2143         AC_SUBST(USE_POLARSSL, [1])
2144         POLARSSL_ENABLED=1
2145         USE_POLARSSL="yes"
2146         ssl_msg="PolarSSL"
2147	 test polarssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2148        ])
2149    fi
2150
2151    addld=""
2152    addlib=""
2153    addcflags=""
2154    polarssllib=""
2155
2156    if test "x$USE_POLARSSL" != "xyes"; then
2157      dnl add the path and test again
2158      addld=-L$OPT_POLARSSL/lib$libsuff
2159      addcflags=-I$OPT_POLARSSL/include
2160      polarssllib=$OPT_POLARSSL/lib$libsuff
2161
2162      LDFLAGS="$LDFLAGS $addld"
2163      if test "$addcflags" != "-I/usr/include"; then
2164         CPPFLAGS="$CPPFLAGS $addcflags"
2165      fi
2166
2167      AC_CHECK_LIB(polarssl, ssl_init,
2168       [
2169       AC_DEFINE(USE_POLARSSL, 1, [if PolarSSL is enabled])
2170       AC_SUBST(USE_POLARSSL, [1])
2171       POLARSSL_ENABLED=1
2172       USE_POLARSSL="yes"
2173       ssl_msg="PolarSSL"
2174       test polarssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2175       ],
2176       [
2177         CPPFLAGS=$_cppflags
2178         LDFLAGS=$_ldflags
2179       ])
2180    fi
2181
2182    if test "x$USE_POLARSSL" = "xyes"; then
2183      AC_MSG_NOTICE([detected PolarSSL])
2184      check_for_ca_bundle=1
2185      LIBS="-lpolarssl $LIBS"
2186
2187      if test -n "$polarssllib"; then
2188        dnl when shared libs were found in a path that the run-time
2189        dnl linker doesn't search through, we need to add it to
2190        dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
2191        dnl due to this
2192        if test "x$cross_compiling" != "xyes"; then
2193          CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$polarssllib"
2194          export CURL_LIBRARY_PATH
2195          AC_MSG_NOTICE([Added $polarssllib to CURL_LIBRARY_PATH])
2196        fi
2197      fi
2198    fi
2199
2200  fi dnl PolarSSL not disabled
2201
2202  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
2203fi
2204
2205dnl ----------------------------------------------------
2206dnl check for mbedTLS
2207dnl ----------------------------------------------------
2208
2209OPT_MBEDTLS=no
2210
2211_cppflags=$CPPFLAGS
2212_ldflags=$LDFLAGS
2213AC_ARG_WITH(mbedtls,dnl
2214AC_HELP_STRING([--with-mbedtls=PATH],[where to look for mbedTLS, PATH points to the installation root])
2215AC_HELP_STRING([--without-mbedtls], [disable mbedTLS detection]),
2216  OPT_MBEDTLS=$withval)
2217
2218if test -z "$ssl_backends" -o "x$OPT_MBEDTLS" != xno; then
2219  ssl_msg=
2220
2221  if test X"$OPT_MBEDTLS" != Xno; then
2222
2223    if test "$OPT_MBEDTLS" = "yes"; then
2224      OPT_MBEDTLS=""
2225    fi
2226
2227    if test -z "$OPT_MBEDTLS" ; then
2228      dnl check for lib first without setting any new path
2229
2230      AC_CHECK_LIB(mbedtls, mbedtls_havege_init,
2231      dnl libmbedtls found, set the variable
2232       [
2233         AC_DEFINE(USE_MBEDTLS, 1, [if mbedTLS is enabled])
2234         AC_SUBST(USE_MBEDTLS, [1])
2235         MBEDTLS_ENABLED=1
2236         USE_MBEDTLS="yes"
2237         ssl_msg="mbedTLS"
2238	 test mbedtls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2239        ], [], -lmbedx509 -lmbedcrypto)
2240    fi
2241
2242    addld=""
2243    addlib=""
2244    addcflags=""
2245    mbedtlslib=""
2246
2247    if test "x$USE_MBEDTLS" != "xyes"; then
2248      dnl add the path and test again
2249      addld=-L$OPT_MBEDTLS/lib$libsuff
2250      addcflags=-I$OPT_MBEDTLS/include
2251      mbedtlslib=$OPT_MBEDTLS/lib$libsuff
2252
2253      LDFLAGS="$LDFLAGS $addld"
2254      if test "$addcflags" != "-I/usr/include"; then
2255         CPPFLAGS="$CPPFLAGS $addcflags"
2256      fi
2257
2258      AC_CHECK_LIB(mbedtls, mbedtls_ssl_init,
2259       [
2260       AC_DEFINE(USE_MBEDTLS, 1, [if mbedTLS is enabled])
2261       AC_SUBST(USE_MBEDTLS, [1])
2262       MBEDTLS_ENABLED=1
2263       USE_MBEDTLS="yes"
2264       ssl_msg="mbedTLS"
2265       test mbedtls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2266       ],
2267       [
2268         CPPFLAGS=$_cppflags
2269         LDFLAGS=$_ldflags
2270       ], -lmbedx509 -lmbedcrypto)
2271    fi
2272
2273    if test "x$USE_MBEDTLS" = "xyes"; then
2274      AC_MSG_NOTICE([detected mbedTLS])
2275      check_for_ca_bundle=1
2276
2277      LIBS="-lmbedtls -lmbedx509 -lmbedcrypto $LIBS"
2278
2279      if test -n "$mbedtlslib"; then
2280        dnl when shared libs were found in a path that the run-time
2281        dnl linker doesn't search through, we need to add it to
2282        dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
2283        dnl due to this
2284        if test "x$cross_compiling" != "xyes"; then
2285          CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$mbedtlslib"
2286          export CURL_LIBRARY_PATH
2287          AC_MSG_NOTICE([Added $mbedtlslib to CURL_LIBRARY_PATH])
2288        fi
2289      fi
2290    fi
2291
2292  fi dnl mbedTLS not disabled
2293
2294  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
2295fi
2296
2297dnl ----------------------------------------------------
2298dnl check for CyaSSL
2299dnl ----------------------------------------------------
2300
2301dnl Default to compiler & linker defaults for CyaSSL files & libraries.
2302OPT_CYASSL=no
2303
2304_cppflags=$CPPFLAGS
2305_ldflags=$LDFLAGS
2306AC_ARG_WITH(cyassl,dnl
2307AC_HELP_STRING([--with-cyassl=PATH],[where to look for CyaSSL, PATH points to the installation root (default: system lib default)])
2308AC_HELP_STRING([--without-cyassl], [disable CyaSSL detection]),
2309  OPT_CYASSL=$withval)
2310
2311dnl provide --with-wolfssl as an alias for --with-cyassl
2312AC_ARG_WITH(wolfssl,dnl
2313AC_HELP_STRING([--with-wolfssl=PATH],[where to look for WolfSSL, PATH points to the installation root (default: system lib default)])
2314AC_HELP_STRING([--without-wolfssl], [disable WolfSSL detection]),
2315  OPT_CYASSL=$withval)
2316
2317if test -z "$ssl_backends" -o "x$OPT_CYASSL" != xno; then
2318  ssl_msg=
2319
2320  if test X"$OPT_CYASSL" != Xno; then
2321
2322    if test "$OPT_CYASSL" = "yes"; then
2323      OPT_CYASSL=""
2324    fi
2325
2326    dnl This should be reworked to use pkg-config instead
2327
2328    cyassllibname=cyassl
2329
2330    if test -z "$OPT_CYASSL" ; then
2331      dnl check for lib in system default first
2332
2333      AC_CHECK_LIB(cyassl, CyaSSL_Init,
2334      dnl libcyassl found, set the variable
2335       [
2336         AC_DEFINE(USE_CYASSL, 1, [if CyaSSL is enabled])
2337         AC_SUBST(USE_CYASSL, [1])
2338         CYASSL_ENABLED=1
2339         USE_CYASSL="yes"
2340         ssl_msg="CyaSSL"
2341	 test cyassl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2342        ])
2343    fi
2344
2345    addld=""
2346    addlib=""
2347    addcflags=""
2348    cyassllib=""
2349
2350    if test "x$USE_CYASSL" != "xyes"; then
2351      dnl add the path and test again
2352      addld=-L$OPT_CYASSL/lib$libsuff
2353      addcflags=-I$OPT_CYASSL/include
2354      cyassllib=$OPT_CYASSL/lib$libsuff
2355
2356      LDFLAGS="$LDFLAGS $addld"
2357      if test "$addcflags" != "-I/usr/include"; then
2358         CPPFLAGS="$CPPFLAGS $addcflags"
2359      fi
2360
2361      AC_CHECK_LIB(cyassl, CyaSSL_Init,
2362       [
2363       AC_DEFINE(USE_CYASSL, 1, [if CyaSSL is enabled])
2364       AC_SUBST(USE_CYASSL, [1])
2365       CYASSL_ENABLED=1
2366       USE_CYASSL="yes"
2367       ssl_msg="CyaSSL"
2368       test cyassl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2369       ],
2370       [
2371         CPPFLAGS=$_cppflags
2372         LDFLAGS=$_ldflags
2373         cyassllib=""
2374       ])
2375    fi
2376
2377    addld=""
2378    addlib=""
2379    addcflags=""
2380
2381    if test "x$USE_CYASSL" != "xyes"; then
2382      dnl libcyassl renamed to libwolfssl as of 3.4.0
2383      addld=-L$OPT_CYASSL/lib$libsuff
2384      addcflags=-I$OPT_CYASSL/include
2385      cyassllib=$OPT_CYASSL/lib$libsuff
2386
2387      LDFLAGS="$LDFLAGS $addld"
2388      if test "$addcflags" != "-I/usr/include"; then
2389         CPPFLAGS="$CPPFLAGS $addcflags"
2390      fi
2391
2392      cyassllibname=wolfssl
2393      my_ac_save_LIBS="$LIBS"
2394      LIBS="-l$cyassllibname -lm $LIBS"
2395
2396      AC_MSG_CHECKING([for CyaSSL_Init in -lwolfssl])
2397      AC_LINK_IFELSE([
2398	AC_LANG_PROGRAM([[
2399/* These aren't needed for detection and confuse WolfSSL.
2400   They are set up properly later if it is detected.  */
2401#undef SIZEOF_LONG
2402#undef SIZEOF_LONG_LONG
2403#include <cyassl/ssl.h>
2404	]],[[
2405	  return CyaSSL_Init();
2406	]])
2407      ],[
2408         AC_MSG_RESULT(yes)
2409         AC_DEFINE(USE_CYASSL, 1, [if CyaSSL/WolfSSL is enabled])
2410         AC_SUBST(USE_CYASSL, [1])
2411         CYASSL_ENABLED=1
2412         USE_CYASSL="yes"
2413         ssl_msg="WolfSSL"
2414	 test cyassl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2415       ],
2416       [
2417         AC_MSG_RESULT(no)
2418         CPPFLAGS=$_cppflags
2419         LDFLAGS=$_ldflags
2420         cyassllib=""
2421       ])
2422      LIBS="$my_ac_save_LIBS"
2423    fi
2424
2425    if test "x$USE_CYASSL" = "xyes"; then
2426      AC_MSG_NOTICE([detected $cyassllibname])
2427      check_for_ca_bundle=1
2428
2429      dnl cyassl/ctaocrypt/types.h needs SIZEOF_LONG_LONG defined!
2430      AX_COMPILE_CHECK_SIZEOF(long long)
2431
2432      dnl Versions since at least 2.6.0 may have options.h
2433      AC_CHECK_HEADERS(cyassl/options.h)
2434
2435      dnl Versions since at least 2.9.4 renamed error.h to error-ssl.h
2436      AC_CHECK_HEADERS(cyassl/error-ssl.h)
2437
2438      LIBS="-l$cyassllibname -lm $LIBS"
2439
2440      if test "x$cyassllibname" = "xwolfssl"; then
2441        dnl Recent WolfSSL versions build without SSLv3 by default
2442        dnl WolfSSL needs configure --enable-opensslextra to have *get_peer*
2443        AC_CHECK_FUNCS(wolfSSLv3_client_method \
2444                       wolfSSL_get_peer_certificate \
2445                       wolfSSL_UseALPN)
2446      else
2447        dnl Cyassl needs configure --enable-opensslextra to have *get_peer*
2448        AC_CHECK_FUNCS(CyaSSL_CTX_UseSupportedCurve \
2449                       CyaSSL_get_peer_certificate)
2450      fi
2451
2452      if test -n "$cyassllib"; then
2453        dnl when shared libs were found in a path that the run-time
2454        dnl linker doesn't search through, we need to add it to
2455        dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
2456        dnl due to this
2457        if test "x$cross_compiling" != "xyes"; then
2458          CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$cyassllib"
2459          export CURL_LIBRARY_PATH
2460          AC_MSG_NOTICE([Added $cyassllib to CURL_LIBRARY_PATH])
2461        fi
2462      fi
2463
2464    fi
2465
2466  fi dnl CyaSSL not disabled
2467
2468  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
2469fi
2470
2471dnl ----------------------------------------------------
2472dnl check for MesaLink
2473dnl ----------------------------------------------------
2474
2475dnl Default to compiler & linker defaults for MesaLink files & libraries.
2476OPT_MESALINK=no
2477
2478_cppflags=$CPPFLAGS
2479_ldflags=$LDFLAGS
2480AC_ARG_WITH(mesalink,dnl
2481AC_HELP_STRING([--with-mesalink=PATH],[where to look for MesaLink, PATH points to the installation root])
2482AC_HELP_STRING([--without-mesalink], [disable MesaLink detection]),
2483  OPT_MESALINK=$withval)
2484
2485if test -z "$ssl_backends" -o "x$OPT_MESALINK" != xno; then
2486  ssl_msg=
2487
2488  if test X"$OPT_MESALINK" != Xno; then
2489
2490    if test "$OPT_MESALINK" = "yes"; then
2491      OPT_MESALINK=""
2492    fi
2493
2494    if test -z "$OPT_MESALINK" ; then
2495      dnl check for lib first without setting any new path
2496
2497      AC_CHECK_LIB(mesalink, mesalink_library_init,
2498      dnl libmesalink found, set the variable
2499       [
2500         AC_DEFINE(USE_MESALINK, 1, [if MesaLink is enabled])
2501         AC_SUBST(USE_MESALINK, [1])
2502         MESALINK_ENABLED=1
2503         USE_MESALINK="yes"
2504         ssl_msg="MesaLink"
2505	 test mesalink != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2506        ])
2507    fi
2508
2509    addld=""
2510    addlib=""
2511    addcflags=""
2512    mesalinklib=""
2513
2514    if test "x$USE_MESALINK" != "xyes"; then
2515      dnl add the path and test again
2516      addld=-L$OPT_MESALINK/lib$libsuff
2517      addcflags=-I$OPT_MESALINK/include
2518      mesalinklib=$OPT_MESALINK/lib$libsuff
2519
2520      LDFLAGS="$LDFLAGS $addld"
2521      if test "$addcflags" != "-I/usr/include"; then
2522         CPPFLAGS="$CPPFLAGS $addcflags"
2523      fi
2524
2525      AC_CHECK_LIB(mesalink, mesalink_library_init,
2526       [
2527       AC_DEFINE(USE_MESALINK, 1, [if MesaLink is enabled])
2528       AC_SUBST(USE_MESALINK, [1])
2529       MESALINK_ENABLED=1
2530       USE_MESALINK="yes"
2531       ssl_msg="MesaLink"
2532       test mesalink != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2533       ],
2534       [
2535         CPPFLAGS=$_cppflags
2536         LDFLAGS=$_ldflags
2537       ])
2538    fi
2539
2540    if test "x$USE_MESALINK" = "xyes"; then
2541      AC_MSG_NOTICE([detected MesaLink])
2542
2543      LIBS="-lmesalink $LIBS"
2544
2545      if test -n "$mesalinklib"; then
2546        dnl when shared libs were found in a path that the run-time
2547        dnl linker doesn't search through, we need to add it to
2548        dnl LD_LIBRARY_PATH to prevent further configure tests to fail
2549        dnl due to this
2550        if test "x$cross_compiling" != "xyes"; then
2551          LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$mesalinklib"
2552          export LD_LIBRARY_PATH
2553          AC_MSG_NOTICE([Added $mesalinklib to LD_LIBRARY_PATH])
2554        fi
2555      fi
2556    fi
2557
2558  fi dnl MesaLink not disabled
2559
2560  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
2561fi
2562
2563dnl ----------------------------------------------------
2564dnl NSS. Only check if GnuTLS and OpenSSL are not enabled
2565dnl ----------------------------------------------------
2566
2567dnl Default to compiler & linker defaults for NSS files & libraries.
2568OPT_NSS=no
2569
2570AC_ARG_WITH(nss,dnl
2571AC_HELP_STRING([--with-nss=PATH],[where to look for NSS, PATH points to the installation root])
2572AC_HELP_STRING([--without-nss], [disable NSS detection]),
2573  OPT_NSS=$withval)
2574
2575if test -z "$ssl_backends" -o "x$OPT_NSS" != xno; then
2576  ssl_msg=
2577
2578  if test X"$OPT_NSS" != Xno; then
2579
2580    addld=""
2581    addlib=""
2582    addcflags=""
2583    nssprefix=""
2584    version=""
2585
2586    if test "x$OPT_NSS" = "xyes"; then
2587
2588      CURL_CHECK_PKGCONFIG(nss)
2589
2590      if test "$PKGCONFIG" != "no" ; then
2591        addlib=`$PKGCONFIG --libs nss`
2592        addcflags=`$PKGCONFIG --cflags nss`
2593        version=`$PKGCONFIG --modversion nss`
2594        nssprefix=`$PKGCONFIG --variable=prefix nss`
2595      else
2596        dnl Without pkg-config, we check for nss-config
2597
2598        check=`nss-config --version 2>/dev/null`
2599        if test -n "$check"; then
2600          addlib=`nss-config --libs`
2601          addcflags=`nss-config --cflags`
2602          version=`nss-config --version`
2603          nssprefix=`nss-config --prefix`
2604        else
2605          addlib="-lnss3"
2606          addcflags=""
2607          version="unknown"
2608        fi
2609      fi
2610    else
2611      NSS_PCDIR="$OPT_NSS/lib/pkgconfig"
2612      if test -f "$NSS_PCDIR/nss.pc"; then
2613        CURL_CHECK_PKGCONFIG(nss, [$NSS_PCDIR])
2614        if test "$PKGCONFIG" != "no" ; then
2615          addld=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --libs-only-L nss`
2616          addlib=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --libs-only-l nss`
2617          addcflags=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --cflags nss`
2618          version=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --modversion nss`
2619          nssprefix=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --variable=prefix nss`
2620        fi
2621      fi
2622    fi
2623
2624    if test -z "$addlib"; then
2625      # Without pkg-config, we'll kludge in some defaults
2626      AC_MSG_WARN([Using hard-wired libraries and compilation flags for NSS.])
2627      addld="-L$OPT_NSS/lib"
2628      addlib="-lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4"
2629      addcflags="-I$OPT_NSS/include"
2630      version="unknown"
2631      nssprefix=$OPT_NSS
2632    fi
2633
2634    CLEANLDFLAGS="$LDFLAGS"
2635    CLEANLIBS="$LIBS"
2636    CLEANCPPFLAGS="$CPPFLAGS"
2637
2638    LDFLAGS="$addld $LDFLAGS"
2639    LIBS="$addlib $LIBS"
2640    if test "$addcflags" != "-I/usr/include"; then
2641       CPPFLAGS="$CPPFLAGS $addcflags"
2642    fi
2643
2644    dnl The function SSL_VersionRangeSet() is needed to enable TLS > 1.0
2645    AC_CHECK_LIB(nss3, SSL_VersionRangeSet,
2646     [
2647     AC_DEFINE(USE_NSS, 1, [if NSS is enabled])
2648     AC_SUBST(USE_NSS, [1])
2649     USE_NSS="yes"
2650     NSS_ENABLED=1
2651     ssl_msg="NSS"
2652     test nss != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2653     ],
2654     [
2655       LDFLAGS="$CLEANLDFLAGS"
2656       LIBS="$CLEANLIBS"
2657       CPPFLAGS="$CLEANCPPFLAGS"
2658     ])
2659
2660    if test "x$USE_NSS" = "xyes"; then
2661      AC_MSG_NOTICE([detected NSS version $version])
2662
2663      dnl PK11_CreateManagedGenericObject() was introduced in NSS 3.34 because
2664      dnl PK11_DestroyGenericObject() does not release resources allocated by
2665      dnl PK11_CreateGenericObject() early enough.
2666      AC_CHECK_FUNC(PK11_CreateManagedGenericObject,
2667        [
2668          AC_DEFINE(HAVE_PK11_CREATEMANAGEDGENERICOBJECT, 1,
2669                    [if you have the PK11_CreateManagedGenericObject function])
2670        ])
2671
2672      dnl needed when linking the curl tool without USE_EXPLICIT_LIB_DEPS
2673      NSS_LIBS=$addlib
2674      AC_SUBST([NSS_LIBS])
2675
2676      dnl when shared libs were found in a path that the run-time
2677      dnl linker doesn't search through, we need to add it to
2678      dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
2679      dnl due to this
2680      if test "x$cross_compiling" != "xyes"; then
2681        CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$nssprefix/lib$libsuff"
2682        export CURL_LIBRARY_PATH
2683        AC_MSG_NOTICE([Added $nssprefix/lib$libsuff to CURL_LIBRARY_PATH])
2684      fi
2685
2686    fi dnl NSS found
2687
2688  fi dnl NSS not disabled
2689
2690  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
2691fi
2692
2693case "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$POLARSSL_ENABLED$MBEDTLS_ENABLED$CYASSL_ENABLED$WINSSL_ENABLED$SECURETRANSPORT_ENABLED$MESALINK_ENABLED$AMISSL_ENABLED" in
2694x)
2695  AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
2696  AC_MSG_WARN([Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss, --with-schannel, --with-secure-transport, --with-mesalink or --with-amissl to address this.])
2697  ;;
2698x1)
2699  # one SSL backend is enabled
2700  AC_SUBST(SSL_ENABLED)
2701  SSL_ENABLED="1"
2702  AC_MSG_NOTICE([built with one SSL backend])
2703  ;;
2704*)
2705  # more than one SSL backend is enabled
2706  AC_SUBST(SSL_ENABLED)
2707  SSL_ENABLED="1"
2708  AC_SUBST(CURL_WITH_MULTI_SSL)
2709  CURL_WITH_MULTI_SSL="1"
2710  AC_DEFINE(CURL_WITH_MULTI_SSL, 1, [built with multiple SSL backends])
2711  AC_MSG_NOTICE([built with multiple SSL backends])
2712  ;;
2713esac
2714
2715if test -n "$ssl_backends"; then
2716  curl_ssl_msg="enabled ($ssl_backends)"
2717fi
2718
2719if test no = "$VALID_DEFAULT_SSL_BACKEND"
2720then
2721  if test -n "$SSL_ENABLED"
2722  then
2723    AC_MSG_ERROR([Default SSL backend $DEFAULT_SSL_BACKEND not enabled!])
2724  else
2725    AC_MSG_ERROR([Default SSL backend requires SSL!])
2726  fi
2727elif test yes = "$VALID_DEFAULT_SSL_BACKEND"
2728then
2729  AC_DEFINE_UNQUOTED([CURL_DEFAULT_SSL_BACKEND], ["$DEFAULT_SSL_BACKEND"], [Default SSL backend])
2730fi
2731
2732dnl **********************************************************************
2733dnl Check for the CA bundle
2734dnl **********************************************************************
2735
2736if test "$check_for_ca_bundle" -gt 0; then
2737  CURL_CHECK_CA_BUNDLE
2738fi
2739
2740dnl **********************************************************************
2741dnl Check for libpsl
2742dnl **********************************************************************
2743
2744AC_ARG_WITH(libpsl,
2745           AS_HELP_STRING([--without-libpsl],
2746           [disable support for libpsl cookie checking]),
2747           with_libpsl=$withval,
2748           with_libpsl=yes)
2749if test $with_libpsl != "no"; then
2750  AC_SEARCH_LIBS(psl_builtin, psl,
2751    [curl_psl_msg="enabled";
2752     AC_DEFINE([USE_LIBPSL], [1], [PSL support enabled])
2753     ],
2754    [curl_psl_msg="no      (libpsl not found)";
2755     AC_MSG_WARN([libpsl was not found])
2756     ]
2757  )
2758fi
2759AM_CONDITIONAL([USE_LIBPSL], [test "$curl_psl_msg" = "enabled"])
2760
2761dnl **********************************************************************
2762dnl Check for libmetalink
2763dnl **********************************************************************
2764
2765OPT_LIBMETALINK=no
2766
2767AC_ARG_WITH(libmetalink,dnl
2768AC_HELP_STRING([--with-libmetalink=PATH],[where to look for libmetalink, PATH points to the installation root])
2769AC_HELP_STRING([--without-libmetalink], [disable libmetalink detection]),
2770  OPT_LIBMETALINK=$withval)
2771
2772if test X"$OPT_LIBMETALINK" != Xno; then
2773
2774  addld=""
2775  addlib=""
2776  addcflags=""
2777  version=""
2778  libmetalinklib=""
2779
2780  PKGTEST="no"
2781  if test "x$OPT_LIBMETALINK" = "xyes"; then
2782    dnl this is with no partiular path given
2783    PKGTEST="yes"
2784    CURL_CHECK_PKGCONFIG(libmetalink)
2785  else
2786    dnl When particular path is given, set PKG_CONFIG_LIBDIR using the path.
2787    LIBMETALINK_PCDIR="$OPT_LIBMETALINK/lib/pkgconfig"
2788    AC_MSG_NOTICE([PKG_CONFIG_LIBDIR will be set to "$LIBMETALINK_PCDIR"])
2789    if test -f "$LIBMETALINK_PCDIR/libmetalink.pc"; then
2790      PKGTEST="yes"
2791    fi
2792    if test "$PKGTEST" = "yes"; then
2793      CURL_CHECK_PKGCONFIG(libmetalink, [$LIBMETALINK_PCDIR])
2794    fi
2795  fi
2796  if test "$PKGTEST" = "yes" && test "$PKGCONFIG" != "no"; then
2797    addlib=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2798      $PKGCONFIG --libs-only-l libmetalink`
2799    addld=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2800      $PKGCONFIG --libs-only-L libmetalink`
2801    addcflags=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2802      $PKGCONFIG --cflags-only-I libmetalink`
2803    version=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2804      $PKGCONFIG --modversion libmetalink`
2805    libmetalinklib=`echo $addld | $SED -e 's/-L//'`
2806  fi
2807  if test -n "$addlib"; then
2808
2809    clean_CPPFLAGS="$CPPFLAGS"
2810    clean_LDFLAGS="$LDFLAGS"
2811    clean_LIBS="$LIBS"
2812    CPPFLAGS="$clean_CPPFLAGS $addcflags"
2813    LDFLAGS="$clean_LDFLAGS $addld"
2814    LIBS="$addlib $clean_LIBS"
2815    AC_MSG_CHECKING([if libmetalink is recent enough])
2816    AC_LINK_IFELSE([
2817      AC_LANG_PROGRAM([[
2818#       include <metalink/metalink.h>
2819      ]],[[
2820        if(0 != metalink_strerror(0)) /* added in 0.1.0 */
2821          return 1;
2822      ]])
2823    ],[
2824      AC_MSG_RESULT([yes ($version)])
2825      want_metalink="yes"
2826    ],[
2827      AC_MSG_RESULT([no ($version)])
2828      AC_MSG_NOTICE([libmetalink library defective or too old])
2829      want_metalink="no"
2830    ])
2831    CPPFLAGS="$clean_CPPFLAGS"
2832    LDFLAGS="$clean_LDFLAGS"
2833    LIBS="$clean_LIBS"
2834    if test "$want_metalink" = "yes"; then
2835      dnl finally libmetalink will be used
2836      AC_DEFINE(USE_METALINK, 1, [Define to enable metalink support])
2837      LIBMETALINK_LIBS=$addlib
2838      LIBMETALINK_LDFLAGS=$addld
2839      LIBMETALINK_CPPFLAGS=$addcflags
2840      AC_SUBST([LIBMETALINK_LIBS])
2841      AC_SUBST([LIBMETALINK_LDFLAGS])
2842      AC_SUBST([LIBMETALINK_CPPFLAGS])
2843      curl_mtlnk_msg="enabled"
2844    fi
2845
2846  fi
2847fi
2848
2849dnl **********************************************************************
2850dnl Check for the presence of LIBSSH2 libraries and headers
2851dnl **********************************************************************
2852
2853dnl Default to compiler & linker defaults for LIBSSH2 files & libraries.
2854OPT_LIBSSH2=off
2855AC_ARG_WITH(libssh2,dnl
2856AC_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])
2857AC_HELP_STRING([--with-libssh2], [enable LIBSSH2]),
2858  OPT_LIBSSH2=$withval, OPT_LIBSSH2=no)
2859
2860
2861OPT_LIBSSH=off
2862AC_ARG_WITH(libssh,dnl
2863AC_HELP_STRING([--with-libssh=PATH],[Where to look for libssh, PATH points to the LIBSSH installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
2864AC_HELP_STRING([--with-libssh], [enable LIBSSH]),
2865  OPT_LIBSSH=$withval, OPT_LIBSSH=no)
2866
2867if test X"$OPT_LIBSSH2" != Xno; then
2868  dnl backup the pre-libssh2 variables
2869  CLEANLDFLAGS="$LDFLAGS"
2870  CLEANCPPFLAGS="$CPPFLAGS"
2871  CLEANLIBS="$LIBS"
2872
2873  case "$OPT_LIBSSH2" in
2874  yes)
2875    dnl --with-libssh2 (without path) used
2876    CURL_CHECK_PKGCONFIG(libssh2)
2877
2878    if test "$PKGCONFIG" != "no" ; then
2879      LIB_SSH2=`$PKGCONFIG --libs libssh2`
2880      LD_SSH2=`$PKGCONFIG --libs-only-L libssh2`
2881      CPP_SSH2=`$PKGCONFIG --cflags-only-I libssh2`
2882      version=`$PKGCONFIG --modversion libssh2`
2883      DIR_SSH2=`echo $LD_SSH2 | $SED -e 's/-L//'`
2884    fi
2885
2886    ;;
2887  off)
2888    dnl no --with-libssh2 option given, just check default places
2889    ;;
2890  *)
2891    dnl use the given --with-libssh2 spot
2892    PREFIX_SSH2=$OPT_LIBSSH2
2893    ;;
2894  esac
2895
2896  dnl if given with a prefix, we set -L and -I based on that
2897  if test -n "$PREFIX_SSH2"; then
2898    LIB_SSH2="-lssh2"
2899    LD_SSH2=-L${PREFIX_SSH2}/lib$libsuff
2900    CPP_SSH2=-I${PREFIX_SSH2}/include
2901    DIR_SSH2=${PREFIX_SSH2}/lib$libsuff
2902  fi
2903
2904  LDFLAGS="$LDFLAGS $LD_SSH2"
2905  CPPFLAGS="$CPPFLAGS $CPP_SSH2"
2906  LIBS="$LIB_SSH2 $LIBS"
2907
2908  AC_CHECK_LIB(ssh2, libssh2_channel_open_ex)
2909
2910  AC_CHECK_HEADERS(libssh2.h,
2911    curl_ssh_msg="enabled (libSSH2)"
2912    LIBSSH2_ENABLED=1
2913    AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use])
2914    AC_SUBST(USE_LIBSSH2, [1])
2915  )
2916
2917  if test X"$OPT_LIBSSH2" != Xoff &&
2918     test "$LIBSSH2_ENABLED" != "1"; then
2919    AC_MSG_ERROR([libSSH2 libs and/or directories were not found where specified!])
2920  fi
2921
2922  if test "$LIBSSH2_ENABLED" = "1"; then
2923    if test -n "$DIR_SSH2"; then
2924       dnl when the libssh2 shared libs were found in a path that the run-time
2925       dnl linker doesn't search through, we need to add it to CURL_LIBRARY_PATH
2926       dnl to prevent further configure tests to fail due to this
2927
2928       if test "x$cross_compiling" != "xyes"; then
2929         CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_SSH2"
2930         export CURL_LIBRARY_PATH
2931         AC_MSG_NOTICE([Added $DIR_SSH2 to CURL_LIBRARY_PATH])
2932       fi
2933    fi
2934  else
2935    dnl no libssh2, revert back to clean variables
2936    LDFLAGS=$CLEANLDFLAGS
2937    CPPFLAGS=$CLEANCPPFLAGS
2938    LIBS=$CLEANLIBS
2939  fi
2940elif test X"$OPT_LIBSSH" != Xno; then
2941  dnl backup the pre-libssh variables
2942  CLEANLDFLAGS="$LDFLAGS"
2943  CLEANCPPFLAGS="$CPPFLAGS"
2944  CLEANLIBS="$LIBS"
2945
2946  case "$OPT_LIBSSH" in
2947  yes)
2948    dnl --with-libssh (without path) used
2949    CURL_CHECK_PKGCONFIG(libssh)
2950
2951    if test "$PKGCONFIG" != "no" ; then
2952      LIB_SSH=`$PKGCONFIG --libs-only-l libssh`
2953      LD_SSH=`$PKGCONFIG --libs-only-L libssh`
2954      CPP_SSH=`$PKGCONFIG --cflags-only-I libssh`
2955      version=`$PKGCONFIG --modversion libssh`
2956      DIR_SSH=`echo $LD_SSH | $SED -e 's/-L//'`
2957    fi
2958
2959    ;;
2960  off)
2961    dnl no --with-libssh option given, just check default places
2962    ;;
2963  *)
2964    dnl use the given --with-libssh spot
2965    PREFIX_SSH=$OPT_LIBSSH
2966    ;;
2967  esac
2968
2969  dnl if given with a prefix, we set -L and -I based on that
2970  if test -n "$PREFIX_SSH"; then
2971    LIB_SSH="-lssh"
2972    LD_SSH=-L${PREFIX_SSH}/lib$libsuff
2973    CPP_SSH=-I${PREFIX_SSH}/include
2974    DIR_SSH=${PREFIX_SSH}/lib$libsuff
2975  fi
2976
2977  LDFLAGS="$LDFLAGS $LD_SSH"
2978  CPPFLAGS="$CPPFLAGS $CPP_SSH"
2979  LIBS="$LIB_SSH $LIBS"
2980
2981  AC_CHECK_LIB(ssh, ssh_new)
2982
2983  AC_CHECK_HEADERS(libssh/libssh.h,
2984    curl_ssh_msg="enabled (libSSH)"
2985    LIBSSH_ENABLED=1
2986    AC_DEFINE(USE_LIBSSH, 1, [if libSSH is in use])
2987    AC_SUBST(USE_LIBSSH, [1])
2988  )
2989
2990  if test X"$OPT_LIBSSH" != Xoff &&
2991     test "$LIBSSH_ENABLED" != "1"; then
2992    AC_MSG_ERROR([libSSH libs and/or directories were not found where specified!])
2993  fi
2994
2995  if test "$LIBSSH_ENABLED" = "1"; then
2996    if test -n "$DIR_SSH"; then
2997       dnl when the libssh shared libs were found in a path that the run-time
2998       dnl linker doesn't search through, we need to add it to CURL_LIBRARY_PATH
2999       dnl to prevent further configure tests to fail due to this
3000
3001       if test "x$cross_compiling" != "xyes"; then
3002         CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_SSH"
3003         export CURL_LIBRARY_PATH
3004         AC_MSG_NOTICE([Added $DIR_SSH to CURL_LIBRARY_PATH])
3005       fi
3006    fi
3007  else
3008    dnl no libssh, revert back to clean variables
3009    LDFLAGS=$CLEANLDFLAGS
3010    CPPFLAGS=$CLEANCPPFLAGS
3011    LIBS=$CLEANLIBS
3012  fi
3013fi
3014
3015dnl **********************************************************************
3016dnl Check for the presence of LIBRTMP libraries and headers
3017dnl **********************************************************************
3018
3019dnl Default to compiler & linker defaults for LIBRTMP files & libraries.
3020OPT_LIBRTMP=off
3021AC_ARG_WITH(librtmp,dnl
3022AC_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])
3023AC_HELP_STRING([--without-librtmp], [disable LIBRTMP]),
3024  OPT_LIBRTMP=$withval)
3025
3026if test X"$OPT_LIBRTMP" != Xno; then
3027  dnl backup the pre-librtmp variables
3028  CLEANLDFLAGS="$LDFLAGS"
3029  CLEANCPPFLAGS="$CPPFLAGS"
3030  CLEANLIBS="$LIBS"
3031
3032  case "$OPT_LIBRTMP" in
3033  yes)
3034    dnl --with-librtmp (without path) used
3035    CURL_CHECK_PKGCONFIG(librtmp)
3036
3037    if test "$PKGCONFIG" != "no" ; then
3038      LIB_RTMP=`$PKGCONFIG --libs-only-l librtmp`
3039      LD_RTMP=`$PKGCONFIG --libs-only-L librtmp`
3040      CPP_RTMP=`$PKGCONFIG --cflags-only-I librtmp`
3041      version=`$PKGCONFIG --modversion librtmp`
3042      DIR_RTMP=`echo $LD_RTMP | $SED -e 's/-L//'`
3043    else
3044      dnl To avoid link errors, we do not allow --librtmp without
3045      dnl a pkgconfig file
3046      AC_MSG_ERROR([--librtmp was specified but could not find librtmp pkgconfig file.])
3047    fi
3048
3049    ;;
3050  off)
3051    dnl no --with-librtmp option given, just check default places
3052    LIB_RTMP="-lrtmp"
3053    ;;
3054  *)
3055    dnl use the given --with-librtmp spot
3056    LIB_RTMP="-lrtmp"
3057    PREFIX_RTMP=$OPT_LIBRTMP
3058    ;;
3059  esac
3060
3061  dnl if given with a prefix, we set -L and -I based on that
3062  if test -n "$PREFIX_RTMP"; then
3063    LD_RTMP=-L${PREFIX_RTMP}/lib$libsuff
3064    CPP_RTMP=-I${PREFIX_RTMP}/include
3065    DIR_RTMP=${PREFIX_RTMP}/lib$libsuff
3066  fi
3067
3068  LDFLAGS="$LDFLAGS $LD_RTMP"
3069  CPPFLAGS="$CPPFLAGS $CPP_RTMP"
3070  LIBS="$LIB_RTMP $LIBS"
3071
3072  AC_CHECK_LIB(rtmp, RTMP_Init,
3073    [
3074     AC_CHECK_HEADERS(librtmp/rtmp.h,
3075        curl_rtmp_msg="enabled (librtmp)"
3076        LIBRTMP_ENABLED=1
3077        AC_DEFINE(USE_LIBRTMP, 1, [if librtmp is in use])
3078        AC_SUBST(USE_LIBRTMP, [1])
3079     )
3080    ],
3081      dnl not found, revert back to clean variables
3082      LDFLAGS=$CLEANLDFLAGS
3083      CPPFLAGS=$CLEANCPPFLAGS
3084      LIBS=$CLEANLIBS
3085  )
3086
3087  if test X"$OPT_LIBRTMP" != Xoff &&
3088     test "$LIBRTMP_ENABLED" != "1"; then
3089    AC_MSG_ERROR([librtmp libs and/or directories were not found where specified!])
3090  fi
3091
3092fi
3093
3094dnl **********************************************************************
3095dnl Check for linker switch for versioned symbols
3096dnl **********************************************************************
3097
3098versioned_symbols_flavour=
3099AC_MSG_CHECKING([whether versioned symbols are wanted])
3100AC_ARG_ENABLE(versioned-symbols,
3101AC_HELP_STRING([--enable-versioned-symbols], [Enable versioned symbols in shared library])
3102AC_HELP_STRING([--disable-versioned-symbols], [Disable versioned symbols in shared library]),
3103[ case "$enableval" in
3104  yes) AC_MSG_RESULT(yes)
3105    AC_MSG_CHECKING([if libraries can be versioned])
3106    GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
3107    if test -z "$GLD"; then
3108        AC_MSG_RESULT(no)
3109        AC_MSG_WARN([You need an ld version supporting the --version-script option])
3110    else
3111        AC_MSG_RESULT(yes)
3112        if test "x$CURL_WITH_MULTI_SSL" = "x1"; then
3113          versioned_symbols_flavour="MULTISSL_"
3114        elif test "x$OPENSSL_ENABLED" = "x1"; then
3115          versioned_symbols_flavour="OPENSSL_"
3116        elif test "x$GNUTLS_ENABLED" = "x1"; then
3117          versioned_symbols_flavour="GNUTLS_"
3118        elif test "x$NSS_ENABLED" = "x1"; then
3119          versioned_symbols_flavour="NSS_"
3120        elif test "x$POLARSSL_ENABLED" = "x1"; then
3121          versioned_symbols_flavour="POLARSSL_"
3122        elif test "x$CYASSL_ENABLED" = "x1"; then
3123          versioned_symbols_flavour="CYASSL_"
3124        elif test "x$WINSSL_ENABLED" = "x1"; then
3125          versioned_symbols_flavour="SCHANNEL_"
3126        elif test "x$SECURETRANSPORT_ENABLED" = "x1"; then
3127          versioned_symbols_flavour="SECURE_TRANSPORT_"
3128        else
3129          versioned_symbols_flavour=""
3130        fi
3131        versioned_symbols="yes"
3132    fi
3133    ;;
3134
3135  *)   AC_MSG_RESULT(no)
3136    ;;
3137  esac
3138], [
3139AC_MSG_RESULT(no)
3140]
3141)
3142
3143AC_SUBST([CURL_LT_SHLIB_VERSIONED_FLAVOUR],
3144  ["$versioned_symbols_flavour"])
3145AM_CONDITIONAL([CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS],
3146  [test "x$versioned_symbols" = 'xyes'])
3147
3148dnl -------------------------------------------------
3149dnl check winidn option before other IDN libraries
3150dnl -------------------------------------------------
3151
3152AC_MSG_CHECKING([whether to enable Windows native IDN (Windows native builds only)])
3153OPT_WINIDN="default"
3154AC_ARG_WITH(winidn,
3155AC_HELP_STRING([--with-winidn=PATH],[enable Windows native IDN])
3156AC_HELP_STRING([--without-winidn], [disable Windows native IDN]),
3157  OPT_WINIDN=$withval)
3158case "$OPT_WINIDN" in
3159  no|default)
3160    dnl --without-winidn option used or configure option not specified
3161    want_winidn="no"
3162    AC_MSG_RESULT([no])
3163    ;;
3164  yes)
3165    dnl --with-winidn option used without path
3166    want_winidn="yes"
3167    want_winidn_path="default"
3168    AC_MSG_RESULT([yes])
3169    ;;
3170  *)
3171    dnl --with-winidn option used with path
3172    want_winidn="yes"
3173    want_winidn_path="$withval"
3174    AC_MSG_RESULT([yes ($withval)])
3175    ;;
3176esac
3177
3178if test "$want_winidn" = "yes"; then
3179  dnl winidn library support has been requested
3180  clean_CPPFLAGS="$CPPFLAGS"
3181  clean_LDFLAGS="$LDFLAGS"
3182  clean_LIBS="$LIBS"
3183  WINIDN_LIBS="-lnormaliz"
3184  WINIDN_CPPFLAGS="-DWINVER=0x0600"
3185  #
3186  if test "$want_winidn_path" != "default"; then
3187    dnl path has been specified
3188    dnl pkg-config not available or provides no info
3189    WINIDN_LDFLAGS="-L$want_winidn_path/lib$libsuff"
3190    WINIDN_CPPFLAGS="-I$want_winidn_path/include"
3191    WINIDN_DIR="$want_winidn_path/lib$libsuff"
3192  fi
3193  #
3194  CPPFLAGS="$CPPFLAGS $WINIDN_CPPFLAGS"
3195  LDFLAGS="$LDFLAGS $WINIDN_LDFLAGS"
3196  LIBS="$WINIDN_LIBS $LIBS"
3197  #
3198  AC_MSG_CHECKING([if IdnToUnicode can be linked])
3199  AC_LINK_IFELSE([
3200    AC_LANG_PROGRAM([[
3201      #include <windows.h>
3202    ]],[[
3203      IdnToUnicode(0, NULL, 0, NULL, 0);
3204    ]])
3205  ],[
3206    AC_MSG_RESULT([yes])
3207    tst_links_winidn="yes"
3208  ],[
3209    AC_MSG_RESULT([no])
3210    tst_links_winidn="no"
3211  ])
3212  #
3213  if test "$tst_links_winidn" = "yes"; then
3214    AC_DEFINE(USE_WIN32_IDN, 1, [Define to 1 if you have the `normaliz' (WinIDN) library (-lnormaliz).])
3215    AC_DEFINE(WANT_IDN_PROTOTYPES, 1, [Define to 1 to provide own prototypes.])
3216    AC_SUBST([IDN_ENABLED], [1])
3217    curl_idn_msg="enabled (Windows-native)"
3218  else
3219    AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
3220    CPPFLAGS="$clean_CPPFLAGS"
3221    LDFLAGS="$clean_LDFLAGS"
3222    LIBS="$clean_LIBS"
3223  fi
3224fi
3225
3226dnl **********************************************************************
3227dnl Check for the presence of IDN libraries and headers
3228dnl **********************************************************************
3229
3230AC_MSG_CHECKING([whether to build with libidn2])
3231OPT_IDN="default"
3232AC_ARG_WITH(libidn2,
3233AC_HELP_STRING([--with-libidn2=PATH],[Enable libidn2 usage])
3234AC_HELP_STRING([--without-libidn2],[Disable libidn2 usage]),
3235  [OPT_IDN=$withval])
3236case "$OPT_IDN" in
3237  no)
3238    dnl --without-libidn2 option used
3239    want_idn="no"
3240    AC_MSG_RESULT([no])
3241    ;;
3242  default)
3243    dnl configure option not specified
3244    want_idn="yes"
3245    want_idn_path="default"
3246    AC_MSG_RESULT([(assumed) yes])
3247    ;;
3248  yes)
3249    dnl --with-libidn2 option used without path
3250    want_idn="yes"
3251    want_idn_path="default"
3252    AC_MSG_RESULT([yes])
3253    ;;
3254  *)
3255    dnl --with-libidn2 option used with path
3256    want_idn="yes"
3257    want_idn_path="$withval"
3258    AC_MSG_RESULT([yes ($withval)])
3259    ;;
3260esac
3261
3262if test "$want_idn" = "yes"; then
3263  dnl idn library support has been requested
3264  clean_CPPFLAGS="$CPPFLAGS"
3265  clean_LDFLAGS="$LDFLAGS"
3266  clean_LIBS="$LIBS"
3267  PKGCONFIG="no"
3268  #
3269  if test "$want_idn_path" != "default"; then
3270    dnl path has been specified
3271    IDN_PCDIR="$want_idn_path/lib$libsuff/pkgconfig"
3272    CURL_CHECK_PKGCONFIG(libidn2, [$IDN_PCDIR])
3273    if test "$PKGCONFIG" != "no"; then
3274      IDN_LIBS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
3275        $PKGCONFIG --libs-only-l libidn2 2>/dev/null`
3276      IDN_LDFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
3277        $PKGCONFIG --libs-only-L libidn2 2>/dev/null`
3278      IDN_CPPFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
3279        $PKGCONFIG --cflags-only-I libidn2 2>/dev/null`
3280      IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
3281    else
3282      dnl pkg-config not available or provides no info
3283      IDN_LIBS="-lidn2"
3284      IDN_LDFLAGS="-L$want_idn_path/lib$libsuff"
3285      IDN_CPPFLAGS="-I$want_idn_path/include"
3286      IDN_DIR="$want_idn_path/lib$libsuff"
3287    fi
3288  else
3289    dnl path not specified
3290    CURL_CHECK_PKGCONFIG(libidn2)
3291    if test "$PKGCONFIG" != "no"; then
3292      IDN_LIBS=`$PKGCONFIG --libs-only-l libidn2 2>/dev/null`
3293      IDN_LDFLAGS=`$PKGCONFIG --libs-only-L libidn2 2>/dev/null`
3294      IDN_CPPFLAGS=`$PKGCONFIG --cflags-only-I libidn2 2>/dev/null`
3295      IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
3296    else
3297      dnl pkg-config not available or provides no info
3298      IDN_LIBS="-lidn2"
3299    fi
3300  fi
3301  #
3302  if test "$PKGCONFIG" != "no"; then
3303    AC_MSG_NOTICE([pkg-config: IDN_LIBS: "$IDN_LIBS"])
3304    AC_MSG_NOTICE([pkg-config: IDN_LDFLAGS: "$IDN_LDFLAGS"])
3305    AC_MSG_NOTICE([pkg-config: IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
3306    AC_MSG_NOTICE([pkg-config: IDN_DIR: "$IDN_DIR"])
3307  else
3308    AC_MSG_NOTICE([IDN_LIBS: "$IDN_LIBS"])
3309    AC_MSG_NOTICE([IDN_LDFLAGS: "$IDN_LDFLAGS"])
3310    AC_MSG_NOTICE([IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
3311    AC_MSG_NOTICE([IDN_DIR: "$IDN_DIR"])
3312  fi
3313  #
3314  CPPFLAGS="$CPPFLAGS $IDN_CPPFLAGS"
3315  LDFLAGS="$LDFLAGS $IDN_LDFLAGS"
3316  LIBS="$IDN_LIBS $LIBS"
3317  #
3318  AC_MSG_CHECKING([if idn2_lookup_ul can be linked])
3319  AC_LINK_IFELSE([
3320    AC_LANG_FUNC_LINK_TRY([idn2_lookup_ul])
3321  ],[
3322    AC_MSG_RESULT([yes])
3323    tst_links_libidn="yes"
3324  ],[
3325    AC_MSG_RESULT([no])
3326    tst_links_libidn="no"
3327  ])
3328  #
3329  AC_CHECK_HEADERS( idn2.h )
3330
3331  if test "$tst_links_libidn" = "yes"; then
3332    AC_DEFINE(HAVE_LIBIDN2, 1, [Define to 1 if you have the `idn2' library (-lidn2).])
3333    dnl different versions of libidn have different setups of these:
3334
3335    AC_SUBST([IDN_ENABLED], [1])
3336    curl_idn_msg="enabled (libidn2)"
3337    if test -n "$IDN_DIR" -a "x$cross_compiling" != "xyes"; then
3338      CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$IDN_DIR"
3339      export CURL_LIBRARY_PATH
3340      AC_MSG_NOTICE([Added $IDN_DIR to CURL_LIBRARY_PATH])
3341    fi
3342  else
3343    AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
3344    CPPFLAGS="$clean_CPPFLAGS"
3345    LDFLAGS="$clean_LDFLAGS"
3346    LIBS="$clean_LIBS"
3347  fi
3348fi
3349
3350
3351dnl Let's hope this split URL remains working:
3352dnl https://www15.software.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
3353dnl genprogc/thread_quick_ref.htm
3354
3355
3356dnl **********************************************************************
3357dnl Check for nghttp2
3358dnl **********************************************************************
3359
3360OPT_H2="yes"
3361
3362if test "x$disable_http" = "xyes"; then
3363  # without HTTP, nghttp2 is no use
3364  OPT_H2="no"
3365fi
3366
3367AC_ARG_WITH(nghttp2,
3368AC_HELP_STRING([--with-nghttp2=PATH],[Enable nghttp2 usage])
3369AC_HELP_STRING([--without-nghttp2],[Disable nghttp2 usage]),
3370  [OPT_H2=$withval])
3371case "$OPT_H2" in
3372  no)
3373    dnl --without-nghttp2 option used
3374    want_h2="no"
3375    ;;
3376  yes)
3377    dnl --with-nghttp2 option used without path
3378    want_h2="default"
3379    want_h2_path=""
3380    ;;
3381  *)
3382    dnl --with-nghttp2 option used with path
3383    want_h2="yes"
3384    want_h2_path="$withval/lib/pkgconfig"
3385    ;;
3386esac
3387
3388curl_h2_msg="disabled (--with-nghttp2)"
3389if test X"$want_h2" != Xno; then
3390  dnl backup the pre-nghttp2 variables
3391  CLEANLDFLAGS="$LDFLAGS"
3392  CLEANCPPFLAGS="$CPPFLAGS"
3393  CLEANLIBS="$LIBS"
3394
3395  CURL_CHECK_PKGCONFIG(libnghttp2, $want_h2_path)
3396
3397  if test "$PKGCONFIG" != "no" ; then
3398    LIB_H2=`CURL_EXPORT_PCDIR([$want_h2_path])
3399      $PKGCONFIG --libs-only-l libnghttp2`
3400    AC_MSG_NOTICE([-l is $LIB_H2])
3401
3402    CPP_H2=`CURL_EXPORT_PCDIR([$want_h2_path]) dnl
3403      $PKGCONFIG --cflags-only-I libnghttp2`
3404    AC_MSG_NOTICE([-I is $CPP_H2])
3405
3406    LD_H2=`CURL_EXPORT_PCDIR([$want_h2_path])
3407      $PKGCONFIG --libs-only-L libnghttp2`
3408    AC_MSG_NOTICE([-L is $LD_H2])
3409
3410    LDFLAGS="$LDFLAGS $LD_H2"
3411    CPPFLAGS="$CPPFLAGS $CPP_H2"
3412    LIBS="$LIB_H2 $LIBS"
3413
3414    # use nghttp2_option_set_no_recv_client_magic to require nghttp2
3415    # >= 1.0.0
3416    AC_CHECK_LIB(nghttp2, nghttp2_option_set_no_recv_client_magic,
3417      [
3418       AC_CHECK_HEADERS(nghttp2/nghttp2.h,
3419          curl_h2_msg="enabled (nghttp2)"
3420          NGHTTP2_ENABLED=1
3421          AC_DEFINE(USE_NGHTTP2, 1, [if nghttp2 is in use])
3422          AC_SUBST(USE_NGHTTP2, [1])
3423       )
3424      ],
3425        dnl not found, revert back to clean variables
3426        LDFLAGS=$CLEANLDFLAGS
3427        CPPFLAGS=$CLEANCPPFLAGS
3428        LIBS=$CLEANLIBS
3429    )
3430
3431  else
3432    dnl no nghttp2 pkg-config found, deal with it
3433    if test X"$want_h2" != Xdefault; then
3434      dnl To avoid link errors, we do not allow --with-nghttp2 without
3435      dnl a pkgconfig file
3436      AC_MSG_ERROR([--with-nghttp2 was specified but could not find libnghttp2 pkg-config file.])
3437    fi
3438  fi
3439
3440fi
3441
3442dnl **********************************************************************
3443dnl Check for zsh completion path
3444dnl **********************************************************************
3445
3446OPT_ZSH_FPATH=default
3447AC_ARG_WITH(zsh-functions-dir,
3448AC_HELP_STRING([--with-zsh-functions-dir=PATH],[Install zsh completions to PATH])
3449AC_HELP_STRING([--without-zsh-functions-dir],[Do not install zsh completions]),
3450  [OPT_ZSH_FPATH=$withval])
3451case "$OPT_ZSH_FPATH" in
3452  no)
3453    dnl --without-zsh-functions-dir option used
3454    ;;
3455  default|yes)
3456    dnl --with-zsh-functions-dir option used without path
3457    ZSH_FUNCTIONS_DIR="$datarootdir/zsh/site-functions"
3458    AC_SUBST(ZSH_FUNCTIONS_DIR)
3459    ;;
3460  *)
3461    dnl --with-zsh-functions-dir option used with path
3462    ZSH_FUNCTIONS_DIR="$withval"
3463    AC_SUBST(ZSH_FUNCTIONS_DIR)
3464    ;;
3465esac
3466
3467dnl **********************************************************************
3468dnl Check for fish completion path
3469dnl **********************************************************************
3470
3471OPT_FISH_FPATH=default
3472AC_ARG_WITH(fish-functions-dir,
3473AC_HELP_STRING([--with-fish-functions-dir=PATH],[Install fish completions to PATH])
3474AC_HELP_STRING([--without-fish-functions-dir],[Do not install fish completions]),
3475  [OPT_FISH_FPATH=$withval])
3476case "$OPT_FISH_FPATH" in
3477  no)
3478    dnl --without-fish-functions-dir option used
3479    ;;
3480  default|yes)
3481    dnl --with-fish-functions-dir option used without path
3482    FISH_FUNCTIONS_DIR="$datarootdir/fish/completions"
3483    AC_SUBST(FISH_FUNCTIONS_DIR)
3484    ;;
3485  *)
3486    dnl --with-fish-functions-dir option used with path
3487    FISH_FUNCTIONS_DIR="$withval"
3488    AC_SUBST(FISH_FUNCTIONS_DIR)
3489    ;;
3490esac
3491
3492dnl **********************************************************************
3493dnl Back to "normal" configuring
3494dnl **********************************************************************
3495
3496dnl Checks for header files.
3497AC_HEADER_STDC
3498
3499CURL_CHECK_HEADER_MALLOC
3500CURL_CHECK_HEADER_MEMORY
3501
3502dnl Now check for the very most basic headers. Then we can use these
3503dnl ones as default-headers when checking for the rest!
3504AC_CHECK_HEADERS(
3505        sys/types.h \
3506        sys/time.h \
3507        sys/select.h \
3508        sys/socket.h \
3509        sys/ioctl.h \
3510        sys/uio.h \
3511        assert.h \
3512        unistd.h \
3513        stdlib.h \
3514        arpa/inet.h \
3515        net/if.h \
3516        netinet/in.h \
3517	netinet/in6.h \
3518        sys/un.h \
3519        linux/tcp.h \
3520        netinet/tcp.h \
3521        netdb.h \
3522        sys/sockio.h \
3523        sys/stat.h \
3524        sys/param.h \
3525        termios.h \
3526        termio.h \
3527        sgtty.h \
3528        fcntl.h \
3529        alloca.h \
3530        time.h \
3531        io.h \
3532        pwd.h \
3533        utime.h \
3534        sys/utime.h \
3535        sys/poll.h \
3536        poll.h \
3537        socket.h \
3538        sys/resource.h \
3539        libgen.h \
3540        locale.h \
3541        errno.h \
3542        stdbool.h \
3543        arpa/tftp.h \
3544        sys/filio.h \
3545        sys/wait.h \
3546        setjmp.h,
3547dnl to do if not found
3548[],
3549dnl to do if found
3550[],
3551dnl default includes
3552[
3553#ifdef HAVE_SYS_TYPES_H
3554#include <sys/types.h>
3555#endif
3556#ifdef HAVE_SYS_TIME_H
3557#include <sys/time.h>
3558#endif
3559#ifdef HAVE_SYS_SELECT_H
3560#include <sys/select.h>
3561#endif
3562#ifdef HAVE_SYS_SOCKET_H
3563#include <sys/socket.h>
3564#endif
3565#ifdef HAVE_NETINET_IN_H
3566#include <netinet/in.h>
3567#endif
3568#ifdef HAVE_NETINET_IN6_H
3569#include <netinet/in6.h>
3570#endif
3571#ifdef HAVE_SYS_UN_H
3572#include <sys/un.h>
3573#endif
3574]
3575)
3576
3577
3578dnl Checks for typedefs, structures, and compiler characteristics.
3579AC_C_CONST
3580CURL_CHECK_VARIADIC_MACROS
3581AC_TYPE_SIZE_T
3582AC_HEADER_TIME
3583CURL_CHECK_STRUCT_TIMEVAL
3584CURL_VERIFY_RUNTIMELIBS
3585
3586AX_COMPILE_CHECK_SIZEOF(size_t)
3587AX_COMPILE_CHECK_SIZEOF(long)
3588AX_COMPILE_CHECK_SIZEOF(int)
3589AX_COMPILE_CHECK_SIZEOF(short)
3590AX_COMPILE_CHECK_SIZEOF(time_t)
3591AX_COMPILE_CHECK_SIZEOF(off_t)
3592
3593o=$CPPFLAGS
3594CPPFLAGS="-I$srcdir/include $CPPFLAGS"
3595AX_COMPILE_CHECK_SIZEOF(curl_off_t, [
3596#include <curl/system.h>
3597])
3598CPPFLAGS=$o
3599
3600AC_CHECK_TYPE(long long,
3601   [AC_DEFINE(HAVE_LONGLONG, 1,
3602      [Define to 1 if the compiler supports the 'long long' data type.])]
3603   longlong="yes"
3604)
3605
3606if test "xyes" = "x$longlong"; then
3607  AC_MSG_CHECKING([if numberLL works])
3608  AC_COMPILE_IFELSE([
3609    AC_LANG_PROGRAM([[
3610    ]],[[
3611      long long val = 1000LL;
3612    ]])
3613  ],[
3614    AC_MSG_RESULT([yes])
3615    AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
3616  ],[
3617    AC_MSG_RESULT([no])
3618  ])
3619fi
3620
3621
3622# check for ssize_t
3623AC_CHECK_TYPE(ssize_t, ,
3624   AC_DEFINE(ssize_t, int, [the signed version of size_t]))
3625
3626# check for bool type
3627AC_CHECK_TYPE([bool],[
3628  AC_DEFINE(HAVE_BOOL_T, 1,
3629    [Define to 1 if bool is an available type.])
3630], ,[
3631#ifdef HAVE_SYS_TYPES_H
3632#include <sys/types.h>
3633#endif
3634#ifdef HAVE_STDBOOL_H
3635#include <stdbool.h>
3636#endif
3637])
3638
3639# check for sa_family_t
3640AC_CHECK_TYPE(sa_family_t,
3641   AC_DEFINE(CURL_SA_FAMILY_T, sa_family_t, [IP address type in sockaddr]),
3642   [
3643   # The windows name?
3644   AC_CHECK_TYPE(ADDRESS_FAMILY,
3645     AC_DEFINE(CURL_SA_FAMILY_T, ADDRESS_FAMILY, [IP address type in sockaddr]),
3646     AC_DEFINE(CURL_SA_FAMILY_T, unsigned short, [IP address type in sockaddr]),
3647    [
3648#ifdef HAVE_SYS_SOCKET_H
3649#include <sys/socket.h>
3650#endif
3651    ])
3652   ],
3653[
3654#ifdef HAVE_SYS_SOCKET_H
3655#include <sys/socket.h>
3656#endif
3657])
3658
3659AC_MSG_CHECKING([if time_t is unsigned])
3660CURL_RUN_IFELSE(
3661  [
3662  #include <time.h>
3663  #include <limits.h>
3664  time_t t = -1;
3665  return (t > 0);
3666  ],[
3667  AC_MSG_RESULT([yes])
3668  AC_DEFINE(HAVE_TIME_T_UNSIGNED, 1, [Define this if time_t is unsigned])
3669],[
3670  AC_MSG_RESULT([no])
3671],[
3672  dnl cross-compiling, most systems are unsigned
3673  AC_MSG_RESULT([no])
3674])
3675
3676CURL_CONFIGURE_PULL_SYS_POLL
3677
3678TYPE_IN_ADDR_T
3679
3680TYPE_SOCKADDR_STORAGE
3681
3682TYPE_SIG_ATOMIC_T
3683
3684AC_TYPE_SIGNAL
3685
3686CURL_CHECK_FUNC_SELECT
3687
3688CURL_CHECK_FUNC_RECV
3689CURL_CHECK_FUNC_SEND
3690CURL_CHECK_MSG_NOSIGNAL
3691
3692CURL_CHECK_FUNC_ALARM
3693CURL_CHECK_FUNC_BASENAME
3694CURL_CHECK_FUNC_CLOSESOCKET
3695CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
3696CURL_CHECK_FUNC_CONNECT
3697CURL_CHECK_FUNC_FCNTL
3698CURL_CHECK_FUNC_FREEADDRINFO
3699CURL_CHECK_FUNC_FREEIFADDRS
3700CURL_CHECK_FUNC_FSETXATTR
3701CURL_CHECK_FUNC_FTRUNCATE
3702CURL_CHECK_FUNC_GETADDRINFO
3703CURL_CHECK_FUNC_GAI_STRERROR
3704CURL_CHECK_FUNC_GETHOSTBYADDR
3705CURL_CHECK_FUNC_GETHOSTBYADDR_R
3706CURL_CHECK_FUNC_GETHOSTBYNAME
3707CURL_CHECK_FUNC_GETHOSTBYNAME_R
3708CURL_CHECK_FUNC_GETHOSTNAME
3709CURL_CHECK_FUNC_GETIFADDRS
3710CURL_CHECK_FUNC_GETSERVBYPORT_R
3711CURL_CHECK_FUNC_GMTIME_R
3712CURL_CHECK_FUNC_INET_NTOA_R
3713CURL_CHECK_FUNC_INET_NTOP
3714CURL_CHECK_FUNC_INET_PTON
3715CURL_CHECK_FUNC_IOCTL
3716CURL_CHECK_FUNC_IOCTLSOCKET
3717CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
3718CURL_CHECK_FUNC_LOCALTIME_R
3719CURL_CHECK_FUNC_MEMRCHR
3720CURL_CHECK_FUNC_POLL
3721CURL_CHECK_FUNC_SETSOCKOPT
3722CURL_CHECK_FUNC_SIGACTION
3723CURL_CHECK_FUNC_SIGINTERRUPT
3724CURL_CHECK_FUNC_SIGNAL
3725CURL_CHECK_FUNC_SIGSETJMP
3726CURL_CHECK_FUNC_SOCKET
3727CURL_CHECK_FUNC_SOCKETPAIR
3728CURL_CHECK_FUNC_STRCASECMP
3729CURL_CHECK_FUNC_STRCMPI
3730CURL_CHECK_FUNC_STRDUP
3731CURL_CHECK_FUNC_STRERROR_R
3732CURL_CHECK_FUNC_STRICMP
3733CURL_CHECK_FUNC_STRNCASECMP
3734CURL_CHECK_FUNC_STRNCMPI
3735CURL_CHECK_FUNC_STRNICMP
3736CURL_CHECK_FUNC_STRSTR
3737CURL_CHECK_FUNC_STRTOK_R
3738CURL_CHECK_FUNC_STRTOLL
3739CURL_CHECK_FUNC_WRITEV
3740
3741case $host in
3742  *msdosdjgpp)
3743     ac_cv_func_pipe=no
3744     skipcheck_pipe=yes
3745     AC_MSG_NOTICE([skip check for pipe on msdosdjgpp])
3746    ;;
3747esac
3748
3749AC_CHECK_DECLS([getpwuid_r], [], [AC_DEFINE(HAVE_DECL_GETPWUID_R_MISSING, 1, "Set if getpwuid_r() declaration is missing")],
3750        [[#include <pwd.h>
3751          #include <sys/types.h>]])
3752
3753
3754AC_CHECK_FUNCS([fnmatch \
3755  geteuid \
3756  getpass_r \
3757  getppid \
3758  getpwuid \
3759  getpwuid_r \
3760  getrlimit \
3761  gettimeofday \
3762  if_nametoindex \
3763  mach_absolute_time \
3764  pipe \
3765  setlocale \
3766  setmode \
3767  setrlimit \
3768  utime \
3769  utimes
3770],[
3771],[
3772  func="$ac_func"
3773  eval skipcheck=\$skipcheck_$func
3774  if test "x$skipcheck" != "xyes"; then
3775    AC_MSG_CHECKING([deeper for $func])
3776    AC_LINK_IFELSE([
3777      AC_LANG_PROGRAM([[
3778      ]],[[
3779        $func ();
3780      ]])
3781    ],[
3782      AC_MSG_RESULT([yes])
3783      eval "ac_cv_func_$func=yes"
3784      AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
3785        [Define to 1 if you have the $func function.])
3786    ],[
3787      AC_MSG_RESULT([but still no])
3788    ])
3789  fi
3790])
3791
3792if test "$ipv6" = "yes"; then
3793  if test "$curl_cv_func_getaddrinfo" = "yes"; then
3794    AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
3795    IPV6_ENABLED=1
3796    AC_SUBST(IPV6_ENABLED)
3797  fi
3798fi
3799
3800CURL_CHECK_NONBLOCKING_SOCKET
3801
3802dnl ************************************************************
3803dnl nroff tool stuff
3804dnl
3805
3806AC_PATH_PROG( PERL, perl, ,
3807  $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
3808AC_SUBST(PERL)
3809
3810AC_PATH_PROGS( NROFF, gnroff nroff, ,
3811  $PATH:/usr/bin/:/usr/local/bin )
3812AC_SUBST(NROFF)
3813
3814if test -n "$NROFF"; then
3815  dnl only check for nroff options if an nroff command was found
3816
3817  AC_MSG_CHECKING([how to use *nroff to get plain text from man pages])
3818  MANOPT="-man"
3819  mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
3820  if test -z "$mancheck"; then
3821    MANOPT="-mandoc"
3822   mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
3823    if test -z "$mancheck"; then
3824      MANOPT=""
3825      AC_MSG_RESULT([failed])
3826      AC_MSG_WARN([found no *nroff option to get plaintext from man pages])
3827    else
3828      AC_MSG_RESULT([$MANOPT])
3829    fi
3830  else
3831    AC_MSG_RESULT([$MANOPT])
3832  fi
3833  AC_SUBST(MANOPT)
3834fi
3835
3836if test -z "$MANOPT"
3837then
3838  dnl if no nroff tool was found, or no option that could convert man pages
3839  dnl was found, then disable the built-in manual stuff
3840  AC_MSG_WARN([disabling built-in manual])
3841  USE_MANUAL="no";
3842fi
3843
3844dnl *************************************************************************
3845dnl If the manual variable still is set, then we go with providing a built-in
3846dnl manual
3847
3848if test "$USE_MANUAL" = "1"; then
3849  AC_DEFINE(USE_MANUAL, 1, [If you want to build curl with the built-in manual])
3850  curl_manual_msg="enabled"
3851fi
3852
3853dnl set variable for use in automakefile(s)
3854AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1)
3855
3856CURL_CHECK_LIB_ARES
3857AM_CONDITIONAL(USE_EMBEDDED_ARES, test x$embedded_ares = xyes)
3858
3859if test "x$curl_cv_native_windows" != "xyes" &&
3860   test "x$enable_shared" = "xyes"; then
3861  build_libhostname=yes
3862else
3863  build_libhostname=no
3864fi
3865AM_CONDITIONAL(BUILD_LIBHOSTNAME, test x$build_libhostname = xyes)
3866
3867if test "x$want_ares" != xyes; then
3868  CURL_CHECK_OPTION_THREADED_RESOLVER
3869fi
3870
3871dnl ************************************************************
3872dnl disable POSIX threads
3873dnl
3874AC_MSG_CHECKING([whether to use POSIX threads for threaded resolver])
3875AC_ARG_ENABLE(pthreads,
3876AC_HELP_STRING([--enable-pthreads],
3877               [Enable POSIX threads (default for threaded resolver)])
3878AC_HELP_STRING([--disable-pthreads],[Disable POSIX threads]),
3879[ case "$enableval" in
3880  no)  AC_MSG_RESULT(no)
3881       want_pthreads=no
3882       ;;
3883  *)   AC_MSG_RESULT(yes)
3884       want_pthreads=yes
3885       ;;
3886  esac ], [
3887       AC_MSG_RESULT(auto)
3888       want_pthreads=auto
3889       ]
3890)
3891
3892dnl turn off pthreads if rt is disabled
3893if test "$want_pthreads" != "no"; then
3894  if test "$want_pthreads" = "yes" && test "$dontwant_rt" = "yes"; then
3895    AC_MSG_ERROR([options --enable-pthreads and --disable-rt are mutually exclusive])
3896  fi
3897  if test "$dontwant_rt" != "no"; then
3898    dnl if --enable-pthreads was explicit then warn it's being ignored
3899    if test "$want_pthreads" = "yes"; then
3900      AC_MSG_WARN([--enable-pthreads Ignored since librt is disabled.])
3901    fi
3902    want_pthreads=no
3903  fi
3904fi
3905
3906dnl turn off pthreads if no threaded resolver
3907if test "$want_pthreads" != "no" && test "$want_thres" != "yes"; then
3908  want_pthreads=no
3909fi
3910
3911dnl detect pthreads
3912if test "$want_pthreads" != "no"; then
3913  AC_CHECK_HEADER(pthread.h,
3914    [ AC_DEFINE(HAVE_PTHREAD_H, 1, [if you have <pthread.h>])
3915      save_CFLAGS="$CFLAGS"
3916
3917      dnl first check for function without lib
3918      AC_CHECK_FUNC(pthread_create, [USE_THREADS_POSIX=1] )
3919
3920      dnl on HPUX, life is more complicated...
3921      case $host in
3922      *-hp-hpux*)
3923         dnl it doesn't actually work without -lpthread
3924         USE_THREADS_POSIX=""
3925         ;;
3926      *)
3927         ;;
3928      esac
3929
3930      dnl if it wasn't found without lib, search for it in pthread lib
3931      if test "$USE_THREADS_POSIX" != "1"
3932      then
3933        CFLAGS="$CFLAGS -pthread"
3934        AC_CHECK_LIB(pthread, pthread_create,
3935                     [USE_THREADS_POSIX=1],
3936                     [ CFLAGS="$save_CFLAGS"])
3937      fi
3938
3939      if test "x$USE_THREADS_POSIX" = "x1"
3940      then
3941        AC_DEFINE(USE_THREADS_POSIX, 1, [if you want POSIX threaded DNS lookup])
3942        curl_res_msg="POSIX threaded"
3943      fi
3944  ])
3945fi
3946
3947dnl threaded resolver check
3948if test "$want_thres" = "yes" && test "x$USE_THREADS_POSIX" != "x1"; then
3949  if test "$want_pthreads" = "yes"; then
3950    AC_MSG_ERROR([--enable-pthreads but pthreads was not found])
3951  fi
3952  dnl If native Windows fallback on Win32 threads since no POSIX threads
3953  if test "$curl_cv_native_windows" = "yes"; then
3954    USE_THREADS_WIN32=1
3955    AC_DEFINE(USE_THREADS_WIN32, 1, [if you want Win32 threaded DNS lookup])
3956    curl_res_msg="Win32 threaded"
3957  else
3958    AC_MSG_ERROR([Threaded resolver enabled but no thread library found])
3959  fi
3960fi
3961
3962dnl ************************************************************
3963dnl disable verbose text strings
3964dnl
3965AC_MSG_CHECKING([whether to enable verbose strings])
3966AC_ARG_ENABLE(verbose,
3967AC_HELP_STRING([--enable-verbose],[Enable verbose strings])
3968AC_HELP_STRING([--disable-verbose],[Disable verbose strings]),
3969[ case "$enableval" in
3970  no)
3971       AC_MSG_RESULT(no)
3972       AC_DEFINE(CURL_DISABLE_VERBOSE_STRINGS, 1, [to disable verbose strings])
3973       curl_verbose_msg="no"
3974       ;;
3975  *)   AC_MSG_RESULT(yes)
3976       ;;
3977  esac ],
3978       AC_MSG_RESULT(yes)
3979)
3980
3981dnl ************************************************************
3982dnl enable SSPI support
3983dnl
3984AC_MSG_CHECKING([whether to enable SSPI support (Windows native builds only)])
3985AC_ARG_ENABLE(sspi,
3986AC_HELP_STRING([--enable-sspi],[Enable SSPI])
3987AC_HELP_STRING([--disable-sspi],[Disable SSPI]),
3988[ case "$enableval" in
3989  yes)
3990       if test "$curl_cv_native_windows" = "yes"; then
3991         AC_MSG_RESULT(yes)
3992         AC_DEFINE(USE_WINDOWS_SSPI, 1, [to enable SSPI support])
3993         AC_SUBST(USE_WINDOWS_SSPI, [1])
3994         curl_sspi_msg="enabled"
3995       else
3996         AC_MSG_RESULT(no)
3997         AC_MSG_WARN([--enable-sspi Ignored. Only supported on native Windows builds.])
3998       fi
3999       ;;
4000  *)
4001       if test "x$WINSSL_ENABLED" = "x1"; then
4002         # --with-winssl implies --enable-sspi
4003         AC_MSG_RESULT(yes)
4004       else
4005         AC_MSG_RESULT(no)
4006       fi
4007       ;;
4008  esac ],
4009       if test "x$WINSSL_ENABLED" = "x1"; then
4010         # --with-winssl implies --enable-sspi
4011         AC_MSG_RESULT(yes)
4012       else
4013         AC_MSG_RESULT(no)
4014       fi
4015)
4016
4017dnl ************************************************************
4018dnl disable cryptographic authentication
4019dnl
4020AC_MSG_CHECKING([whether to enable cryptographic authentication methods])
4021AC_ARG_ENABLE(crypto-auth,
4022AC_HELP_STRING([--enable-crypto-auth],[Enable cryptographic authentication])
4023AC_HELP_STRING([--disable-crypto-auth],[Disable cryptographic authentication]),
4024[ case "$enableval" in
4025  no)
4026       AC_MSG_RESULT(no)
4027       AC_DEFINE(CURL_DISABLE_CRYPTO_AUTH, 1, [to disable cryptographic authentication])
4028       CURL_DISABLE_CRYPTO_AUTH=1
4029       ;;
4030  *)   AC_MSG_RESULT(yes)
4031       ;;
4032  esac ],
4033       AC_MSG_RESULT(yes)
4034)
4035
4036CURL_CHECK_OPTION_NTLM_WB
4037
4038CURL_CHECK_NTLM_WB
4039
4040dnl ************************************************************
4041dnl disable TLS-SRP authentication
4042dnl
4043AC_MSG_CHECKING([whether to enable TLS-SRP authentication])
4044AC_ARG_ENABLE(tls-srp,
4045AC_HELP_STRING([--enable-tls-srp],[Enable TLS-SRP authentication])
4046AC_HELP_STRING([--disable-tls-srp],[Disable TLS-SRP authentication]),
4047[ case "$enableval" in
4048  no)
4049       AC_MSG_RESULT(no)
4050       AC_DEFINE(CURL_DISABLE_TLS_SRP, 1, [to disable TLS-SRP authentication])
4051       want_tls_srp=no
4052       ;;
4053  *)   AC_MSG_RESULT(yes)
4054       want_tls_srp=yes
4055       ;;
4056  esac ],
4057       AC_MSG_RESULT(yes)
4058       want_tls_srp=yes
4059)
4060
4061if test "$want_tls_srp" = "yes" && ( test "x$HAVE_GNUTLS_SRP" = "x1" || test "x$HAVE_OPENSSL_SRP" = "x1") ; then
4062   AC_DEFINE(USE_TLS_SRP, 1, [Use TLS-SRP authentication])
4063   USE_TLS_SRP=1
4064   curl_tls_srp_msg="enabled"
4065fi
4066
4067dnl ************************************************************
4068dnl disable Unix domain sockets support
4069dnl
4070AC_MSG_CHECKING([whether to enable Unix domain sockets])
4071AC_ARG_ENABLE(unix-sockets,
4072AC_HELP_STRING([--enable-unix-sockets],[Enable Unix domain sockets])
4073AC_HELP_STRING([--disable-unix-sockets],[Disable Unix domain sockets]),
4074[ case "$enableval" in
4075  no)  AC_MSG_RESULT(no)
4076       want_unix_sockets=no
4077       ;;
4078  *)   AC_MSG_RESULT(yes)
4079       want_unix_sockets=yes
4080       ;;
4081  esac ], [
4082       AC_MSG_RESULT(auto)
4083       want_unix_sockets=auto
4084       ]
4085)
4086if test "x$want_unix_sockets" != "xno"; then
4087  AC_CHECK_MEMBER([struct sockaddr_un.sun_path], [
4088    AC_DEFINE(USE_UNIX_SOCKETS, 1, [Use Unix domain sockets])
4089    AC_SUBST(USE_UNIX_SOCKETS, [1])
4090    curl_unix_sockets_msg="enabled"
4091  ], [
4092    if test "x$want_unix_sockets" = "xyes"; then
4093      AC_MSG_ERROR([--enable-unix-sockets is not available on this platform!])
4094    fi
4095  ], [
4096    #include <sys/un.h>
4097  ])
4098fi
4099
4100dnl ************************************************************
4101dnl disable cookies support
4102dnl
4103AC_MSG_CHECKING([whether to enable support for cookies])
4104AC_ARG_ENABLE(cookies,
4105AC_HELP_STRING([--enable-cookies],[Enable cookies support])
4106AC_HELP_STRING([--disable-cookies],[Disable cookies support]),
4107[ case "$enableval" in
4108  no)
4109       AC_MSG_RESULT(no)
4110       AC_DEFINE(CURL_DISABLE_COOKIES, 1, [to disable cookies support])
4111       ;;
4112  *)   AC_MSG_RESULT(yes)
4113       ;;
4114  esac ],
4115       AC_MSG_RESULT(yes)
4116)
4117
4118dnl ************************************************************
4119dnl switch on/off alt-svc
4120dnl
4121curl_altsvc_msg="no      (--enable-alt-svc)";
4122AC_MSG_CHECKING([whether to support alt-svc])
4123AC_ARG_ENABLE(alt-svc,
4124AC_HELP_STRING([--enable-alt-svc],[Enable alt-svc support])
4125AC_HELP_STRING([--disable-alt-svc],[Disable alt-svc support]),
4126[ case "$enableval" in
4127  no)
4128       AC_MSG_RESULT(no)
4129       ;;
4130  *) AC_MSG_RESULT(yes)
4131       curl_altsvc_msg="enabled";
4132       enable_altsvc="yes"
4133       experimental="alt-svc"
4134       ;;
4135  esac ],
4136       AC_MSG_RESULT(no)
4137)
4138
4139if test "$enable_altsvc" = "yes"; then
4140  AC_DEFINE(USE_ALTSVC, 1, [to enable alt-svc])
4141  experimental="alt-svc"
4142fi
4143
4144dnl ************************************************************
4145dnl hiding of library internal symbols
4146dnl
4147CURL_CONFIGURE_SYMBOL_HIDING
4148
4149dnl
4150dnl All the library dependencies put into $LIB apply to libcurl only.
4151dnl
4152LIBCURL_LIBS=$LIBS
4153
4154AC_SUBST(LIBCURL_LIBS)
4155AC_SUBST(CURL_NETWORK_LIBS)
4156AC_SUBST(CURL_NETWORK_AND_TIME_LIBS)
4157
4158dnl BLANK_AT_MAKETIME may be used in our Makefile.am files to blank
4159dnl LIBS variable used in generated makefile at makefile processing
4160dnl time. Doing this functionally prevents LIBS from being used for
4161dnl all link targets in given makefile.
4162BLANK_AT_MAKETIME=
4163AC_SUBST(BLANK_AT_MAKETIME)
4164
4165AM_CONDITIONAL(CROSSCOMPILING, test x$cross_compiling = xyes)
4166
4167dnl yes or no
4168ENABLE_SHARED="$enable_shared"
4169AC_SUBST(ENABLE_SHARED)
4170
4171dnl to let curl-config output the static libraries correctly
4172ENABLE_STATIC="$enable_static"
4173AC_SUBST(ENABLE_STATIC)
4174
4175
4176dnl
4177dnl For keeping supported features and protocols also in pkg-config file
4178dnl since it is more cross-compile friendly than curl-config
4179dnl
4180
4181if test "x$OPENSSL_ENABLED" = "x1"; then
4182  SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
4183elif test -n "$SSL_ENABLED"; then
4184  SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
4185fi
4186if test "x$IPV6_ENABLED" = "x1"; then
4187  SUPPORT_FEATURES="$SUPPORT_FEATURES IPv6"
4188fi
4189if test "x$USE_UNIX_SOCKETS" = "x1"; then
4190  SUPPORT_FEATURES="$SUPPORT_FEATURES UnixSockets"
4191fi
4192if test "x$HAVE_LIBZ" = "x1"; then
4193  SUPPORT_FEATURES="$SUPPORT_FEATURES libz"
4194fi
4195if test "x$HAVE_BROTLI" = "x1"; then
4196  SUPPORT_FEATURES="$SUPPORT_FEATURES brotli"
4197fi
4198if test "x$USE_ARES" = "x1" -o "x$USE_THREADS_POSIX" = "x1" \
4199                            -o "x$USE_THREADS_WIN32" = "x1"; then
4200  SUPPORT_FEATURES="$SUPPORT_FEATURES AsynchDNS"
4201fi
4202if test "x$IDN_ENABLED" = "x1"; then
4203  SUPPORT_FEATURES="$SUPPORT_FEATURES IDN"
4204fi
4205if test "x$USE_WINDOWS_SSPI" = "x1"; then
4206  SUPPORT_FEATURES="$SUPPORT_FEATURES SSPI"
4207fi
4208
4209if test "x$HAVE_GSSAPI" = "x1"; then
4210  SUPPORT_FEATURES="$SUPPORT_FEATURES GSS-API"
4211fi
4212
4213if test "x$curl_psl_msg" = "xenabled"; then
4214  SUPPORT_FEATURES="$SUPPORT_FEATURES PSL"
4215fi
4216
4217if test "x$enable_altsvc" = "xyes"; then
4218  SUPPORT_FEATURES="$SUPPORT_FEATURES alt-svc"
4219fi
4220
4221if test "x$CURL_DISABLE_CRYPTO_AUTH" != "x1" -a \
4222    \( "x$HAVE_GSSAPI" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \); then
4223  SUPPORT_FEATURES="$SUPPORT_FEATURES SPNEGO"
4224fi
4225
4226if test "x$CURL_DISABLE_CRYPTO_AUTH" != "x1" -a \
4227    \( "x$HAVE_GSSAPI" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \); then
4228  SUPPORT_FEATURES="$SUPPORT_FEATURES Kerberos"
4229fi
4230
4231if test "x$CURL_DISABLE_CRYPTO_AUTH" != "x1"; then
4232  if test "x$OPENSSL_ENABLED" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \
4233      -o "x$GNUTLS_ENABLED" = "x1" -o "x$MBEDTLS_ENABLED" = "x1" \
4234      -o "x$NSS_ENABLED" = "x1" -o "x$SECURETRANSPORT_ENABLED" = "x1"; then
4235    SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM"
4236
4237    if test "x$CURL_DISABLE_HTTP" != "x1" -a \
4238        "x$NTLM_WB_ENABLED" = "x1"; then
4239      SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM_WB"
4240    fi
4241  fi
4242fi
4243
4244if test "x$USE_TLS_SRP" = "x1"; then
4245  SUPPORT_FEATURES="$SUPPORT_FEATURES TLS-SRP"
4246fi
4247
4248if test "x$USE_NGHTTP2" = "x1"; then
4249  SUPPORT_FEATURES="$SUPPORT_FEATURES HTTP2"
4250fi
4251
4252if test "x$CURL_WITH_MULTI_SSL" = "x1"; then
4253  SUPPORT_FEATURES="$SUPPORT_FEATURES MultiSSL"
4254fi
4255
4256if test "x$OPENSSL_ENABLED" = "x1" -o "x$GNUTLS_ENABLED" = "x1" \
4257    -o "x$NSS_ENABLED" = "x1"; then
4258  SUPPORT_FEATURES="$SUPPORT_FEATURES HTTPS-proxy"
4259fi
4260
4261AC_SUBST(SUPPORT_FEATURES)
4262
4263dnl For supported protocols in pkg-config file
4264if test "x$CURL_DISABLE_HTTP" != "x1"; then
4265  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTP"
4266  if test "x$SSL_ENABLED" = "x1"; then
4267    SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTPS"
4268  fi
4269fi
4270if test "x$CURL_DISABLE_FTP" != "x1"; then
4271  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTP"
4272  if test "x$SSL_ENABLED" = "x1"; then
4273    SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTPS"
4274  fi
4275fi
4276if test "x$CURL_DISABLE_FILE" != "x1"; then
4277  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FILE"
4278fi
4279if test "x$CURL_DISABLE_TELNET" != "x1"; then
4280  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TELNET"
4281fi
4282if test "x$CURL_DISABLE_LDAP" != "x1"; then
4283  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAP"
4284  if test "x$CURL_DISABLE_LDAPS" != "x1"; then
4285    if (test "x$USE_OPENLDAP" = "x1" && test "x$SSL_ENABLED" = "x1") ||
4286      (test "x$USE_OPENLDAP" != "x1"  && test "x$HAVE_LDAP_SSL" = "x1"); then
4287      SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAPS"
4288    fi
4289  fi
4290fi
4291if test "x$CURL_DISABLE_DICT" != "x1"; then
4292  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS DICT"
4293fi
4294if test "x$CURL_DISABLE_TFTP" != "x1"; then
4295  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TFTP"
4296fi
4297if test "x$CURL_DISABLE_GOPHER" != "x1"; then
4298  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS GOPHER"
4299fi
4300if test "x$CURL_DISABLE_POP3" != "x1"; then
4301  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3"
4302  if test "x$SSL_ENABLED" = "x1"; then
4303    SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3S"
4304  fi
4305fi
4306if test "x$CURL_DISABLE_IMAP" != "x1"; then
4307  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAP"
4308  if test "x$SSL_ENABLED" = "x1"; then
4309    SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAPS"
4310  fi
4311fi
4312if test "x$CURL_DISABLE_SMB" != "x1" \
4313    -a "x$CURL_DISABLE_CRYPTO_AUTH" != "x1" \
4314    -a \( "x$OPENSSL_ENABLED" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \
4315      -o "x$GNUTLS_ENABLED" = "x1" -o "x$MBEDTLS_ENABLED" = "x1" \
4316      -o "x$NSS_ENABLED" = "x1" -o "x$SECURETRANSPORT_ENABLED" = "x1" \); then
4317  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMB"
4318  if test "x$SSL_ENABLED" = "x1"; then
4319    SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMBS"
4320  fi
4321fi
4322if test "x$CURL_DISABLE_SMTP" != "x1"; then
4323  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTP"
4324  if test "x$SSL_ENABLED" = "x1"; then
4325    SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTPS"
4326  fi
4327fi
4328if test "x$USE_LIBSSH2" = "x1"; then
4329  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
4330  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
4331fi
4332if test "x$USE_LIBSSH" = "x1"; then
4333  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
4334  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
4335fi
4336if test "x$CURL_DISABLE_RTSP" != "x1"; then
4337  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTSP"
4338fi
4339if test "x$USE_LIBRTMP" = "x1"; then
4340  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTMP"
4341fi
4342
4343dnl replace spaces with newlines
4344dnl sort the lines
4345dnl replace the newlines back to spaces
4346SUPPORT_PROTOCOLS=`echo $SUPPORT_PROTOCOLS | tr ' ' '\012' | sort | tr '\012' ' '`
4347
4348AC_SUBST(SUPPORT_PROTOCOLS)
4349
4350dnl squeeze whitespace out of some variables
4351
4352squeeze CFLAGS
4353squeeze CPPFLAGS
4354squeeze DEFS
4355squeeze LDFLAGS
4356squeeze LIBS
4357
4358squeeze LIBCURL_LIBS
4359squeeze CURL_NETWORK_LIBS
4360squeeze CURL_NETWORK_AND_TIME_LIBS
4361
4362squeeze SUPPORT_FEATURES
4363squeeze SUPPORT_PROTOCOLS
4364
4365XC_CHECK_BUILD_FLAGS
4366
4367SSL_BACKENDS=${ssl_backends}
4368AC_SUBST(SSL_BACKENDS)
4369
4370if test "x$want_curldebug_assumed" = "xyes" &&
4371  test "x$want_curldebug" = "xyes" && test "x$USE_ARES" = "x1"; then
4372  ac_configure_args="$ac_configure_args --enable-curldebug"
4373fi
4374
4375AC_CONFIG_FILES([Makefile \
4376           docs/Makefile \
4377           docs/examples/Makefile \
4378           docs/libcurl/Makefile \
4379           docs/libcurl/opts/Makefile \
4380           docs/cmdline-opts/Makefile \
4381           include/Makefile \
4382           include/curl/Makefile \
4383           src/Makefile \
4384           lib/Makefile \
4385           scripts/Makefile \
4386           lib/libcurl.vers \
4387           tests/Makefile \
4388           tests/certs/Makefile \
4389           tests/certs/scripts/Makefile \
4390           tests/data/Makefile \
4391           tests/server/Makefile \
4392           tests/libtest/Makefile \
4393           tests/unit/Makefile \
4394           packages/Makefile \
4395           packages/vms/Makefile \
4396           curl-config \
4397           libcurl.pc
4398])
4399AC_OUTPUT
4400
4401CURL_GENERATE_CONFIGUREHELP_PM
4402
4403XC_AMEND_DISTCLEAN([lib src tests/unit tests/server tests/libtest docs/examples])
4404
4405AC_MSG_NOTICE([Configured to build curl/libcurl:
4406
4407  Host setup:       ${host}
4408  Install prefix:   ${prefix}
4409  Compiler:         ${CC}
4410   CFLAGS:          ${CFLAGS}
4411   CPPFLAGS:        ${CPPFLAGS}
4412   LDFLAGS:         ${LDFLAGS}
4413   LIBS:            ${LIBS}
4414
4415  curl version:     ${CURLVERSION}
4416  SSL:              ${curl_ssl_msg}
4417  SSH:              ${curl_ssh_msg}
4418  zlib:             ${curl_zlib_msg}
4419  brotli:           ${curl_brotli_msg}
4420  GSS-API:          ${curl_gss_msg}
4421  TLS-SRP:          ${curl_tls_srp_msg}
4422  resolver:         ${curl_res_msg}
4423  IPv6:             ${curl_ipv6_msg}
4424  Unix sockets:     ${curl_unix_sockets_msg}
4425  IDN:              ${curl_idn_msg}
4426  Build libcurl:    Shared=${enable_shared}, Static=${enable_static}
4427  Built-in manual:  ${curl_manual_msg}
4428  --libcurl option: ${curl_libcurl_msg}
4429  Verbose errors:   ${curl_verbose_msg}
4430  Code coverage:    ${curl_coverage_msg}
4431  SSPI:             ${curl_sspi_msg}
4432  ca cert bundle:   ${ca}${ca_warning}
4433  ca cert path:     ${capath}${capath_warning}
4434  ca fallback:      ${with_ca_fallback}
4435  LDAP:             ${curl_ldap_msg}
4436  LDAPS:            ${curl_ldaps_msg}
4437  RTSP:             ${curl_rtsp_msg}
4438  RTMP:             ${curl_rtmp_msg}
4439  Metalink:         ${curl_mtlnk_msg}
4440  PSL:              ${curl_psl_msg}
4441  Alt-svc:          ${curl_altsvc_msg}
4442  HTTP2:            ${curl_h2_msg}
4443  Protocols:        ${SUPPORT_PROTOCOLS}
4444  Features:         ${SUPPORT_FEATURES}
4445])
4446if test -n "$experimental"; then
4447 cat >&2 << _EOF
4448  WARNING: $experimental is enabled but marked EXPERIMENTAL. Use with caution!
4449_EOF
4450fi
4451