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