Imported Upstream version 7.59.0
[platform/upstream/curl.git] / configure.ac
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
9 #
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at https://curl.haxx.se/docs/copyright.html.
13 #
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 #***************************************************************************
22 dnl Process this file with autoconf to produce a configure script.
23
24 AC_PREREQ(2.57)
25
26 dnl We don't know the version number "statically" so we use a dash here
27 AC_INIT([curl], [-], [a suitable curl mailing list: https://curl.haxx.se/mail/])
28
29 XC_OVR_ZZ50
30 XC_OVR_ZZ60
31 CURL_OVERRIDE_AUTOCONF
32
33 dnl configure script copyright
34 AC_COPYRIGHT([Copyright (c) 1998 - 2017 Daniel Stenberg, <daniel@haxx.se>
35 This configure script may be copied, distributed and modified under the
36 terms of the curl license; see COPYING for more details])
37
38 AC_CONFIG_SRCDIR([lib/urldata.h])
39 AC_CONFIG_HEADERS(lib/curl_config.h)
40 AC_CONFIG_MACRO_DIR([m4])
41 AM_MAINTAINER_MODE
42 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
43
44 CURL_CHECK_OPTION_DEBUG
45 CURL_CHECK_OPTION_OPTIMIZE
46 CURL_CHECK_OPTION_WARNINGS
47 CURL_CHECK_OPTION_WERROR
48 CURL_CHECK_OPTION_CURLDEBUG
49 CURL_CHECK_OPTION_SYMBOL_HIDING
50 CURL_CHECK_OPTION_ARES
51 CURL_CHECK_OPTION_RT
52
53 XC_CHECK_PATH_SEPARATOR
54
55 #
56 # save the configure arguments
57 #
58 CONFIGURE_OPTIONS="\"$ac_configure_args\""
59 AC_SUBST(CONFIGURE_OPTIONS)
60
61 CURL_CFLAG_EXTRAS=""
62 if test X"$want_werror" = Xyes; then
63   CURL_CFLAG_EXTRAS="-Werror"
64 fi
65 AC_SUBST(CURL_CFLAG_EXTRAS)
66
67 dnl SED is mandatory for configure process and libtool.
68 dnl Set it now, allowing it to be changed later.
69 if 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
76 fi
77 AC_SUBST([SED])
78
79 dnl GREP is mandatory for configure process and libtool.
80 dnl Set it now, allowing it to be changed later.
81 if 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
88 fi
89 AC_SUBST([GREP])
90
91 dnl EGREP is mandatory for configure process and libtool.
92 dnl Set it now, allowing it to be changed later.
93 if 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
103 fi
104 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
105   AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
106 fi
107 AC_SUBST([EGREP])
108
109 dnl AR is mandatory for configure process and libtool.
110 dnl This is target dependent, so check it as a tool.
111 if 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
118 fi
119 AC_SUBST([AR])
120
121 AC_SUBST(libext)
122
123 dnl figure out the libcurl version
124 CURLVERSION=`$SED -ne 's/^#define LIBCURL_VERSION "\(.*\)".*/\1/p' ${srcdir}/include/curl/curlver.h`
125 XC_CHECK_PROG_CC
126
127 dnl Check if gcc is being used before adding AX_CODE_COVERAGE
128 AS_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
133 XC_AUTOMAKE
134 AC_MSG_CHECKING([curl version])
135 AC_MSG_RESULT($CURLVERSION)
136
137 AC_SUBST(CURLVERSION)
138
139 dnl
140 dnl we extract the numerical version for curl-config only
141 VERSIONNUM=`$SED -ne 's/^#define LIBCURL_VERSION_NUM 0x\([0-9A-Fa-f]*\).*/\1/p' ${srcdir}/include/curl/curlver.h`
142 AC_SUBST(VERSIONNUM)
143
144 dnl Solaris pkgadd support definitions
145 PKGADD_PKG="HAXXcurl"
146 PKGADD_NAME="curl - a client that groks URLs"
147 PKGADD_VENDOR="curl.haxx.se"
148 AC_SUBST(PKGADD_PKG)
149 AC_SUBST(PKGADD_NAME)
150 AC_SUBST(PKGADD_VENDOR)
151
152 dnl
153 dnl 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)"
159 curl_tls_srp_msg="no      (--enable-tls-srp)"
160     curl_res_msg="default (--enable-ares / --enable-threaded-resolver)"
161    curl_ipv6_msg="no      (--enable-ipv6)"
162 curl_unix_sockets_msg="no      (--enable-unix-sockets)"
163     curl_idn_msg="no      (--with-{libidn2,winidn})"
164  curl_manual_msg="no      (--enable-manual)"
165 curl_libcurl_msg="enabled (--disable-libcurl-option)"
166 curl_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
177 dnl
178 dnl Save some initial values the user might have provided
179 dnl
180 INITIAL_LDFLAGS=$LDFLAGS
181 INITIAL_LIBS=$LIBS
182
183 dnl
184 dnl Detect the canonical host and target build environment
185 dnl
186
187 AC_CANONICAL_HOST
188 dnl Get system canonical name
189 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
190
191 dnl Checks for programs.
192
193 dnl This defines _ALL_SOURCE for AIX
194 CURL_CHECK_AIX_ALL_SOURCE
195
196 dnl Our configure and build reentrant settings
197 CURL_CONFIGURE_THREAD_SAFE
198 CURL_CONFIGURE_REENTRANT
199
200 dnl check for how to do large files
201 AC_SYS_LARGEFILE
202
203 XC_LIBTOOL
204
205 #
206 # Automake conditionals based on libtool related checks
207 #
208
209 AM_CONDITIONAL([CURL_LT_SHLIB_USE_VERSION_INFO],
210   [test "x$xc_lt_shlib_use_version_info" = 'xyes'])
211 AM_CONDITIONAL([CURL_LT_SHLIB_USE_NO_UNDEFINED],
212   [test "x$xc_lt_shlib_use_no_undefined" = 'xyes'])
213 AM_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
232 AM_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
241 CPPFLAG_CURL_STATICLIB=
242 if test "x$xc_lt_build_static_only" = 'xyes'; then
243   CPPFLAG_CURL_STATICLIB='-DCURL_STATICLIB'
244 fi
245 AC_SUBST([CPPFLAG_CURL_STATICLIB])
246
247
248 # Determine whether all dependent libraries must be specified when linking
249 if test "X$enable_shared" = "Xyes" -a "X$link_all_deplibs" = "Xno"
250 then
251     REQUIRE_LIB_DEPS=no
252 else
253     REQUIRE_LIB_DEPS=yes
254 fi
255 AC_SUBST(REQUIRE_LIB_DEPS)
256 AM_CONDITIONAL(USE_EXPLICIT_LIB_DEPS, test x$REQUIRE_LIB_DEPS = xyes)
257
258 dnl check if there's a way to force code inline
259 AC_C_INLINE
260
261 dnl **********************************************************************
262 dnl platform/compiler/architecture specific checks/flags
263 dnl **********************************************************************
264
265 CURL_CHECK_COMPILER
266 CURL_SET_COMPILER_BASIC_OPTS
267 CURL_SET_COMPILER_DEBUG_OPTS
268 CURL_SET_COMPILER_OPTIMIZE_OPTS
269 CURL_SET_COMPILER_WARNING_OPTS
270
271 if 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   #
281 fi
282
283 CURL_CHECK_COMPILER_HALT_ON_ERROR
284 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
285 CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH
286 CURL_CHECK_COMPILER_SYMBOL_HIDING
287
288 CURL_CHECK_CURLDEBUG
289 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
290
291 supports_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.
295 if test "x$cross_compiling" != "xno" &&
296    test "x$enable_shared" != "xno"; then
297   supports_unittests=no
298 fi
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.
303 case $host in
304   mips-sgi-irix6.5)
305     if test "$compiler_id" = "GNU_C"; then
306       supports_unittests=no
307     fi
308     ;;
309 esac
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.
314 case $host_os in
315   aix*)
316     supports_unittests=no
317     ;;
318 esac
319
320 dnl Build unit tests when option --enable-debug is given.
321 if test "x$want_debug" = "xyes" &&
322    test "x$supports_unittests" = "xyes"; then
323   want_unittests=yes
324 else
325   want_unittests=no
326 fi
327 AM_CONDITIONAL(BUILD_UNITTESTS, test x$want_unittests = xyes)
328
329 dnl **********************************************************************
330 dnl Compilation based checks should not be done before this point.
331 dnl **********************************************************************
332
333 dnl **********************************************************************
334 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
335 dnl and ws2tcpip.h take precedence over any other further checks which
336 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
337 dnl this specific header files. And do them before its results are used.
338 dnl **********************************************************************
339
340 CURL_CHECK_HEADER_WINDOWS
341 CURL_CHECK_NATIVE_WINDOWS
342 case 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     ;;
357 esac
358 CURL_CHECK_WIN32_LARGEFILE
359
360 CURL_MAC_CFLAGS
361 CURL_SUPPORTS_BUILTIN_AVAILABLE
362
363 dnl ************************************************************
364 dnl switch off particular protocols
365 dnl
366 AC_MSG_CHECKING([whether to support http])
367 AC_ARG_ENABLE(http,
368 AC_HELP_STRING([--enable-http],[Enable HTTP support])
369 AC_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 )
385 AC_MSG_CHECKING([whether to support ftp])
386 AC_ARG_ENABLE(ftp,
387 AC_HELP_STRING([--enable-ftp],[Enable FTP support])
388 AC_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 )
400 AC_MSG_CHECKING([whether to support file])
401 AC_ARG_ENABLE(file,
402 AC_HELP_STRING([--enable-file],[Enable FILE support])
403 AC_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 )
415 AC_MSG_CHECKING([whether to support ldap])
416 AC_ARG_ENABLE(ldap,
417 AC_HELP_STRING([--enable-ldap],[Enable LDAP support])
418 AC_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 )
431 AC_MSG_CHECKING([whether to support ldaps])
432 AC_ARG_ENABLE(ldaps,
433 AC_HELP_STRING([--enable-ldaps],[Enable LDAPS support])
434 AC_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
463 AC_MSG_CHECKING([whether to support rtsp])
464 AC_ARG_ENABLE(rtsp,
465 AC_HELP_STRING([--enable-rtsp],[Enable RTSP support])
466 AC_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
489 AC_MSG_CHECKING([whether to support proxies])
490 AC_ARG_ENABLE(proxy,
491 AC_HELP_STRING([--enable-proxy],[Enable proxy support])
492 AC_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
505 AC_MSG_CHECKING([whether to support dict])
506 AC_ARG_ENABLE(dict,
507 AC_HELP_STRING([--enable-dict],[Enable DICT support])
508 AC_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 )
520 AC_MSG_CHECKING([whether to support telnet])
521 AC_ARG_ENABLE(telnet,
522 AC_HELP_STRING([--enable-telnet],[Enable TELNET support])
523 AC_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 )
535 AC_MSG_CHECKING([whether to support tftp])
536 AC_ARG_ENABLE(tftp,
537 AC_HELP_STRING([--enable-tftp],[Enable TFTP support])
538 AC_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
551 AC_MSG_CHECKING([whether to support pop3])
552 AC_ARG_ENABLE(pop3,
553 AC_HELP_STRING([--enable-pop3],[Enable POP3 support])
554 AC_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
568 AC_MSG_CHECKING([whether to support imap])
569 AC_ARG_ENABLE(imap,
570 AC_HELP_STRING([--enable-imap],[Enable IMAP support])
571 AC_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
585 AC_MSG_CHECKING([whether to support smb])
586 AC_ARG_ENABLE(smb,
587 AC_HELP_STRING([--enable-smb],[Enable SMB/CIFS support])
588 AC_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
601 AC_MSG_CHECKING([whether to support smtp])
602 AC_ARG_ENABLE(smtp,
603 AC_HELP_STRING([--enable-smtp],[Enable SMTP support])
604 AC_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
617 AC_MSG_CHECKING([whether to support gopher])
618 AC_ARG_ENABLE(gopher,
619 AC_HELP_STRING([--enable-gopher],[Enable Gopher support])
620 AC_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
634 dnl **********************************************************************
635 dnl Check for built-in manual
636 dnl **********************************************************************
637
638 AC_MSG_CHECKING([whether to provide built-in manual])
639 AC_ARG_ENABLE(manual,
640 AC_HELP_STRING([--enable-manual],[Enable built-in manual])
641 AC_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 )
653 dnl The actual use of the USE_MANUAL variable is done much later in this
654 dnl script to allow other actions to disable it as well.
655
656 dnl ************************************************************
657 dnl disable C code generation support
658 dnl
659 AC_MSG_CHECKING([whether to enable generation of C code])
660 AC_ARG_ENABLE(libcurl_option,
661 AC_HELP_STRING([--enable-libcurl-option],[Enable --libcurl C code generation support])
662 AC_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
675 dnl **********************************************************************
676 dnl Checks for libraries.
677 dnl **********************************************************************
678
679 AC_MSG_CHECKING([whether to use libgcc])
680 AC_ARG_ENABLE(libgcc,
681 AC_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
693 CURL_CHECK_LIB_XNET
694
695 dnl gethostbyname without lib or in the nsl lib?
696 AC_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
705 if test "$HAVE_GETHOSTBYNAME" != "1"
706 then
707   dnl gethostbyname in the socket lib?
708   AC_CHECK_LIB(socket, gethostbyname,
709                [HAVE_GETHOSTBYNAME="1"
710                LIBS="-lsocket $LIBS"
711                ])
712 fi
713
714 if test "$HAVE_GETHOSTBYNAME" != "1"
715 then
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                ])
723 fi
724
725 dnl At least one system has been identified to require BOTH nsl and socket
726 dnl libs at the same time to link properly.
727 if test "$HAVE_GETHOSTBYNAME" != "1"
728 then
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   ])
744 fi
745
746 if test "$HAVE_GETHOSTBYNAME" != "1"
747 then
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
795 fi
796
797 if test "$HAVE_GETHOSTBYNAME" != "1"
798 then
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   ])
814 fi
815
816 if test "$HAVE_GETHOSTBYNAME" != "1"
817 then
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   ])
833 fi
834
835 if test "$HAVE_GETHOSTBYNAME" != "1"
836 then
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                ])
842 fi
843
844 if test "$HAVE_GETHOSTBYNAME" != "1"
845 then
846   dnl gethostbyname in the net lib - for BeOS
847   AC_CHECK_LIB(net, gethostbyname,
848                [HAVE_GETHOSTBYNAME="1"
849                LIBS="-lnet $LIBS"
850                ])
851 fi
852
853
854 if test "$HAVE_GETHOSTBYNAME" != "1"; then
855   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
856 fi
857
858 CURL_CHECK_LIBS_CONNECT
859
860 CURL_NETWORK_LIBS=$LIBS
861
862 dnl **********************************************************************
863 dnl In case that function clock_gettime with monotonic timer is available,
864 dnl check for additional required libraries.
865 dnl **********************************************************************
866 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
867
868 dnl **********************************************************************
869 dnl The preceding library checks are all potentially useful for test
870 dnl servers and libtest cases which require networking and clock_gettime
871 dnl support.  Save the list of required libraries at this point for use
872 dnl while linking those test servers and programs.
873 dnl **********************************************************************
874 CURL_NETWORK_AND_TIME_LIBS=$LIBS
875
876 dnl **********************************************************************
877 dnl Check for the presence of ZLIB libraries and headers
878 dnl **********************************************************************
879
880 dnl Check for & handle argument to --with-zlib.
881
882 clean_CPPFLAGS=$CPPFLAGS
883 clean_LDFLAGS=$LDFLAGS
884 clean_LIBS=$LIBS
885 ZLIB_LIBS=""
886 AC_ARG_WITH(zlib,
887 AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH])
888 AC_HELP_STRING([--without-zlib],[disable use of zlib]),
889                [OPT_ZLIB="$withval"])
890
891 if test "$OPT_ZLIB" = "no" ; then
892     AC_MSG_WARN([zlib disabled])
893 else
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
979 fi
980
981 dnl set variable for use in automakefile(s)
982 AM_CONDITIONAL(HAVE_LIBZ, test x"$AMFIXLIB" = x1)
983 AC_SUBST(ZLIB_LIBS)
984
985 dnl **********************************************************************
986 dnl Check for the presence of BROTLI decoder libraries and headers
987 dnl **********************************************************************
988
989 dnl Brotli project home page: https://github.com/google/brotli
990
991 dnl Default to compiler & linker defaults for BROTLI files & libraries.
992 OPT_BROTLI=off
993 AC_ARG_WITH(brotli,dnl
994 AC_HELP_STRING([--with-brotli=PATH],[Where to look for brotli, PATH points to the BROTLI installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
995 AC_HELP_STRING([--without-brotli], [disable BROTLI]),
996   OPT_BROTLI=$withval)
997
998 if 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
1071 fi
1072
1073 dnl **********************************************************************
1074 dnl Check for LDAP
1075 dnl **********************************************************************
1076
1077 LDAPLIBNAME=""
1078 AC_ARG_WITH(ldap-lib,
1079 AC_HELP_STRING([--with-ldap-lib=libname],[Specify name of ldap lib file]),
1080  [LDAPLIBNAME="$withval"])
1081
1082 LBERLIBNAME=""
1083 AC_ARG_WITH(lber-lib,
1084 AC_HELP_STRING([--with-lber-lib=libname],[Specify name of lber lib file]),
1085  [LBERLIBNAME="$withval"])
1086
1087 if 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
1122 fi
1123
1124 if 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
1138 fi
1139
1140 if 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
1153 fi
1154
1155 if test x$CURL_DISABLE_LDAPS != x1 ; then
1156     curl_ldaps_msg="enabled"
1157 fi
1158
1159 dnl **********************************************************************
1160 dnl Checks for IPv6
1161 dnl **********************************************************************
1162
1163 AC_MSG_CHECKING([whether to enable IPv6])
1164 AC_ARG_ENABLE(ipv6,
1165 AC_HELP_STRING([--enable-ipv6],[Enable IPv6 (with IPv4) support])
1166 AC_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() */
1185 main()
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
1201 if test "$ipv6" = "yes"; then
1202   curl_ipv6_msg="enabled"
1203 fi
1204
1205 # Check if struct sockaddr_in6 have sin6_scope_id member
1206 if 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
1226 fi
1227
1228 dnl **********************************************************************
1229 dnl Check if the operating system allows programs to write to their own argv[]
1230 dnl **********************************************************************
1231
1232 AC_MSG_CHECKING([if argv can be written to])
1233 AC_RUN_IFELSE([
1234   AC_LANG_SOURCE([[
1235 int 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 ])
1247 case $curl_cv_writable_argv in
1248 yes)
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         ;;
1252 no)
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         ;;
1259 esac
1260
1261 dnl **********************************************************************
1262 dnl Check for GSS-API libraries
1263 dnl **********************************************************************
1264
1265 dnl check for GSS-API stuff in the /usr as default
1266
1267 GSSAPI_ROOT="/usr"
1268 AC_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
1275 AC_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
1282 AC_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
1297 save_CPPFLAGS="$CPPFLAGS"
1298 AC_MSG_CHECKING([if GSS-API support is requested])
1299 if 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         [
1328 AC_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   )
1373 else
1374   AC_MSG_RESULT(no)
1375 fi
1376 if 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
1431 else
1432   CPPFLAGS="$save_CPPFLAGS"
1433 fi
1434
1435 build_libstubgss=no
1436 if test x"$want_gss" = "xyes"; then
1437   build_libstubgss=yes
1438 fi
1439
1440 AM_CONDITIONAL(BUILD_STUB_GSS, test "x$build_libstubgss" = "xyes")
1441
1442 dnl -------------------------------------------------------------
1443 dnl parse --with-default-ssl-backend so it can be validated below
1444 dnl -------------------------------------------------------------
1445
1446 DEFAULT_SSL_BACKEND=no
1447 VALID_DEFAULT_SSL_BACKEND=
1448 AC_ARG_WITH(default-ssl-backend,
1449 AC_HELP_STRING([--with-default-ssl-backend=NAME],[Use NAME as default SSL backend])
1450 AC_HELP_STRING([--without-default-ssl-backend],[Use implicit default SSL backend]),
1451   [DEFAULT_SSL_BACKEND=$withval])
1452 case "$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     ;;
1466 esac
1467
1468 dnl **********************************************************************
1469
1470 dnl -------------------------------------------------
1471 dnl check winssl option before other SSL libraries
1472 dnl -------------------------------------------------
1473
1474 OPT_WINSSL=no
1475 AC_ARG_WITH(winssl,dnl
1476 AC_HELP_STRING([--with-winssl],[enable Windows native SSL/TLS])
1477 AC_HELP_STRING([--without-winssl], [disable Windows native SSL/TLS]),
1478   OPT_WINSSL=$withval)
1479
1480 AC_MSG_CHECKING([whether to enable Windows native SSL/TLS (Windows native builds only)])
1481 if 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"
1500 else
1501   AC_MSG_RESULT(no)
1502 fi
1503
1504 OPT_DARWINSSL=no
1505 AC_ARG_WITH(darwinssl,dnl
1506 AC_HELP_STRING([--with-darwinssl],[enable Apple OS native SSL/TLS])
1507 AC_HELP_STRING([--without-darwinssl], [disable Apple OS native SSL/TLS]),
1508   OPT_DARWINSSL=$withval)
1509
1510 AC_MSG_CHECKING([whether to enable Apple OS native SSL/TLS])
1511 if 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"
1525 else
1526   AC_MSG_RESULT(no)
1527 fi
1528
1529 dnl **********************************************************************
1530 dnl Check for the presence of SSL libraries and headers
1531 dnl **********************************************************************
1532
1533 dnl Default to compiler & linker defaults for SSL files & libraries.
1534 OPT_SSL=off
1535 dnl Default to no CA bundle
1536 ca="no"
1537 AC_ARG_WITH(ssl,dnl
1538 AC_HELP_STRING([--with-ssl=PATH],[Where to look for OpenSSL, PATH points to the SSL installation (default: /usr/local/ssl); when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
1539 AC_HELP_STRING([--without-ssl], [disable OpenSSL]),
1540   OPT_SSL=$withval)
1541
1542 if 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"
1826 fi
1827
1828 dnl **********************************************************************
1829 dnl Check for the random seed preferences
1830 dnl **********************************************************************
1831
1832 if 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
1862 fi
1863
1864 dnl ---
1865 dnl We require OpenSSL with SRP support.
1866 dnl ---
1867 if 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    ])
1873 fi
1874
1875 dnl ----------------------------------------------------
1876 dnl check for GnuTLS
1877 dnl ----------------------------------------------------
1878
1879 dnl Default to compiler & linker defaults for GnuTLS files & libraries.
1880 OPT_GNUTLS=no
1881
1882 AC_ARG_WITH(gnutls,dnl
1883 AC_HELP_STRING([--with-gnutls=PATH],[where to look for GnuTLS, PATH points to the installation root])
1884 AC_HELP_STRING([--without-gnutls], [disable GnuTLS detection]),
1885   OPT_GNUTLS=$withval)
1886
1887 if 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"
1992 fi
1993
1994 dnl ---
1995 dnl Check which crypto backend GnuTLS uses
1996 dnl ---
1997
1998 if 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
2022 fi
2023
2024 dnl ---
2025 dnl We require GnuTLS with SRP support.
2026 dnl ---
2027 if 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    ])
2033 fi
2034
2035 dnl ----------------------------------------------------
2036 dnl check for PolarSSL
2037 dnl ----------------------------------------------------
2038
2039 dnl Default to compiler & linker defaults for PolarSSL files & libraries.
2040 OPT_POLARSSL=no
2041
2042 _cppflags=$CPPFLAGS
2043 _ldflags=$LDFLAGS
2044 AC_ARG_WITH(polarssl,dnl
2045 AC_HELP_STRING([--with-polarssl=PATH],[where to look for PolarSSL, PATH points to the installation root])
2046 AC_HELP_STRING([--without-polarssl], [disable PolarSSL detection]),
2047   OPT_POLARSSL=$withval)
2048
2049 if 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"
2125 fi
2126
2127 dnl ----------------------------------------------------
2128 dnl check for mbedTLS
2129 dnl ----------------------------------------------------
2130
2131 OPT_MBEDTLS=no
2132
2133 _cppflags=$CPPFLAGS
2134 _ldflags=$LDFLAGS
2135 AC_ARG_WITH(mbedtls,dnl
2136 AC_HELP_STRING([--with-mbedtls=PATH],[where to look for mbedTLS, PATH points to the installation root])
2137 AC_HELP_STRING([--without-mbedtls], [disable mbedTLS detection]),
2138   OPT_MBEDTLS=$withval)
2139
2140 if 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"
2216 fi
2217
2218 dnl ----------------------------------------------------
2219 dnl check for CyaSSL
2220 dnl ----------------------------------------------------
2221
2222 dnl Default to compiler & linker defaults for CyaSSL files & libraries.
2223 OPT_CYASSL=no
2224
2225 _cppflags=$CPPFLAGS
2226 _ldflags=$LDFLAGS
2227 AC_ARG_WITH(cyassl,dnl
2228 AC_HELP_STRING([--with-cyassl=PATH],[where to look for CyaSSL, PATH points to the installation root (default: system lib default)])
2229 AC_HELP_STRING([--without-cyassl], [disable CyaSSL detection]),
2230   OPT_CYASSL=$withval)
2231
2232 if 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"
2384 fi
2385
2386 dnl ----------------------------------------------------
2387 dnl NSS. Only check if GnuTLS and OpenSSL are not enabled
2388 dnl ----------------------------------------------------
2389
2390 dnl Default to compiler & linker defaults for NSS files & libraries.
2391 OPT_NSS=no
2392
2393 AC_ARG_WITH(nss,dnl
2394 AC_HELP_STRING([--with-nss=PATH],[where to look for NSS, PATH points to the installation root])
2395 AC_HELP_STRING([--without-nss], [disable NSS detection]),
2396   OPT_NSS=$withval)
2397
2398 if 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 PK11_CreateManagedGenericObject() was introduced in NSS 3.34 because
2487       dnl PK11_DestroyGenericObject() does not release resources allocated by
2488       dnl PK11_CreateGenericObject() early enough.
2489       AC_CHECK_FUNC(PK11_CreateManagedGenericObject,
2490         [
2491           AC_DEFINE(HAVE_PK11_CREATEMANAGEDGENERICOBJECT, 1,
2492                     [if you have the PK11_CreateManagedGenericObject function])
2493         ])
2494
2495       dnl needed when linking the curl tool without USE_EXPLICIT_LIB_DEPS
2496       NSS_LIBS=$addlib
2497       AC_SUBST([NSS_LIBS])
2498
2499       dnl when shared libs were found in a path that the run-time
2500       dnl linker doesn't search through, we need to add it to
2501       dnl LD_LIBRARY_PATH to prevent further configure tests to fail
2502       dnl due to this
2503       if test "x$cross_compiling" != "xyes"; then
2504         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$nssprefix/lib$libsuff"
2505         export LD_LIBRARY_PATH
2506         AC_MSG_NOTICE([Added $nssprefix/lib$libsuff to LD_LIBRARY_PATH])
2507       fi
2508
2509     fi dnl NSS found
2510
2511   fi dnl NSS not disabled
2512
2513   test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
2514 fi
2515
2516 OPT_AXTLS=off
2517
2518 AC_ARG_WITH(axtls,dnl
2519 AC_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.])
2520 AC_HELP_STRING([--without-axtls], [disable axTLS]),
2521   OPT_AXTLS=$withval)
2522
2523 if test -z "$ssl_backends" -o "x$OPT_AXTLS" != xno; then
2524   ssl_msg=
2525   if test X"$OPT_AXTLS" != Xno; then
2526     dnl backup the pre-axtls variables
2527     CLEANLDFLAGS="$LDFLAGS"
2528     CLEANCPPFLAGS="$CPPFLAGS"
2529     CLEANLIBS="$LIBS"
2530
2531     case "$OPT_AXTLS" in
2532     yes)
2533       dnl --with-axtls (without path) used
2534       PREFIX_AXTLS=/usr/local
2535       LIB_AXTLS="$PREFIX_AXTLS/lib"
2536       LDFLAGS="$LDFLAGS -L$LIB_AXTLS"
2537       CPPFLAGS="$CPPFLAGS -I$PREFIX_AXTLS/include"
2538       ;;
2539     off)
2540       dnl no --with-axtls option given, just check default places
2541       PREFIX_AXTLS=
2542       ;;
2543     *)
2544       dnl check the given --with-axtls spot
2545       PREFIX_AXTLS=$OPT_AXTLS
2546       LIB_AXTLS="$PREFIX_AXTLS/lib"
2547       LDFLAGS="$LDFLAGS -L$LIB_AXTLS"
2548       CPPFLAGS="$CPPFLAGS -I$PREFIX_AXTLS/include"
2549       ;;
2550     esac
2551
2552     AC_CHECK_LIB(axtls, ssl_version,[
2553       LIBS="-laxtls $LIBS"
2554       AC_DEFINE(USE_AXTLS, 1, [if axTLS is enabled])
2555       AC_SUBST(USE_AXTLS, [1])
2556       AXTLS_ENABLED=1
2557       USE_AXTLS="yes"
2558       ssl_msg="axTLS"
2559       test axtls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
2560
2561       if test "x$cross_compiling" != "xyes"; then
2562         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIB_AXTLS"
2563         export LD_LIBRARY_PATH
2564         AC_MSG_NOTICE([Added $LIB_AXTLS to LD_LIBRARY_PATH])
2565       fi
2566       ],[
2567       LDFLAGS="$CLEANLDFLAGS"
2568       CPPFLAGS="$CLEANCPPFLAGS"
2569       LIBS="$CLEANLIBS"
2570     ])
2571   fi
2572   test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
2573 fi
2574
2575 case "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$POLARSSL_ENABLED$MBEDTLS_ENABLED$AXTLS_ENABLED$CYASSL_ENABLED$WINSSL_ENABLED$DARWINSSL_ENABLED" in
2576 x)
2577   AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
2578   AC_MSG_WARN([Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss, --with-axtls, --with-winssl, or --with-darwinssl to address this.])
2579   ;;
2580 x1)
2581   # one SSL backend is enabled
2582   AC_SUBST(SSL_ENABLED)
2583   SSL_ENABLED="1"
2584   AC_MSG_NOTICE([built with one SSL backend])
2585   ;;
2586 *)
2587   # more than one SSL backend is enabled
2588   AC_SUBST(SSL_ENABLED)
2589   SSL_ENABLED="1"
2590   AC_SUBST(CURL_WITH_MULTI_SSL)
2591   CURL_WITH_MULTI_SSL="1"
2592   AC_DEFINE(CURL_WITH_MULTI_SSL, 1, [built with multiple SSL backends])
2593   AC_MSG_NOTICE([built with multiple SSL backends])
2594   ;;
2595 esac
2596
2597 if test -n "$ssl_backends"; then
2598   curl_ssl_msg="enabled ($ssl_backends)"
2599 fi
2600
2601 if test no = "$VALID_DEFAULT_SSL_BACKEND"
2602 then
2603   if test -n "$SSL_ENABLED"
2604   then
2605     AC_MSG_ERROR([Default SSL backend $DEFAULT_SSL_BACKEND not enabled!])
2606   else
2607     AC_MSG_ERROR([Default SSL backend requires SSL!])
2608   fi
2609 elif test yes = "$VALID_DEFAULT_SSL_BACKEND"
2610 then
2611   AC_DEFINE_UNQUOTED([CURL_DEFAULT_SSL_BACKEND], ["$DEFAULT_SSL_BACKEND"], [Default SSL backend])
2612 fi
2613
2614 dnl **********************************************************************
2615 dnl Check for the CA bundle
2616 dnl **********************************************************************
2617
2618 CURL_CHECK_CA_BUNDLE
2619
2620 dnl **********************************************************************
2621 dnl Check for libpsl
2622 dnl **********************************************************************
2623
2624 AC_ARG_WITH(libpsl,
2625            AS_HELP_STRING([--without-libpsl],
2626            [disable support for libpsl cookie checking]),
2627            with_libpsl=$withval,
2628            with_libpsl=yes)
2629 if test $with_libpsl != "no"; then
2630   AC_SEARCH_LIBS(psl_builtin, psl,
2631     [curl_psl_msg="yes";
2632      AC_DEFINE([USE_LIBPSL], [1], [PSL support enabled])
2633      ],
2634     [curl_psl_msg="no      (libpsl not found)";
2635      AC_MSG_WARN([libpsl was not found])
2636      ]
2637   )
2638 fi
2639 AM_CONDITIONAL([USE_LIBPSL], [test "$curl_psl_msg" = "yes"])
2640
2641 dnl **********************************************************************
2642 dnl Check for libmetalink
2643 dnl **********************************************************************
2644
2645 OPT_LIBMETALINK=no
2646
2647 AC_ARG_WITH(libmetalink,dnl
2648 AC_HELP_STRING([--with-libmetalink=PATH],[where to look for libmetalink, PATH points to the installation root])
2649 AC_HELP_STRING([--without-libmetalink], [disable libmetalink detection]),
2650   OPT_LIBMETALINK=$withval)
2651
2652 if test X"$OPT_LIBMETALINK" != Xno; then
2653
2654   addld=""
2655   addlib=""
2656   addcflags=""
2657   version=""
2658   libmetalinklib=""
2659
2660   PKGTEST="no"
2661   if test "x$OPT_LIBMETALINK" = "xyes"; then
2662     dnl this is with no partiular path given
2663     PKGTEST="yes"
2664     CURL_CHECK_PKGCONFIG(libmetalink)
2665   else
2666     dnl When particular path is given, set PKG_CONFIG_LIBDIR using the path.
2667     LIBMETALINK_PCDIR="$OPT_LIBMETALINK/lib/pkgconfig"
2668     AC_MSG_NOTICE([PKG_CONFIG_LIBDIR will be set to "$LIBMETALINK_PCDIR"])
2669     if test -f "$LIBMETALINK_PCDIR/libmetalink.pc"; then
2670       PKGTEST="yes"
2671     fi
2672     if test "$PKGTEST" = "yes"; then
2673       CURL_CHECK_PKGCONFIG(libmetalink, [$LIBMETALINK_PCDIR])
2674     fi
2675   fi
2676   if test "$PKGTEST" = "yes" && test "$PKGCONFIG" != "no"; then
2677     addlib=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2678       $PKGCONFIG --libs-only-l libmetalink`
2679     addld=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2680       $PKGCONFIG --libs-only-L libmetalink`
2681     addcflags=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2682       $PKGCONFIG --cflags-only-I libmetalink`
2683     version=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2684       $PKGCONFIG --modversion libmetalink`
2685     libmetalinklib=`echo $addld | $SED -e 's/-L//'`
2686   fi
2687   if test -n "$addlib"; then
2688
2689     clean_CPPFLAGS="$CPPFLAGS"
2690     clean_LDFLAGS="$LDFLAGS"
2691     clean_LIBS="$LIBS"
2692     CPPFLAGS="$clean_CPPFLAGS $addcflags"
2693     LDFLAGS="$clean_LDFLAGS $addld"
2694     LIBS="$addlib $clean_LIBS"
2695     AC_MSG_CHECKING([if libmetalink is recent enough])
2696     AC_LINK_IFELSE([
2697       AC_LANG_PROGRAM([[
2698 #       include <metalink/metalink.h>
2699       ]],[[
2700         if(0 != metalink_strerror(0)) /* added in 0.1.0 */
2701           return 1;
2702       ]])
2703     ],[
2704       AC_MSG_RESULT([yes ($version)])
2705       want_metalink="yes"
2706     ],[
2707       AC_MSG_RESULT([no ($version)])
2708       AC_MSG_NOTICE([libmetalink library defective or too old])
2709       want_metalink="no"
2710     ])
2711     CPPFLAGS="$clean_CPPFLAGS"
2712     LDFLAGS="$clean_LDFLAGS"
2713     LIBS="$clean_LIBS"
2714     if test "$want_metalink" = "yes"; then
2715       dnl finally libmetalink will be used
2716       AC_DEFINE(USE_METALINK, 1, [Define to enable metalink support])
2717       LIBMETALINK_LIBS=$addlib
2718       LIBMETALINK_LDFLAGS=$addld
2719       LIBMETALINK_CPPFLAGS=$addcflags
2720       AC_SUBST([LIBMETALINK_LIBS])
2721       AC_SUBST([LIBMETALINK_LDFLAGS])
2722       AC_SUBST([LIBMETALINK_CPPFLAGS])
2723       curl_mtlnk_msg="enabled"
2724     fi
2725
2726   fi
2727 fi
2728
2729 dnl **********************************************************************
2730 dnl Check for the presence of LIBSSH2 libraries and headers
2731 dnl **********************************************************************
2732
2733 dnl Default to compiler & linker defaults for LIBSSH2 files & libraries.
2734 OPT_LIBSSH2=off
2735 AC_ARG_WITH(libssh2,dnl
2736 AC_HELP_STRING([--with-libssh2=PATH],[Where to look for libssh2, PATH points to the LIBSSH2 installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
2737 AC_HELP_STRING([--with-libssh2], [enable LIBSSH2]),
2738   OPT_LIBSSH2=$withval, OPT_LIBSSH2=no)
2739
2740
2741 OPT_LIBSSH=off
2742 AC_ARG_WITH(libssh,dnl
2743 AC_HELP_STRING([--with-libssh=PATH],[Where to look for libssh, PATH points to the LIBSSH installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
2744 AC_HELP_STRING([--with-libssh], [enable LIBSSH]),
2745   OPT_LIBSSH=$withval, OPT_LIBSSH=no)
2746
2747 if test X"$OPT_LIBSSH2" != Xno; then
2748   dnl backup the pre-libssh2 variables
2749   CLEANLDFLAGS="$LDFLAGS"
2750   CLEANCPPFLAGS="$CPPFLAGS"
2751   CLEANLIBS="$LIBS"
2752
2753   case "$OPT_LIBSSH2" in
2754   yes)
2755     dnl --with-libssh2 (without path) used
2756     CURL_CHECK_PKGCONFIG(libssh2)
2757
2758     if test "$PKGCONFIG" != "no" ; then
2759       LIB_SSH2=`$PKGCONFIG --libs-only-l libssh2`
2760       LD_SSH2=`$PKGCONFIG --libs-only-L libssh2`
2761       CPP_SSH2=`$PKGCONFIG --cflags-only-I libssh2`
2762       version=`$PKGCONFIG --modversion libssh2`
2763       DIR_SSH2=`echo $LD_SSH2 | $SED -e 's/-L//'`
2764     fi
2765
2766     ;;
2767   off)
2768     dnl no --with-libssh2 option given, just check default places
2769     ;;
2770   *)
2771     dnl use the given --with-libssh2 spot
2772     PREFIX_SSH2=$OPT_LIBSSH2
2773     ;;
2774   esac
2775
2776   dnl if given with a prefix, we set -L and -I based on that
2777   if test -n "$PREFIX_SSH2"; then
2778     LIB_SSH2="-lssh2"
2779     LD_SSH2=-L${PREFIX_SSH2}/lib$libsuff
2780     CPP_SSH2=-I${PREFIX_SSH2}/include
2781     DIR_SSH2=${PREFIX_SSH2}/lib$libsuff
2782   fi
2783
2784   LDFLAGS="$LDFLAGS $LD_SSH2"
2785   CPPFLAGS="$CPPFLAGS $CPP_SSH2"
2786   LIBS="$LIB_SSH2 $LIBS"
2787
2788   AC_CHECK_LIB(ssh2, libssh2_channel_open_ex)
2789
2790   AC_CHECK_HEADERS(libssh2.h,
2791     curl_ssh_msg="enabled (libSSH2)"
2792     LIBSSH2_ENABLED=1
2793     AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use])
2794     AC_SUBST(USE_LIBSSH2, [1])
2795   )
2796
2797   if test X"$OPT_LIBSSH2" != Xoff &&
2798      test "$LIBSSH2_ENABLED" != "1"; then
2799     AC_MSG_ERROR([libSSH2 libs and/or directories were not found where specified!])
2800   fi
2801
2802   if test "$LIBSSH2_ENABLED" = "1"; then
2803     if test -n "$DIR_SSH2"; then
2804        dnl when the libssh2 shared libs were found in a path that the run-time
2805        dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
2806        dnl to prevent further configure tests to fail due to this
2807
2808        if test "x$cross_compiling" != "xyes"; then
2809          LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DIR_SSH2"
2810          export LD_LIBRARY_PATH
2811          AC_MSG_NOTICE([Added $DIR_SSH2 to LD_LIBRARY_PATH])
2812        fi
2813     fi
2814   else
2815     dnl no libssh2, revert back to clean variables
2816     LDFLAGS=$CLEANLDFLAGS
2817     CPPFLAGS=$CLEANCPPFLAGS
2818     LIBS=$CLEANLIBS
2819   fi
2820 elif test X"$OPT_LIBSSH" != Xno; then
2821   dnl backup the pre-libssh variables
2822   CLEANLDFLAGS="$LDFLAGS"
2823   CLEANCPPFLAGS="$CPPFLAGS"
2824   CLEANLIBS="$LIBS"
2825
2826   case "$OPT_LIBSSH" in
2827   yes)
2828     dnl --with-libssh (without path) used
2829     CURL_CHECK_PKGCONFIG(libssh)
2830
2831     if test "$PKGCONFIG" != "no" ; then
2832       LIB_SSH=`$PKGCONFIG --libs-only-l libssh`
2833       LD_SSH=`$PKGCONFIG --libs-only-L libssh`
2834       CPP_SSH=`$PKGCONFIG --cflags-only-I libssh`
2835       version=`$PKGCONFIG --modversion libssh`
2836       DIR_SSH=`echo $LD_SSH | $SED -e 's/-L//'`
2837     fi
2838
2839     ;;
2840   off)
2841     dnl no --with-libssh option given, just check default places
2842     ;;
2843   *)
2844     dnl use the given --with-libssh spot
2845     PREFIX_SSH=$OPT_LIBSSH
2846     ;;
2847   esac
2848
2849   dnl if given with a prefix, we set -L and -I based on that
2850   if test -n "$PREFIX_SSH"; then
2851     LIB_SSH="-lssh"
2852     LD_SSH=-L${PREFIX_SSH}/lib$libsuff
2853     CPP_SSH=-I${PREFIX_SSH}/include
2854     DIR_SSH=${PREFIX_SSH}/lib$libsuff
2855   fi
2856
2857   LDFLAGS="$LDFLAGS $LD_SSH"
2858   CPPFLAGS="$CPPFLAGS $CPP_SSH"
2859   LIBS="$LIB_SSH $LIBS"
2860
2861   AC_CHECK_LIB(ssh, ssh_new)
2862
2863   AC_CHECK_HEADERS(libssh/libssh.h,
2864     curl_ssh_msg="enabled (libSSH)"
2865     LIBSSH_ENABLED=1
2866     AC_DEFINE(USE_LIBSSH, 1, [if libSSH is in use])
2867     AC_SUBST(USE_LIBSSH, [1])
2868   )
2869
2870   if test X"$OPT_LIBSSH" != Xoff &&
2871      test "$LIBSSH_ENABLED" != "1"; then
2872     AC_MSG_ERROR([libSSH libs and/or directories were not found where specified!])
2873   fi
2874
2875   if test "$LIBSSH_ENABLED" = "1"; then
2876     if test -n "$DIR_SSH"; then
2877        dnl when the libssh shared libs were found in a path that the run-time
2878        dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
2879        dnl to prevent further configure tests to fail due to this
2880
2881        if test "x$cross_compiling" != "xyes"; then
2882          LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DIR_SSH"
2883          export LD_LIBRARY_PATH
2884          AC_MSG_NOTICE([Added $DIR_SSH to LD_LIBRARY_PATH])
2885        fi
2886     fi
2887   else
2888     dnl no libssh, revert back to clean variables
2889     LDFLAGS=$CLEANLDFLAGS
2890     CPPFLAGS=$CLEANCPPFLAGS
2891     LIBS=$CLEANLIBS
2892   fi
2893 fi
2894
2895 dnl **********************************************************************
2896 dnl Check for the presence of LIBRTMP libraries and headers
2897 dnl **********************************************************************
2898
2899 dnl Default to compiler & linker defaults for LIBRTMP files & libraries.
2900 OPT_LIBRTMP=off
2901 AC_ARG_WITH(librtmp,dnl
2902 AC_HELP_STRING([--with-librtmp=PATH],[Where to look for librtmp, PATH points to the LIBRTMP installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
2903 AC_HELP_STRING([--without-librtmp], [disable LIBRTMP]),
2904   OPT_LIBRTMP=$withval)
2905
2906 if test X"$OPT_LIBRTMP" != Xno; then
2907   dnl backup the pre-librtmp variables
2908   CLEANLDFLAGS="$LDFLAGS"
2909   CLEANCPPFLAGS="$CPPFLAGS"
2910   CLEANLIBS="$LIBS"
2911
2912   case "$OPT_LIBRTMP" in
2913   yes)
2914     dnl --with-librtmp (without path) used
2915     CURL_CHECK_PKGCONFIG(librtmp)
2916
2917     if test "$PKGCONFIG" != "no" ; then
2918       LIB_RTMP=`$PKGCONFIG --libs-only-l librtmp`
2919       LD_RTMP=`$PKGCONFIG --libs-only-L librtmp`
2920       CPP_RTMP=`$PKGCONFIG --cflags-only-I librtmp`
2921       version=`$PKGCONFIG --modversion librtmp`
2922       DIR_RTMP=`echo $LD_RTMP | $SED -e 's/-L//'`
2923     else
2924       dnl To avoid link errors, we do not allow --librtmp without
2925       dnl a pkgconfig file
2926       AC_MSG_ERROR([--librtmp was specified but could not find librtmp pkgconfig file.])
2927     fi
2928
2929     ;;
2930   off)
2931     dnl no --with-librtmp option given, just check default places
2932     LIB_RTMP="-lrtmp"
2933     ;;
2934   *)
2935     dnl use the given --with-librtmp spot
2936     LIB_RTMP="-lrtmp"
2937     PREFIX_RTMP=$OPT_LIBRTMP
2938     ;;
2939   esac
2940
2941   dnl if given with a prefix, we set -L and -I based on that
2942   if test -n "$PREFIX_RTMP"; then
2943     LD_RTMP=-L${PREFIX_RTMP}/lib$libsuff
2944     CPP_RTMP=-I${PREFIX_RTMP}/include
2945     DIR_RTMP=${PREFIX_RTMP}/lib$libsuff
2946   fi
2947
2948   LDFLAGS="$LDFLAGS $LD_RTMP"
2949   CPPFLAGS="$CPPFLAGS $CPP_RTMP"
2950   LIBS="$LIB_RTMP $LIBS"
2951
2952   AC_CHECK_LIB(rtmp, RTMP_Init,
2953     [
2954      AC_CHECK_HEADERS(librtmp/rtmp.h,
2955         curl_rtmp_msg="enabled (librtmp)"
2956         LIBRTMP_ENABLED=1
2957         AC_DEFINE(USE_LIBRTMP, 1, [if librtmp is in use])
2958         AC_SUBST(USE_LIBRTMP, [1])
2959      )
2960     ],
2961       dnl not found, revert back to clean variables
2962       LDFLAGS=$CLEANLDFLAGS
2963       CPPFLAGS=$CLEANCPPFLAGS
2964       LIBS=$CLEANLIBS
2965   )
2966
2967   if test X"$OPT_LIBRTMP" != Xoff &&
2968      test "$LIBRTMP_ENABLED" != "1"; then
2969     AC_MSG_ERROR([librtmp libs and/or directories were not found where specified!])
2970   fi
2971
2972 fi
2973
2974 dnl **********************************************************************
2975 dnl Check for linker switch for versioned symbols
2976 dnl **********************************************************************
2977
2978 versioned_symbols_flavour=
2979 AC_MSG_CHECKING([whether versioned symbols are wanted])
2980 AC_ARG_ENABLE(versioned-symbols,
2981 AC_HELP_STRING([--enable-versioned-symbols], [Enable versioned symbols in shared library])
2982 AC_HELP_STRING([--disable-versioned-symbols], [Disable versioned symbols in shared library]),
2983 [ case "$enableval" in
2984   yes) AC_MSG_RESULT(yes)
2985     AC_MSG_CHECKING([if libraries can be versioned])
2986     GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
2987     if test -z "$GLD"; then
2988         AC_MSG_RESULT(no)
2989         AC_MSG_WARN([You need an ld version supporting the --version-script option])
2990     else
2991         AC_MSG_RESULT(yes)
2992         if test "x$CURL_WITH_MULTI_SSL" = "x1"; then
2993           versioned_symbols_flavour="MULTISSL_"
2994         elif test "x$OPENSSL_ENABLED" = "x1"; then
2995           versioned_symbols_flavour="OPENSSL_"
2996         elif test "x$GNUTLS_ENABLED" = "x1"; then
2997           versioned_symbols_flavour="GNUTLS_"
2998         elif test "x$NSS_ENABLED" = "x1"; then
2999           versioned_symbols_flavour="NSS_"
3000         elif test "x$POLARSSL_ENABLED" = "x1"; then
3001           versioned_symbols_flavour="POLARSSL_"
3002         elif test "x$CYASSL_ENABLED" = "x1"; then
3003           versioned_symbols_flavour="CYASSL_"
3004         elif test "x$AXTLS_ENABLED" = "x1"; then
3005           versioned_symbols_flavour="AXTLS_"
3006         elif test "x$WINSSL_ENABLED" = "x1"; then
3007           versioned_symbols_flavour="WINSSL_"
3008         elif test "x$DARWINSSL_ENABLED" = "x1"; then
3009           versioned_symbols_flavour="DARWINSSL_"
3010         else
3011           versioned_symbols_flavour=""
3012         fi
3013         versioned_symbols="yes"
3014     fi
3015     ;;
3016
3017   *)   AC_MSG_RESULT(no)
3018     ;;
3019   esac
3020 ], [
3021 AC_MSG_RESULT(no)
3022 ]
3023 )
3024
3025 AC_SUBST([CURL_LT_SHLIB_VERSIONED_FLAVOUR],
3026   ["$versioned_symbols_flavour"])
3027 AM_CONDITIONAL([CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS],
3028   [test "x$versioned_symbols" = 'xyes'])
3029
3030 dnl -------------------------------------------------
3031 dnl check winidn option before other IDN libraries
3032 dnl -------------------------------------------------
3033
3034 AC_MSG_CHECKING([whether to enable Windows native IDN (Windows native builds only)])
3035 OPT_WINIDN="default"
3036 AC_ARG_WITH(winidn,
3037 AC_HELP_STRING([--with-winidn=PATH],[enable Windows native IDN])
3038 AC_HELP_STRING([--without-winidn], [disable Windows native IDN]),
3039   OPT_WINIDN=$withval)
3040 case "$OPT_WINIDN" in
3041   no|default)
3042     dnl --without-winidn option used or configure option not specified
3043     want_winidn="no"
3044     AC_MSG_RESULT([no])
3045     ;;
3046   yes)
3047     dnl --with-winidn option used without path
3048     want_winidn="yes"
3049     want_winidn_path="default"
3050     AC_MSG_RESULT([yes])
3051     ;;
3052   *)
3053     dnl --with-winidn option used with path
3054     want_winidn="yes"
3055     want_winidn_path="$withval"
3056     AC_MSG_RESULT([yes ($withval)])
3057     ;;
3058 esac
3059
3060 if test "$want_winidn" = "yes"; then
3061   dnl winidn library support has been requested
3062   clean_CPPFLAGS="$CPPFLAGS"
3063   clean_LDFLAGS="$LDFLAGS"
3064   clean_LIBS="$LIBS"
3065   WINIDN_LIBS="-lnormaliz"
3066   WINIDN_CPPFLAGS="-DWINVER=0x0600"
3067   #
3068   if test "$want_winidn_path" != "default"; then
3069     dnl path has been specified
3070     dnl pkg-config not available or provides no info
3071     WINIDN_LDFLAGS="-L$want_winidn_path/lib$libsuff"
3072     WINIDN_CPPFLAGS="-I$want_winidn_path/include"
3073     WINIDN_DIR="$want_winidn_path/lib$libsuff"
3074   fi
3075   #
3076   CPPFLAGS="$CPPFLAGS $WINIDN_CPPFLAGS"
3077   LDFLAGS="$LDFLAGS $WINIDN_LDFLAGS"
3078   LIBS="$WINIDN_LIBS $LIBS"
3079   #
3080   AC_MSG_CHECKING([if IdnToUnicode can be linked])
3081   AC_LINK_IFELSE([
3082     AC_LANG_PROGRAM([[
3083       #include <windows.h>
3084     ]],[[
3085       IdnToUnicode(0, NULL, 0, NULL, 0);
3086     ]])
3087   ],[
3088     AC_MSG_RESULT([yes])
3089     tst_links_winidn="yes"
3090   ],[
3091     AC_MSG_RESULT([no])
3092     tst_links_winidn="no"
3093   ])
3094   #
3095   if test "$tst_links_winidn" = "yes"; then
3096     AC_DEFINE(USE_WIN32_IDN, 1, [Define to 1 if you have the `normaliz' (WinIDN) library (-lnormaliz).])
3097     AC_DEFINE(WANT_IDN_PROTOTYPES, 1, [Define to 1 to provide own prototypes.])
3098     AC_SUBST([IDN_ENABLED], [1])
3099     curl_idn_msg="enabled (Windows-native)"
3100   else
3101     AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
3102     CPPFLAGS="$clean_CPPFLAGS"
3103     LDFLAGS="$clean_LDFLAGS"
3104     LIBS="$clean_LIBS"
3105   fi
3106 fi
3107
3108 dnl **********************************************************************
3109 dnl Check for the presence of IDN libraries and headers
3110 dnl **********************************************************************
3111
3112 AC_MSG_CHECKING([whether to build with libidn2])
3113 OPT_IDN="default"
3114 AC_ARG_WITH(libidn2,
3115 AC_HELP_STRING([--with-libidn2=PATH],[Enable libidn2 usage])
3116 AC_HELP_STRING([--without-libidn2],[Disable libidn2 usage]),
3117   [OPT_IDN=$withval])
3118 case "$OPT_IDN" in
3119   no)
3120     dnl --without-libidn2 option used
3121     want_idn="no"
3122     AC_MSG_RESULT([no])
3123     ;;
3124   default)
3125     dnl configure option not specified
3126     want_idn="yes"
3127     want_idn_path="default"
3128     AC_MSG_RESULT([(assumed) yes])
3129     ;;
3130   yes)
3131     dnl --with-libidn2 option used without path
3132     want_idn="yes"
3133     want_idn_path="default"
3134     AC_MSG_RESULT([yes])
3135     ;;
3136   *)
3137     dnl --with-libidn2 option used with path
3138     want_idn="yes"
3139     want_idn_path="$withval"
3140     AC_MSG_RESULT([yes ($withval)])
3141     ;;
3142 esac
3143
3144 if test "$want_idn" = "yes"; then
3145   dnl idn library support has been requested
3146   clean_CPPFLAGS="$CPPFLAGS"
3147   clean_LDFLAGS="$LDFLAGS"
3148   clean_LIBS="$LIBS"
3149   PKGCONFIG="no"
3150   #
3151   if test "$want_idn_path" != "default"; then
3152     dnl path has been specified
3153     IDN_PCDIR="$want_idn_path/lib$libsuff/pkgconfig"
3154     CURL_CHECK_PKGCONFIG(libidn2, [$IDN_PCDIR])
3155     if test "$PKGCONFIG" != "no"; then
3156       IDN_LIBS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
3157         $PKGCONFIG --libs-only-l libidn2 2>/dev/null`
3158       IDN_LDFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
3159         $PKGCONFIG --libs-only-L libidn2 2>/dev/null`
3160       IDN_CPPFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
3161         $PKGCONFIG --cflags-only-I libidn2 2>/dev/null`
3162       IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
3163     else
3164       dnl pkg-config not available or provides no info
3165       IDN_LIBS="-lidn2"
3166       IDN_LDFLAGS="-L$want_idn_path/lib$libsuff"
3167       IDN_CPPFLAGS="-I$want_idn_path/include"
3168       IDN_DIR="$want_idn_path/lib$libsuff"
3169     fi
3170   else
3171     dnl path not specified
3172     CURL_CHECK_PKGCONFIG(libidn2)
3173     if test "$PKGCONFIG" != "no"; then
3174       IDN_LIBS=`$PKGCONFIG --libs-only-l libidn2 2>/dev/null`
3175       IDN_LDFLAGS=`$PKGCONFIG --libs-only-L libidn2 2>/dev/null`
3176       IDN_CPPFLAGS=`$PKGCONFIG --cflags-only-I libidn2 2>/dev/null`
3177       IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
3178     else
3179       dnl pkg-config not available or provides no info
3180       IDN_LIBS="-lidn2"
3181     fi
3182   fi
3183   #
3184   if test "$PKGCONFIG" != "no"; then
3185     AC_MSG_NOTICE([pkg-config: IDN_LIBS: "$IDN_LIBS"])
3186     AC_MSG_NOTICE([pkg-config: IDN_LDFLAGS: "$IDN_LDFLAGS"])
3187     AC_MSG_NOTICE([pkg-config: IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
3188     AC_MSG_NOTICE([pkg-config: IDN_DIR: "$IDN_DIR"])
3189   else
3190     AC_MSG_NOTICE([IDN_LIBS: "$IDN_LIBS"])
3191     AC_MSG_NOTICE([IDN_LDFLAGS: "$IDN_LDFLAGS"])
3192     AC_MSG_NOTICE([IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
3193     AC_MSG_NOTICE([IDN_DIR: "$IDN_DIR"])
3194   fi
3195   #
3196   CPPFLAGS="$CPPFLAGS $IDN_CPPFLAGS"
3197   LDFLAGS="$LDFLAGS $IDN_LDFLAGS"
3198   LIBS="$IDN_LIBS $LIBS"
3199   #
3200   AC_MSG_CHECKING([if idn2_lookup_ul can be linked])
3201   AC_LINK_IFELSE([
3202     AC_LANG_FUNC_LINK_TRY([idn2_lookup_ul])
3203   ],[
3204     AC_MSG_RESULT([yes])
3205     tst_links_libidn="yes"
3206   ],[
3207     AC_MSG_RESULT([no])
3208     tst_links_libidn="no"
3209   ])
3210   #
3211   AC_CHECK_HEADERS( idn2.h )
3212
3213   if test "$tst_links_libidn" = "yes"; then
3214     AC_DEFINE(HAVE_LIBIDN2, 1, [Define to 1 if you have the `idn2' library (-lidn2).])
3215     dnl different versions of libidn have different setups of these:
3216
3217     AC_SUBST([IDN_ENABLED], [1])
3218     curl_idn_msg="enabled (libidn2)"
3219     if test -n "$IDN_DIR" -a "x$cross_compiling" != "xyes"; then
3220       LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$IDN_DIR"
3221       export LD_LIBRARY_PATH
3222       AC_MSG_NOTICE([Added $IDN_DIR to LD_LIBRARY_PATH])
3223     fi
3224   else
3225     AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
3226     CPPFLAGS="$clean_CPPFLAGS"
3227     LDFLAGS="$clean_LDFLAGS"
3228     LIBS="$clean_LIBS"
3229   fi
3230 fi
3231
3232
3233 dnl Let's hope this split URL remains working:
3234 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
3235 dnl genprogc/thread_quick_ref.htm
3236
3237
3238 dnl **********************************************************************
3239 dnl Check for nghttp2
3240 dnl **********************************************************************
3241
3242 OPT_H2="yes"
3243
3244 if test "x$disable_http" = "xyes"; then
3245   # without HTTP, nghttp2 is no use
3246   OPT_H2="no"
3247 fi
3248
3249 AC_ARG_WITH(nghttp2,
3250 AC_HELP_STRING([--with-nghttp2=PATH],[Enable nghttp2 usage])
3251 AC_HELP_STRING([--without-nghttp2],[Disable nghttp2 usage]),
3252   [OPT_H2=$withval])
3253 case "$OPT_H2" in
3254   no)
3255     dnl --without-nghttp2 option used
3256     want_h2="no"
3257     ;;
3258   yes)
3259     dnl --with-nghttp2 option used without path
3260     want_h2="default"
3261     want_h2_path=""
3262     ;;
3263   *)
3264     dnl --with-nghttp2 option used with path
3265     want_h2="yes"
3266     want_h2_path="$withval/lib/pkgconfig"
3267     ;;
3268 esac
3269
3270 curl_h2_msg="disabled (--with-nghttp2)"
3271 if test X"$want_h2" != Xno; then
3272   dnl backup the pre-nghttp2 variables
3273   CLEANLDFLAGS="$LDFLAGS"
3274   CLEANCPPFLAGS="$CPPFLAGS"
3275   CLEANLIBS="$LIBS"
3276
3277   CURL_CHECK_PKGCONFIG(libnghttp2, $want_h2_path)
3278
3279   if test "$PKGCONFIG" != "no" ; then
3280     LIB_H2=`CURL_EXPORT_PCDIR([$want_h2_path])
3281       $PKGCONFIG --libs-only-l libnghttp2`
3282     AC_MSG_NOTICE([-l is $LIB_H2])
3283
3284     CPP_H2=`CURL_EXPORT_PCDIR([$want_h2_path]) dnl
3285       $PKGCONFIG --cflags-only-I libnghttp2`
3286     AC_MSG_NOTICE([-I is $CPP_H2])
3287
3288     LD_H2=`CURL_EXPORT_PCDIR([$want_h2_path])
3289       $PKGCONFIG --libs-only-L libnghttp2`
3290     AC_MSG_NOTICE([-L is $LD_H2])
3291
3292     LDFLAGS="$LDFLAGS $LD_H2"
3293     CPPFLAGS="$CPPFLAGS $CPP_H2"
3294     LIBS="$LIB_H2 $LIBS"
3295
3296     # use nghttp2_option_set_no_recv_client_magic to require nghttp2
3297     # >= 1.0.0
3298     AC_CHECK_LIB(nghttp2, nghttp2_option_set_no_recv_client_magic,
3299       [
3300        AC_CHECK_HEADERS(nghttp2/nghttp2.h,
3301           curl_h2_msg="enabled (nghttp2)"
3302           NGHTTP2_ENABLED=1
3303           AC_DEFINE(USE_NGHTTP2, 1, [if nghttp2 is in use])
3304           AC_SUBST(USE_NGHTTP2, [1])
3305        )
3306       ],
3307         dnl not found, revert back to clean variables
3308         LDFLAGS=$CLEANLDFLAGS
3309         CPPFLAGS=$CLEANCPPFLAGS
3310         LIBS=$CLEANLIBS
3311     )
3312
3313   else
3314     dnl no nghttp2 pkg-config found, deal with it
3315     if test X"$want_h2" != Xdefault; then
3316       dnl To avoid link errors, we do not allow --with-nghttp2 without
3317       dnl a pkgconfig file
3318       AC_MSG_ERROR([--with-nghttp2 was specified but could not find libnghttp2 pkg-config file.])
3319     fi
3320   fi
3321
3322 fi
3323
3324 dnl **********************************************************************
3325 dnl Check for zsh completion path
3326 dnl **********************************************************************
3327
3328 OPT_ZSH_FPATH=default
3329 AC_ARG_WITH(zsh-functions-dir,
3330 AC_HELP_STRING([--with-zsh-functions-dir=PATH],[Install zsh completions to PATH])
3331 AC_HELP_STRING([--without-zsh-functions-dir],[Do not install zsh completions]),
3332   [OPT_ZSH_FPATH=$withval])
3333 case "$OPT_ZSH_FPATH" in
3334   no)
3335     dnl --without-zsh-functions-dir option used
3336     ;;
3337   default|yes)
3338     dnl --with-zsh-functions-dir option used without path
3339     ZSH_FUNCTIONS_DIR="$datarootdir/zsh/site-functions"
3340     AC_SUBST(ZSH_FUNCTIONS_DIR)
3341     ;;
3342   *)
3343     dnl --with-zsh-functions-dir option used with path
3344     ZSH_FUNCTIONS_DIR="$withval"
3345     AC_SUBST(ZSH_FUNCTIONS_DIR)
3346     ;;
3347 esac
3348
3349 dnl **********************************************************************
3350 dnl Back to "normal" configuring
3351 dnl **********************************************************************
3352
3353 dnl Checks for header files.
3354 AC_HEADER_STDC
3355
3356 CURL_CHECK_HEADER_MALLOC
3357 CURL_CHECK_HEADER_MEMORY
3358
3359 dnl Now check for the very most basic headers. Then we can use these
3360 dnl ones as default-headers when checking for the rest!
3361 AC_CHECK_HEADERS(
3362         sys/types.h \
3363         sys/time.h \
3364         sys/select.h \
3365         sys/socket.h \
3366         sys/ioctl.h \
3367         sys/uio.h \
3368         assert.h \
3369         unistd.h \
3370         stdlib.h \
3371         arpa/inet.h \
3372         net/if.h \
3373         netinet/in.h \
3374         netinet/in6.h \
3375         sys/un.h \
3376         linux/tcp.h \
3377         netinet/tcp.h \
3378         netdb.h \
3379         sys/sockio.h \
3380         sys/stat.h \
3381         sys/param.h \
3382         termios.h \
3383         termio.h \
3384         sgtty.h \
3385         fcntl.h \
3386         alloca.h \
3387         time.h \
3388         io.h \
3389         pwd.h \
3390         utime.h \
3391         sys/utime.h \
3392         sys/poll.h \
3393         poll.h \
3394         socket.h \
3395         sys/resource.h \
3396         libgen.h \
3397         locale.h \
3398         errno.h \
3399         stdbool.h \
3400         arpa/tftp.h \
3401         sys/filio.h \
3402         sys/wait.h \
3403         setjmp.h,
3404 dnl to do if not found
3405 [],
3406 dnl to do if found
3407 [],
3408 dnl default includes
3409 [
3410 #ifdef HAVE_SYS_TYPES_H
3411 #include <sys/types.h>
3412 #endif
3413 #ifdef HAVE_SYS_TIME_H
3414 #include <sys/time.h>
3415 #endif
3416 #ifdef HAVE_SYS_SELECT_H
3417 #include <sys/select.h>
3418 #endif
3419 #ifdef HAVE_SYS_SOCKET_H
3420 #include <sys/socket.h>
3421 #endif
3422 #ifdef HAVE_NETINET_IN_H
3423 #include <netinet/in.h>
3424 #endif
3425 #ifdef HAVE_NETINET_IN6_H
3426 #include <netinet/in6.h>
3427 #endif
3428 #ifdef HAVE_SYS_UN_H
3429 #include <sys/un.h>
3430 #endif
3431 ]
3432 )
3433
3434 dnl Checks for typedefs, structures, and compiler characteristics.
3435 AC_C_CONST
3436 CURL_CHECK_VARIADIC_MACROS
3437 AC_TYPE_SIZE_T
3438 AC_HEADER_TIME
3439 CURL_CHECK_STRUCT_TIMEVAL
3440 CURL_VERIFY_RUNTIMELIBS
3441
3442 AC_CHECK_SIZEOF(size_t)
3443 AC_CHECK_SIZEOF(long)
3444 AC_CHECK_SIZEOF(int)
3445 AC_CHECK_SIZEOF(short)
3446 AC_CHECK_SIZEOF(time_t)
3447 AC_CHECK_SIZEOF(off_t)
3448
3449 o=$CPPFLAGS
3450 CPPFLAGS="-I$srcdir/include $CPPFLAGS"
3451 AC_CHECK_SIZEOF(curl_off_t, unused , [
3452 #include <curl/system.h>
3453 ])
3454 CPPFLAGS=$o
3455
3456 AC_CHECK_TYPE(long long,
3457    [AC_DEFINE(HAVE_LONGLONG, 1,
3458       [Define to 1 if the compiler supports the 'long long' data type.])]
3459    longlong="yes"
3460 )
3461
3462 if test "xyes" = "x$longlong"; then
3463   AC_MSG_CHECKING([if numberLL works])
3464   AC_COMPILE_IFELSE([
3465     AC_LANG_PROGRAM([[
3466     ]],[[
3467       long long val = 1000LL;
3468     ]])
3469   ],[
3470     AC_MSG_RESULT([yes])
3471     AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
3472   ],[
3473     AC_MSG_RESULT([no])
3474   ])
3475 fi
3476
3477
3478 # check for ssize_t
3479 AC_CHECK_TYPE(ssize_t, ,
3480    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
3481
3482 # check for bool type
3483 AC_CHECK_TYPE([bool],[
3484   AC_DEFINE(HAVE_BOOL_T, 1,
3485     [Define to 1 if bool is an available type.])
3486 ], ,[
3487 #ifdef HAVE_SYS_TYPES_H
3488 #include <sys/types.h>
3489 #endif
3490 #ifdef HAVE_STDBOOL_H
3491 #include <stdbool.h>
3492 #endif
3493 ])
3494
3495 AC_MSG_CHECKING([if time_t is unsigned])
3496 AC_RUN_IFELSE([
3497   AC_LANG_SOURCE([[
3498   #include <time.h>
3499   #include <limits.h>
3500   time_t t = -1;
3501   return (t > 0);
3502   ]])] ,[
3503   AC_MSG_RESULT([yes])
3504   AC_DEFINE(HAVE_TIME_T_UNSIGNED, 1, [Define this if time_t is unsigned])
3505 ],[
3506   AC_MSG_RESULT([no])
3507 ],[
3508   dnl cross-compiling, most systems are unsigned
3509   AC_MSG_RESULT([no])
3510 ])
3511
3512 CURL_CONFIGURE_CURL_SOCKLEN_T
3513
3514 CURL_CONFIGURE_PULL_SYS_POLL
3515
3516 TYPE_IN_ADDR_T
3517
3518 TYPE_SOCKADDR_STORAGE
3519
3520 TYPE_SIG_ATOMIC_T
3521
3522 AC_TYPE_SIGNAL
3523
3524 CURL_CHECK_FUNC_SELECT
3525
3526 CURL_CHECK_FUNC_RECV
3527 CURL_CHECK_FUNC_SEND
3528 CURL_CHECK_MSG_NOSIGNAL
3529
3530 CURL_CHECK_FUNC_ALARM
3531 CURL_CHECK_FUNC_BASENAME
3532 CURL_CHECK_FUNC_CLOSESOCKET
3533 CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
3534 CURL_CHECK_FUNC_CONNECT
3535 CURL_CHECK_FUNC_FCNTL
3536 CURL_CHECK_FUNC_FDOPEN
3537 CURL_CHECK_FUNC_FREEADDRINFO
3538 CURL_CHECK_FUNC_FREEIFADDRS
3539 CURL_CHECK_FUNC_FSETXATTR
3540 CURL_CHECK_FUNC_FTRUNCATE
3541 CURL_CHECK_FUNC_GETADDRINFO
3542 CURL_CHECK_FUNC_GAI_STRERROR
3543 CURL_CHECK_FUNC_GETHOSTBYADDR
3544 CURL_CHECK_FUNC_GETHOSTBYADDR_R
3545 CURL_CHECK_FUNC_GETHOSTBYNAME
3546 CURL_CHECK_FUNC_GETHOSTBYNAME_R
3547 CURL_CHECK_FUNC_GETHOSTNAME
3548 CURL_CHECK_FUNC_GETIFADDRS
3549 CURL_CHECK_FUNC_GETSERVBYPORT_R
3550 CURL_CHECK_FUNC_GMTIME_R
3551 CURL_CHECK_FUNC_INET_NTOA_R
3552 CURL_CHECK_FUNC_INET_NTOP
3553 CURL_CHECK_FUNC_INET_PTON
3554 CURL_CHECK_FUNC_IOCTL
3555 CURL_CHECK_FUNC_IOCTLSOCKET
3556 CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
3557 CURL_CHECK_FUNC_LOCALTIME_R
3558 CURL_CHECK_FUNC_MEMRCHR
3559 CURL_CHECK_FUNC_POLL
3560 CURL_CHECK_FUNC_SETSOCKOPT
3561 CURL_CHECK_FUNC_SIGACTION
3562 CURL_CHECK_FUNC_SIGINTERRUPT
3563 CURL_CHECK_FUNC_SIGNAL
3564 CURL_CHECK_FUNC_SIGSETJMP
3565 CURL_CHECK_FUNC_SOCKET
3566 CURL_CHECK_FUNC_SOCKETPAIR
3567 CURL_CHECK_FUNC_STRCASECMP
3568 CURL_CHECK_FUNC_STRCMPI
3569 CURL_CHECK_FUNC_STRDUP
3570 CURL_CHECK_FUNC_STRERROR_R
3571 CURL_CHECK_FUNC_STRICMP
3572 CURL_CHECK_FUNC_STRNCASECMP
3573 CURL_CHECK_FUNC_STRNCMPI
3574 CURL_CHECK_FUNC_STRNICMP
3575 CURL_CHECK_FUNC_STRSTR
3576 CURL_CHECK_FUNC_STRTOK_R
3577 CURL_CHECK_FUNC_STRTOLL
3578 CURL_CHECK_FUNC_WRITEV
3579
3580 case $host in
3581   *msdosdjgpp)
3582      ac_cv_func_pipe=no
3583      skipcheck_pipe=yes
3584      AC_MSG_NOTICE([skip check for pipe on msdosdjgpp])
3585     ;;
3586 esac
3587
3588 AC_CHECK_FUNCS([geteuid \
3589   getpass_r \
3590   getppid \
3591   getpwuid \
3592   getpwuid_r \
3593   getrlimit \
3594   gettimeofday \
3595   if_nametoindex \
3596   mach_absolute_time \
3597   pipe \
3598   setlocale \
3599   setmode \
3600   setrlimit \
3601   utime \
3602   utimes
3603 ],[
3604 ],[
3605   func="$ac_func"
3606   eval skipcheck=\$skipcheck_$func
3607   if test "x$skipcheck" != "xyes"; then
3608     AC_MSG_CHECKING([deeper for $func])
3609     AC_LINK_IFELSE([
3610       AC_LANG_PROGRAM([[
3611       ]],[[
3612         $func ();
3613       ]])
3614     ],[
3615       AC_MSG_RESULT([yes])
3616       eval "ac_cv_func_$func=yes"
3617       AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
3618         [Define to 1 if you have the $func function.])
3619     ],[
3620       AC_MSG_RESULT([but still no])
3621     ])
3622   fi
3623 ])
3624
3625 dnl Check if the getnameinfo function is available
3626 dnl and get the types of five of its arguments.
3627 CURL_CHECK_FUNC_GETNAMEINFO
3628
3629 if test "$ipv6" = "yes"; then
3630   if test "$curl_cv_func_getaddrinfo" = "yes"; then
3631     AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
3632     IPV6_ENABLED=1
3633     AC_SUBST(IPV6_ENABLED)
3634   fi
3635   CURL_CHECK_NI_WITHSCOPEID
3636 fi
3637
3638 CURL_CHECK_NONBLOCKING_SOCKET
3639
3640 dnl ************************************************************
3641 dnl nroff tool stuff
3642 dnl
3643
3644 AC_PATH_PROG( PERL, perl, ,
3645   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
3646 AC_SUBST(PERL)
3647
3648 AC_PATH_PROGS( NROFF, gnroff nroff, ,
3649   $PATH:/usr/bin/:/usr/local/bin )
3650 AC_SUBST(NROFF)
3651
3652 if test -n "$NROFF"; then
3653   dnl only check for nroff options if an nroff command was found
3654
3655   AC_MSG_CHECKING([how to use *nroff to get plain text from man pages])
3656   MANOPT="-man"
3657   mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
3658   if test -z "$mancheck"; then
3659     MANOPT="-mandoc"
3660    mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
3661     if test -z "$mancheck"; then
3662       MANOPT=""
3663       AC_MSG_RESULT([failed])
3664       AC_MSG_WARN([found no *nroff option to get plaintext from man pages])
3665     else
3666       AC_MSG_RESULT([$MANOPT])
3667     fi
3668   else
3669     AC_MSG_RESULT([$MANOPT])
3670   fi
3671   AC_SUBST(MANOPT)
3672 fi
3673
3674 if test -z "$MANOPT"
3675 then
3676   dnl if no nroff tool was found, or no option that could convert man pages
3677   dnl was found, then disable the built-in manual stuff
3678   AC_MSG_WARN([disabling built-in manual])
3679   USE_MANUAL="no";
3680 fi
3681
3682 dnl *************************************************************************
3683 dnl If the manual variable still is set, then we go with providing a built-in
3684 dnl manual
3685
3686 if test "$USE_MANUAL" = "1"; then
3687   AC_DEFINE(USE_MANUAL, 1, [If you want to build curl with the built-in manual])
3688   curl_manual_msg="enabled"
3689 fi
3690
3691 dnl set variable for use in automakefile(s)
3692 AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1)
3693
3694 CURL_CHECK_LIB_ARES
3695 AM_CONDITIONAL(USE_EMBEDDED_ARES, test x$embedded_ares = xyes)
3696
3697 if test "x$curl_cv_native_windows" != "xyes" &&
3698    test "x$enable_shared" = "xyes"; then
3699   build_libhostname=yes
3700 else
3701   build_libhostname=no
3702 fi
3703 AM_CONDITIONAL(BUILD_LIBHOSTNAME, test x$build_libhostname = xyes)
3704
3705 if test "x$want_ares" != xyes; then
3706   CURL_CHECK_OPTION_THREADED_RESOLVER
3707 fi
3708
3709 dnl ************************************************************
3710 dnl disable POSIX threads
3711 dnl
3712 AC_MSG_CHECKING([whether to use POSIX threads for threaded resolver])
3713 AC_ARG_ENABLE(pthreads,
3714 AC_HELP_STRING([--enable-pthreads],
3715                [Enable POSIX threads (default for threaded resolver)])
3716 AC_HELP_STRING([--disable-pthreads],[Disable POSIX threads]),
3717 [ case "$enableval" in
3718   no)  AC_MSG_RESULT(no)
3719        want_pthreads=no
3720        ;;
3721   *)   AC_MSG_RESULT(yes)
3722        want_pthreads=yes
3723        ;;
3724   esac ], [
3725        AC_MSG_RESULT(auto)
3726        want_pthreads=auto
3727        ]
3728 )
3729
3730 dnl turn off pthreads if rt is disabled
3731 if test "$want_pthreads" != "no"; then
3732   if test "$want_pthreads" = "yes" && test "$dontwant_rt" = "yes"; then
3733     AC_MSG_ERROR([options --enable-pthreads and --disable-rt are mutually exclusive])
3734   fi
3735   if test "$dontwant_rt" != "no"; then
3736     dnl if --enable-pthreads was explicit then warn it's being ignored
3737     if test "$want_pthreads" = "yes"; then
3738       AC_MSG_WARN([--enable-pthreads Ignored since librt is disabled.])
3739     fi
3740     want_pthreads=no
3741   fi
3742 fi
3743
3744 dnl turn off pthreads if no threaded resolver
3745 if test "$want_pthreads" != "no" && test "$want_thres" != "yes"; then
3746   want_pthreads=no
3747 fi
3748
3749 dnl detect pthreads
3750 if test "$want_pthreads" != "no"; then
3751   AC_CHECK_HEADER(pthread.h,
3752     [ AC_DEFINE(HAVE_PTHREAD_H, 1, [if you have <pthread.h>])
3753       save_CFLAGS="$CFLAGS"
3754
3755       dnl first check for function without lib
3756       AC_CHECK_FUNC(pthread_create, [USE_THREADS_POSIX=1] )
3757
3758       dnl if it wasn't found without lib, search for it in pthread lib
3759       if test "$USE_THREADS_POSIX" != "1"
3760       then
3761         CFLAGS="$CFLAGS -pthread"
3762         AC_CHECK_LIB(pthread, pthread_create,
3763                      [USE_THREADS_POSIX=1],
3764                      [ CFLAGS="$save_CFLAGS"])
3765       fi
3766
3767       if test "x$USE_THREADS_POSIX" = "x1"
3768       then
3769         AC_DEFINE(USE_THREADS_POSIX, 1, [if you want POSIX threaded DNS lookup])
3770         curl_res_msg="POSIX threaded"
3771       fi
3772   ])
3773 fi
3774
3775 dnl threaded resolver check
3776 if test "$want_thres" = "yes" && test "x$USE_THREADS_POSIX" != "x1"; then
3777   if test "$want_pthreads" = "yes"; then
3778     AC_MSG_ERROR([--enable-pthreads but pthreads was not found])
3779   fi
3780   dnl If native Windows fallback on Win32 threads since no POSIX threads
3781   if test "$curl_cv_native_windows" = "yes"; then
3782     USE_THREADS_WIN32=1
3783     AC_DEFINE(USE_THREADS_WIN32, 1, [if you want Win32 threaded DNS lookup])
3784     curl_res_msg="Win32 threaded"
3785   else
3786     AC_MSG_ERROR([Threaded resolver enabled but no thread library found])
3787   fi
3788 fi
3789
3790 dnl ************************************************************
3791 dnl disable verbose text strings
3792 dnl
3793 AC_MSG_CHECKING([whether to enable verbose strings])
3794 AC_ARG_ENABLE(verbose,
3795 AC_HELP_STRING([--enable-verbose],[Enable verbose strings])
3796 AC_HELP_STRING([--disable-verbose],[Disable verbose strings]),
3797 [ case "$enableval" in
3798   no)
3799        AC_MSG_RESULT(no)
3800        AC_DEFINE(CURL_DISABLE_VERBOSE_STRINGS, 1, [to disable verbose strings])
3801        curl_verbose_msg="no"
3802        ;;
3803   *)   AC_MSG_RESULT(yes)
3804        ;;
3805   esac ],
3806        AC_MSG_RESULT(yes)
3807 )
3808
3809 dnl ************************************************************
3810 dnl enable SSPI support
3811 dnl
3812 AC_MSG_CHECKING([whether to enable SSPI support (Windows native builds only)])
3813 AC_ARG_ENABLE(sspi,
3814 AC_HELP_STRING([--enable-sspi],[Enable SSPI])
3815 AC_HELP_STRING([--disable-sspi],[Disable SSPI]),
3816 [ case "$enableval" in
3817   yes)
3818        if test "$curl_cv_native_windows" = "yes"; then
3819          AC_MSG_RESULT(yes)
3820          AC_DEFINE(USE_WINDOWS_SSPI, 1, [to enable SSPI support])
3821          AC_SUBST(USE_WINDOWS_SSPI, [1])
3822          curl_sspi_msg="enabled"
3823        else
3824          AC_MSG_RESULT(no)
3825          AC_MSG_WARN([--enable-sspi Ignored. Only supported on native Windows builds.])
3826        fi
3827        ;;
3828   *)
3829        if test "x$WINSSL_ENABLED" = "x1"; then
3830          # --with-winssl implies --enable-sspi
3831          AC_MSG_RESULT(yes)
3832        else
3833          AC_MSG_RESULT(no)
3834        fi
3835        ;;
3836   esac ],
3837        if test "x$WINSSL_ENABLED" = "x1"; then
3838          # --with-winssl implies --enable-sspi
3839          AC_MSG_RESULT(yes)
3840        else
3841          AC_MSG_RESULT(no)
3842        fi
3843 )
3844
3845 dnl ************************************************************
3846 dnl disable cryptographic authentication
3847 dnl
3848 AC_MSG_CHECKING([whether to enable cryptographic authentication methods])
3849 AC_ARG_ENABLE(crypto-auth,
3850 AC_HELP_STRING([--enable-crypto-auth],[Enable cryptographic authentication])
3851 AC_HELP_STRING([--disable-crypto-auth],[Disable cryptographic authentication]),
3852 [ case "$enableval" in
3853   no)
3854        AC_MSG_RESULT(no)
3855        AC_DEFINE(CURL_DISABLE_CRYPTO_AUTH, 1, [to disable cryptographic authentication])
3856        CURL_DISABLE_CRYPTO_AUTH=1
3857        ;;
3858   *)   AC_MSG_RESULT(yes)
3859        ;;
3860   esac ],
3861        AC_MSG_RESULT(yes)
3862 )
3863
3864 CURL_CHECK_OPTION_NTLM_WB
3865
3866 CURL_CHECK_NTLM_WB
3867
3868 dnl ************************************************************
3869 dnl disable TLS-SRP authentication
3870 dnl
3871 AC_MSG_CHECKING([whether to enable TLS-SRP authentication])
3872 AC_ARG_ENABLE(tls-srp,
3873 AC_HELP_STRING([--enable-tls-srp],[Enable TLS-SRP authentication])
3874 AC_HELP_STRING([--disable-tls-srp],[Disable TLS-SRP authentication]),
3875 [ case "$enableval" in
3876   no)
3877        AC_MSG_RESULT(no)
3878        AC_DEFINE(CURL_DISABLE_TLS_SRP, 1, [to disable TLS-SRP authentication])
3879        want_tls_srp=no
3880        ;;
3881   *)   AC_MSG_RESULT(yes)
3882        want_tls_srp=yes
3883        ;;
3884   esac ],
3885        AC_MSG_RESULT(yes)
3886        want_tls_srp=yes
3887 )
3888
3889 if test "$want_tls_srp" = "yes" && ( test "x$HAVE_GNUTLS_SRP" = "x1" || test "x$HAVE_OPENSSL_SRP" = "x1") ; then
3890    AC_DEFINE(USE_TLS_SRP, 1, [Use TLS-SRP authentication])
3891    USE_TLS_SRP=1
3892    curl_tls_srp_msg="enabled"
3893 fi
3894
3895 dnl ************************************************************
3896 dnl disable Unix domain sockets support
3897 dnl
3898 AC_MSG_CHECKING([whether to enable Unix domain sockets])
3899 AC_ARG_ENABLE(unix-sockets,
3900 AC_HELP_STRING([--enable-unix-sockets],[Enable Unix domain sockets])
3901 AC_HELP_STRING([--disable-unix-sockets],[Disable Unix domain sockets]),
3902 [ case "$enableval" in
3903   no)  AC_MSG_RESULT(no)
3904        want_unix_sockets=no
3905        ;;
3906   *)   AC_MSG_RESULT(yes)
3907        want_unix_sockets=yes
3908        ;;
3909   esac ], [
3910        AC_MSG_RESULT(auto)
3911        want_unix_sockets=auto
3912        ]
3913 )
3914 if test "x$want_unix_sockets" != "xno"; then
3915   AC_CHECK_MEMBER([struct sockaddr_un.sun_path], [
3916     AC_DEFINE(USE_UNIX_SOCKETS, 1, [Use Unix domain sockets])
3917     AC_SUBST(USE_UNIX_SOCKETS, [1])
3918     curl_unix_sockets_msg="enabled"
3919   ], [
3920     if test "x$want_unix_sockets" = "xyes"; then
3921       AC_MSG_ERROR([--enable-unix-sockets is not available on this platform!])
3922     fi
3923   ], [
3924     #include <sys/un.h>
3925   ])
3926 fi
3927
3928 dnl ************************************************************
3929 dnl disable cookies support
3930 dnl
3931 AC_MSG_CHECKING([whether to enable support for cookies])
3932 AC_ARG_ENABLE(cookies,
3933 AC_HELP_STRING([--enable-cookies],[Enable cookies support])
3934 AC_HELP_STRING([--disable-cookies],[Disable cookies support]),
3935 [ case "$enableval" in
3936   no)
3937        AC_MSG_RESULT(no)
3938        AC_DEFINE(CURL_DISABLE_COOKIES, 1, [to disable cookies support])
3939        ;;
3940   *)   AC_MSG_RESULT(yes)
3941        ;;
3942   esac ],
3943        AC_MSG_RESULT(yes)
3944 )
3945
3946 dnl ************************************************************
3947 dnl hiding of library internal symbols
3948 dnl
3949 CURL_CONFIGURE_SYMBOL_HIDING
3950
3951 dnl
3952 dnl All the library dependencies put into $LIB apply to libcurl only.
3953 dnl
3954 LIBCURL_LIBS=$LIBS
3955
3956 AC_SUBST(LIBCURL_LIBS)
3957 AC_SUBST(CURL_NETWORK_LIBS)
3958 AC_SUBST(CURL_NETWORK_AND_TIME_LIBS)
3959
3960 dnl BLANK_AT_MAKETIME may be used in our Makefile.am files to blank
3961 dnl LIBS variable used in generated makefile at makefile processing
3962 dnl time. Doing this functionally prevents LIBS from being used for
3963 dnl all link targets in given makefile.
3964 BLANK_AT_MAKETIME=
3965 AC_SUBST(BLANK_AT_MAKETIME)
3966
3967 AM_CONDITIONAL(CROSSCOMPILING, test x$cross_compiling = xyes)
3968
3969 dnl yes or no
3970 ENABLE_SHARED="$enable_shared"
3971 AC_SUBST(ENABLE_SHARED)
3972
3973 dnl to let curl-config output the static libraries correctly
3974 ENABLE_STATIC="$enable_static"
3975 AC_SUBST(ENABLE_STATIC)
3976
3977
3978 dnl
3979 dnl For keeping supported features and protocols also in pkg-config file
3980 dnl since it is more cross-compile friendly than curl-config
3981 dnl
3982
3983 if test "x$OPENSSL_ENABLED" = "x1"; then
3984   SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
3985 elif test -n "$SSL_ENABLED"; then
3986   SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
3987 fi
3988 if test "x$IPV6_ENABLED" = "x1"; then
3989   SUPPORT_FEATURES="$SUPPORT_FEATURES IPv6"
3990 fi
3991 if test "x$USE_UNIX_SOCKETS" = "x1"; then
3992   SUPPORT_FEATURES="$SUPPORT_FEATURES UnixSockets"
3993 fi
3994 if test "x$HAVE_LIBZ" = "x1"; then
3995   SUPPORT_FEATURES="$SUPPORT_FEATURES libz"
3996 fi
3997 if test "x$HAVE_BROTLI" = "x1"; then
3998   SUPPORT_FEATURES="$SUPPORT_FEATURES brotli"
3999 fi
4000 if test "x$USE_ARES" = "x1" -o "x$USE_THREADS_POSIX" = "x1" \
4001                             -o "x$USE_THREADS_WIN32" = "x1"; then
4002   SUPPORT_FEATURES="$SUPPORT_FEATURES AsynchDNS"
4003 fi
4004 if test "x$IDN_ENABLED" = "x1"; then
4005   SUPPORT_FEATURES="$SUPPORT_FEATURES IDN"
4006 fi
4007 if test "x$USE_WINDOWS_SSPI" = "x1"; then
4008   SUPPORT_FEATURES="$SUPPORT_FEATURES SSPI"
4009 fi
4010
4011 if test "x$HAVE_GSSAPI" = "x1"; then
4012   SUPPORT_FEATURES="$SUPPORT_FEATURES GSS-API"
4013 fi
4014
4015 if test "x$curl_psl_msg" = "xyes"; then
4016   SUPPORT_FEATURES="$SUPPORT_FEATURES PSL"
4017 fi
4018
4019 if test "x$CURL_DISABLE_CRYPTO_AUTH" != "x1" -a \
4020     \( "x$HAVE_GSSAPI" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \); then
4021   SUPPORT_FEATURES="$SUPPORT_FEATURES SPNEGO"
4022 fi
4023
4024 if test "x$CURL_DISABLE_CRYPTO_AUTH" != "x1" -a \
4025     \( "x$HAVE_GSSAPI" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \); then
4026   SUPPORT_FEATURES="$SUPPORT_FEATURES Kerberos"
4027 fi
4028
4029 if test "x$CURL_DISABLE_CRYPTO_AUTH" != "x1"; then
4030   if test "x$OPENSSL_ENABLED" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \
4031       -o "x$GNUTLS_ENABLED" = "x1" -o "x$MBEDTLS_ENABLED" = "x1" \
4032       -o "x$NSS_ENABLED" = "x1" -o "x$DARWINSSL_ENABLED" = "x1"; then
4033     SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM"
4034
4035     if test "x$CURL_DISABLE_HTTP" != "x1" -a \
4036         "x$NTLM_WB_ENABLED" = "x1"; then
4037       SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM_WB"
4038     fi
4039   fi
4040 fi
4041
4042 if test "x$USE_TLS_SRP" = "x1"; then
4043   SUPPORT_FEATURES="$SUPPORT_FEATURES TLS-SRP"
4044 fi
4045
4046 if test "x$USE_NGHTTP2" = "x1"; then
4047   SUPPORT_FEATURES="$SUPPORT_FEATURES HTTP2"
4048 fi
4049
4050 if test "x$CURL_WITH_MULTI_SSL" = "x1"; then
4051   SUPPORT_FEATURES="$SUPPORT_FEATURES MultiSSL"
4052 fi
4053
4054 if test "x$OPENSSL_ENABLED" = "x1" -o "x$GNUTLS_ENABLED" = "x1" \
4055     -o "x$NSS_ENABLED" = "x1"; then
4056   SUPPORT_FEATURES="$SUPPORT_FEATURES HTTPS-proxy"
4057 fi
4058
4059 AC_SUBST(SUPPORT_FEATURES)
4060
4061 dnl For supported protocols in pkg-config file
4062 if test "x$CURL_DISABLE_HTTP" != "x1"; then
4063   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTP"
4064   if test "x$SSL_ENABLED" = "x1"; then
4065     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTPS"
4066   fi
4067 fi
4068 if test "x$CURL_DISABLE_FTP" != "x1"; then
4069   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTP"
4070   if test "x$SSL_ENABLED" = "x1"; then
4071     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTPS"
4072   fi
4073 fi
4074 if test "x$CURL_DISABLE_FILE" != "x1"; then
4075   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FILE"
4076 fi
4077 if test "x$CURL_DISABLE_TELNET" != "x1"; then
4078   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TELNET"
4079 fi
4080 if test "x$CURL_DISABLE_LDAP" != "x1"; then
4081   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAP"
4082   if test "x$CURL_DISABLE_LDAPS" != "x1"; then
4083     if (test "x$USE_OPENLDAP" = "x1" && test "x$SSL_ENABLED" = "x1") ||
4084       (test "x$USE_OPENLDAP" != "x1"  && test "x$HAVE_LDAP_SSL" = "x1"); then
4085       SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAPS"
4086     fi
4087   fi
4088 fi
4089 if test "x$CURL_DISABLE_DICT" != "x1"; then
4090   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS DICT"
4091 fi
4092 if test "x$CURL_DISABLE_TFTP" != "x1"; then
4093   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TFTP"
4094 fi
4095 if test "x$CURL_DISABLE_GOPHER" != "x1"; then
4096   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS GOPHER"
4097 fi
4098 if test "x$CURL_DISABLE_POP3" != "x1"; then
4099   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3"
4100   if test "x$SSL_ENABLED" = "x1"; then
4101     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3S"
4102   fi
4103 fi
4104 if test "x$CURL_DISABLE_IMAP" != "x1"; then
4105   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAP"
4106   if test "x$SSL_ENABLED" = "x1"; then
4107     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAPS"
4108   fi
4109 fi
4110 if test "x$CURL_DISABLE_SMB" != "x1" \
4111     -a "x$CURL_DISABLE_CRYPTO_AUTH" != "x1" \
4112     -a \( "x$OPENSSL_ENABLED" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \
4113       -o "x$GNUTLS_ENABLED" = "x1" -o "x$MBEDTLS_ENABLED" = "x1" \
4114       -o "x$NSS_ENABLED" = "x1" -o "x$DARWINSSL_ENABLED" = "x1" \); then
4115   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMB"
4116   if test "x$SSL_ENABLED" = "x1"; then
4117     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMBS"
4118   fi
4119 fi
4120 if test "x$CURL_DISABLE_SMTP" != "x1"; then
4121   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTP"
4122   if test "x$SSL_ENABLED" = "x1"; then
4123     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTPS"
4124   fi
4125 fi
4126 if test "x$USE_LIBSSH2" = "x1"; then
4127   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
4128   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
4129 fi
4130 if test "x$USE_LIBSSH" = "x1"; then
4131   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
4132   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
4133 fi
4134 if test "x$CURL_DISABLE_RTSP" != "x1"; then
4135   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTSP"
4136 fi
4137 if test "x$USE_LIBRTMP" = "x1"; then
4138   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTMP"
4139 fi
4140
4141 dnl replace spaces with newlines
4142 dnl sort the lines
4143 dnl replace the newlines back to spaces
4144 SUPPORT_PROTOCOLS=`echo $SUPPORT_PROTOCOLS | tr ' ' '\012' | sort | tr '\012' ' '`
4145
4146 AC_SUBST(SUPPORT_PROTOCOLS)
4147
4148 dnl squeeze whitespace out of some variables
4149
4150 squeeze CFLAGS
4151 squeeze CPPFLAGS
4152 squeeze DEFS
4153 squeeze LDFLAGS
4154 squeeze LIBS
4155
4156 squeeze LIBCURL_LIBS
4157 squeeze CURL_NETWORK_LIBS
4158 squeeze CURL_NETWORK_AND_TIME_LIBS
4159
4160 squeeze SUPPORT_FEATURES
4161 squeeze SUPPORT_PROTOCOLS
4162
4163 XC_CHECK_BUILD_FLAGS
4164
4165 SSL_BACKENDS=${ssl_backends}
4166 AC_SUBST(SSL_BACKENDS)
4167
4168 if test "x$want_curldebug_assumed" = "xyes" &&
4169   test "x$want_curldebug" = "xyes" && test "x$USE_ARES" = "x1"; then
4170   ac_configure_args="$ac_configure_args --enable-curldebug"
4171 fi
4172
4173 AC_CONFIG_FILES([Makefile \
4174            docs/Makefile \
4175            docs/examples/Makefile \
4176            docs/libcurl/Makefile \
4177            docs/libcurl/opts/Makefile \
4178            docs/cmdline-opts/Makefile \
4179            include/Makefile \
4180            include/curl/Makefile \
4181            src/Makefile \
4182            lib/Makefile \
4183            scripts/Makefile \
4184            lib/libcurl.vers \
4185            tests/Makefile \
4186            tests/certs/Makefile \
4187            tests/certs/scripts/Makefile \
4188            tests/data/Makefile \
4189            tests/server/Makefile \
4190            tests/libtest/Makefile \
4191            tests/unit/Makefile \
4192            packages/Makefile \
4193            packages/Win32/Makefile \
4194            packages/Win32/cygwin/Makefile \
4195            packages/Linux/Makefile \
4196            packages/Linux/RPM/Makefile \
4197            packages/Linux/RPM/curl.spec \
4198            packages/Linux/RPM/curl-ssl.spec \
4199            packages/Solaris/Makefile \
4200            packages/EPM/curl.list \
4201            packages/EPM/Makefile \
4202            packages/vms/Makefile \
4203            packages/AIX/Makefile \
4204            packages/AIX/RPM/Makefile \
4205            packages/AIX/RPM/curl.spec \
4206            curl-config \
4207            libcurl.pc
4208 ])
4209 AC_OUTPUT
4210
4211 CURL_GENERATE_CONFIGUREHELP_PM
4212
4213 XC_AMEND_DISTCLEAN([lib src tests/unit tests/server tests/libtest docs/examples])
4214
4215 AC_MSG_NOTICE([Configured to build curl/libcurl:
4216
4217   curl version:     ${CURLVERSION}
4218   Host setup:       ${host}
4219   Install prefix:   ${prefix}
4220   Compiler:         ${CC}
4221   SSL support:      ${curl_ssl_msg}
4222   SSH support:      ${curl_ssh_msg}
4223   zlib support:     ${curl_zlib_msg}
4224   brotli support:   ${curl_brotli_msg}
4225   GSS-API support:  ${curl_gss_msg}
4226   TLS-SRP support:  ${curl_tls_srp_msg}
4227   resolver:         ${curl_res_msg}
4228   IPv6 support:     ${curl_ipv6_msg}
4229   Unix sockets support: ${curl_unix_sockets_msg}
4230   IDN support:      ${curl_idn_msg}
4231   Build libcurl:    Shared=${enable_shared}, Static=${enable_static}
4232   Built-in manual:  ${curl_manual_msg}
4233   --libcurl option: ${curl_libcurl_msg}
4234   Verbose errors:   ${curl_verbose_msg}
4235   SSPI support:     ${curl_sspi_msg}
4236   ca cert bundle:   ${ca}${ca_warning}
4237   ca cert path:     ${capath}${capath_warning}
4238   ca fallback:      ${with_ca_fallback}
4239   LDAP support:     ${curl_ldap_msg}
4240   LDAPS support:    ${curl_ldaps_msg}
4241   RTSP support:     ${curl_rtsp_msg}
4242   RTMP support:     ${curl_rtmp_msg}
4243   metalink support: ${curl_mtlnk_msg}
4244   PSL support:      ${curl_psl_msg}
4245   HTTP2 support:    ${curl_h2_msg}
4246   Protocols:        ${SUPPORT_PROTOCOLS}
4247 ])