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