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