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