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