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