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