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