Merge branch 'upstream' into tizen
[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-"$ac_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     ac_cv_header_winsock_h="no"
352     ac_cv_header_winsock2_h="no"
353     ac_cv_header_ws2tcpip_h="no"
354     ac_cv_header_winldap_h="no"
355     ac_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 "$ac_cv_header_windows_h" = "yes"; then
746     if test "$ac_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 "$ac_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 dnl resolve lib?
855 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
856
857 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
858   AC_CHECK_LIB(resolve, strcasecmp,
859               [LIBS="-lresolve $LIBS"],
860                ,
861                -lnsl)
862 fi
863 ac_cv_func_strcasecmp="no"
864
865 CURL_CHECK_LIBS_CONNECT
866
867 CURL_NETWORK_LIBS=$LIBS
868
869 dnl **********************************************************************
870 dnl In case that function clock_gettime with monotonic timer is available,
871 dnl check for additional required libraries.
872 dnl **********************************************************************
873 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
874
875 dnl **********************************************************************
876 dnl The preceding library checks are all potentially useful for test
877 dnl servers and libtest cases which require networking and clock_gettime
878 dnl support.  Save the list of required libraries at this point for use
879 dnl while linking those test servers and programs.
880 dnl **********************************************************************
881 CURL_NETWORK_AND_TIME_LIBS=$LIBS
882
883 dnl **********************************************************************
884 dnl Check for the presence of ZLIB libraries and headers
885 dnl **********************************************************************
886
887 dnl Check for & handle argument to --with-zlib.
888
889 clean_CPPFLAGS=$CPPFLAGS
890 clean_LDFLAGS=$LDFLAGS
891 clean_LIBS=$LIBS
892 ZLIB_LIBS=""
893 AC_ARG_WITH(zlib,
894 AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH])
895 AC_HELP_STRING([--without-zlib],[disable use of zlib]),
896                [OPT_ZLIB="$withval"])
897
898 if test "$OPT_ZLIB" = "no" ; then
899     AC_MSG_WARN([zlib disabled])
900 else
901   if test "$OPT_ZLIB" = "yes" ; then
902     OPT_ZLIB=""
903   fi
904
905   if test -z "$OPT_ZLIB" ; then
906     dnl check for the lib first without setting any new path, since many
907     dnl people have it in the default path
908
909     AC_CHECK_LIB(z, inflateEnd,
910                    dnl libz found, set the variable
911                    [HAVE_LIBZ="1"
912                     LIBS="-lz $LIBS"],
913                    dnl if no lib found, try /usr/local
914                    [OPT_ZLIB="/usr/local"])
915
916   fi
917
918   dnl Add a nonempty path to the compiler flags
919   if test -n "$OPT_ZLIB"; then
920      CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
921      LDFLAGS="$LDFLAGS -L$OPT_ZLIB/lib$libsuff"
922   fi
923
924   AC_CHECK_HEADER(zlib.h,
925     [
926     dnl zlib.h was found
927     HAVE_ZLIB_H="1"
928     dnl if the lib wasn't found already, try again with the new paths
929     if test "$HAVE_LIBZ" != "1"; then
930       AC_CHECK_LIB(z, gzread,
931                    [
932                    dnl the lib was found!
933                    HAVE_LIBZ="1"
934                    LIBS="-lz $LIBS"
935                    ],
936                    [ CPPFLAGS=$clean_CPPFLAGS
937                    LDFLAGS=$clean_LDFLAGS])
938     fi
939     ],
940     [
941       dnl zlib.h was not found, restore the flags
942       CPPFLAGS=$clean_CPPFLAGS
943       LDFLAGS=$clean_LDFLAGS]
944     )
945
946   if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
947   then
948     AC_MSG_WARN([configure found only the libz lib, not the header file!])
949     HAVE_LIBZ=""
950     CPPFLAGS=$clean_CPPFLAGS
951     LDFLAGS=$clean_LDFLAGS
952     LIBS=$clean_LIBS
953   elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
954   then
955     AC_MSG_WARN([configure found only the libz header file, not the lib!])
956     CPPFLAGS=$clean_CPPFLAGS
957     LDFLAGS=$clean_LDFLAGS
958     LIBS=$clean_LIBS
959   elif test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" = "1"
960   then
961     dnl both header and lib were found!
962     AC_SUBST(HAVE_LIBZ)
963     AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
964     AC_DEFINE(HAVE_LIBZ, 1, [if zlib is available])
965
966     ZLIB_LIBS="-lz"
967     LIBS="-lz $clean_LIBS"
968
969     dnl replace 'HAVE_LIBZ' in the automake makefile.ams
970     AMFIXLIB="1"
971     AC_MSG_NOTICE([found both libz and libz.h header])
972     curl_zlib_msg="enabled"
973   fi
974 fi
975
976 dnl set variable for use in automakefile(s)
977 AM_CONDITIONAL(HAVE_LIBZ, test x"$AMFIXLIB" = x1)
978 AC_SUBST(ZLIB_LIBS)
979
980 dnl **********************************************************************
981 dnl Check for LDAP
982 dnl **********************************************************************
983
984 LDAPLIBNAME=""
985 AC_ARG_WITH(ldap-lib,
986 AC_HELP_STRING([--with-ldap-lib=libname],[Specify name of ldap lib file]),
987  [LDAPLIBNAME="$withval"])
988
989 LBERLIBNAME=""
990 AC_ARG_WITH(lber-lib,
991 AC_HELP_STRING([--with-lber-lib=libname],[Specify name of lber lib file]),
992  [LBERLIBNAME="$withval"])
993
994 if test x$CURL_DISABLE_LDAP != x1 ; then
995
996   CURL_CHECK_HEADER_LBER
997   CURL_CHECK_HEADER_LDAP
998   CURL_CHECK_HEADER_LDAPSSL
999   CURL_CHECK_HEADER_LDAP_SSL
1000
1001   if test -z "$LDAPLIBNAME" ; then
1002     if test "$ac_cv_native_windows" = "yes"; then
1003       dnl Windows uses a single and unique LDAP library name
1004       LDAPLIBNAME="wldap32"
1005       LBERLIBNAME="no"
1006     fi
1007   fi
1008
1009   if test "$LDAPLIBNAME" ; then
1010     AC_CHECK_LIB("$LDAPLIBNAME", ldap_init,, [
1011       AC_MSG_WARN(["$LDAPLIBNAME" is not an LDAP library: LDAP disabled])
1012       AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
1013       AC_SUBST(CURL_DISABLE_LDAP, [1])
1014       AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
1015       AC_SUBST(CURL_DISABLE_LDAPS, [1])])
1016   else
1017     dnl Try to find the right ldap libraries for this system
1018     CURL_CHECK_LIBS_LDAP
1019     case X-"$curl_cv_ldap_LIBS" in
1020       X-unknown)
1021         AC_MSG_WARN([Cannot find libraries for LDAP support: LDAP disabled])
1022         AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
1023         AC_SUBST(CURL_DISABLE_LDAP, [1])
1024         AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
1025         AC_SUBST(CURL_DISABLE_LDAPS, [1])
1026         ;;
1027     esac
1028   fi
1029 fi
1030
1031 if test x$CURL_DISABLE_LDAP != x1 ; then
1032
1033   if test "$LBERLIBNAME" ; then
1034     dnl If name is "no" then don't define this library at all
1035     dnl (it's only needed if libldap.so's dependencies are broken).
1036     if test "$LBERLIBNAME" != "no" ; then
1037       AC_CHECK_LIB("$LBERLIBNAME", ber_free,, [
1038         AC_MSG_WARN(["$LBERLIBNAME" is not an LBER library: LDAP disabled])
1039         AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
1040         AC_SUBST(CURL_DISABLE_LDAP, [1])
1041         AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
1042         AC_SUBST(CURL_DISABLE_LDAPS, [1])])
1043     fi
1044   fi
1045 fi
1046
1047 if test x$CURL_DISABLE_LDAP != x1 ; then
1048   AC_CHECK_FUNCS([ldap_url_parse ldap_init_fd])
1049
1050   if test "$LDAPLIBNAME" = "wldap32"; then
1051     curl_ldap_msg="enabled (winldap)"
1052     AC_DEFINE(USE_WIN32_LDAP, 1, [Use Windows LDAP implementation])
1053   else
1054     curl_ldap_msg="enabled (OpenLDAP)"
1055     if test "x$ac_cv_func_ldap_init_fd" = "xyes"; then
1056       AC_DEFINE(USE_OPENLDAP, 1, [Use OpenLDAP-specific code])
1057       AC_SUBST(USE_OPENLDAP, [1])
1058     fi
1059   fi
1060 fi
1061
1062 if test x$CURL_DISABLE_LDAPS != x1 ; then
1063     curl_ldaps_msg="enabled"
1064 fi
1065
1066 dnl **********************************************************************
1067 dnl Checks for IPv6
1068 dnl **********************************************************************
1069
1070 AC_MSG_CHECKING([whether to enable IPv6])
1071 AC_ARG_ENABLE(ipv6,
1072 AC_HELP_STRING([--enable-ipv6],[Enable IPv6 (with IPv4) support])
1073 AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),
1074 [ case "$enableval" in
1075   no)
1076        AC_MSG_RESULT(no)
1077        ipv6=no
1078        ;;
1079   *)   AC_MSG_RESULT(yes)
1080        ipv6=yes
1081        ;;
1082   esac ],
1083
1084   AC_TRY_RUN([ /* is AF_INET6 available? */
1085 #include <sys/types.h>
1086 #ifdef HAVE_WINSOCK2_H
1087 #include <winsock2.h>
1088 #else
1089 #include <sys/socket.h>
1090 #endif
1091 #include <stdlib.h> /* for exit() */
1092 main()
1093 {
1094  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1095    exit(1);
1096  else
1097    exit(0);
1098 }
1099 ],
1100   AC_MSG_RESULT(yes)
1101   ipv6=yes,
1102   AC_MSG_RESULT(no)
1103   ipv6=no,
1104   AC_MSG_RESULT(yes)
1105   ipv6=yes
1106 ))
1107
1108 if test "$ipv6" = "yes"; then
1109   curl_ipv6_msg="enabled"
1110 fi
1111
1112 # Check if struct sockaddr_in6 have sin6_scope_id member
1113 if test "$ipv6" = yes; then
1114   AC_MSG_CHECKING([if struct sockaddr_in6 has sin6_scope_id member])
1115   AC_TRY_COMPILE([
1116 #include <sys/types.h>
1117 #ifdef HAVE_WINSOCK2_H
1118 #include <winsock2.h>
1119 #include <ws2tcpip.h>
1120 #else
1121 #include <netinet/in.h>
1122 #endif] ,
1123   struct sockaddr_in6 s; s.sin6_scope_id = 0; , have_sin6_scope_id=yes)
1124   if test "$have_sin6_scope_id" = yes; then
1125     AC_MSG_RESULT([yes])
1126     AC_DEFINE(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID, 1, [Define to 1 if struct sockaddr_in6 has the sin6_scope_id member])
1127   else
1128     AC_MSG_RESULT([no])
1129   fi
1130 fi
1131
1132 dnl **********************************************************************
1133 dnl Check if the operating system allows programs to write to their own argv[]
1134 dnl **********************************************************************
1135
1136 AC_MSG_CHECKING([if argv can be written to])
1137 AC_RUN_IFELSE([
1138   AC_LANG_SOURCE([[
1139 int main(int argc, char ** argv) {
1140     argv[0][0] = ' ';
1141     return (argv[0][0] == ' ')?0:1;
1142 }
1143   ]])
1144 ],[
1145   curl_cv_writable_argv=yes
1146 ],[
1147   curl_cv_writable_argv=no
1148 ],[
1149   curl_cv_writable_argv=cross
1150 ])
1151 case $curl_cv_writable_argv in
1152 yes)
1153         AC_DEFINE(HAVE_WRITABLE_ARGV, 1, [Define this symbol if your OS supports changing the contents of argv])
1154         AC_MSG_RESULT(yes)
1155         ;;
1156 no)
1157         AC_MSG_RESULT(no)
1158         ;;
1159 *)
1160         AC_MSG_RESULT(no)
1161         AC_MSG_WARN([the previous check could not be made default was used])
1162         ;;
1163 esac
1164
1165 dnl **********************************************************************
1166 dnl Check for GSS-API libraries
1167 dnl **********************************************************************
1168
1169 dnl check for GSS-API stuff in the /usr as default
1170
1171 GSSAPI_ROOT="/usr"
1172 AC_ARG_WITH(gssapi-includes,
1173   AC_HELP_STRING([--with-gssapi-includes=DIR],
1174                  [Specify location of GSS-API headers]),
1175   [ GSSAPI_INCS="-I$withval"
1176     want_gss="yes" ]
1177 )
1178
1179 AC_ARG_WITH(gssapi-libs,
1180   AC_HELP_STRING([--with-gssapi-libs=DIR],
1181                  [Specify location of GSS-API libs]),
1182   [ GSSAPI_LIB_DIR="-L$withval"
1183     want_gss="yes" ]
1184 )
1185
1186 AC_ARG_WITH(gssapi,
1187   AC_HELP_STRING([--with-gssapi=DIR],
1188                  [Where to look for GSS-API]), [
1189   GSSAPI_ROOT="$withval"
1190   if test x"$GSSAPI_ROOT" != xno; then
1191     want_gss="yes"
1192     if test x"$GSSAPI_ROOT" = xyes; then
1193       dnl if yes, then use default root
1194       GSSAPI_ROOT="/usr"
1195     fi
1196   fi
1197 ])
1198
1199 : ${KRB5CONFIG:="$GSSAPI_ROOT/bin/krb5-config"}
1200
1201 save_CPPFLAGS="$CPPFLAGS"
1202 AC_MSG_CHECKING([if GSS-API support is requested])
1203 if test x"$want_gss" = xyes; then
1204   AC_MSG_RESULT(yes)
1205
1206   if test -z "$GSSAPI_INCS"; then
1207      if test -n "$host_alias" -a -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then
1208         GSSAPI_INCS=`$GSSAPI_ROOT/bin/$host_alias-krb5-config --cflags gssapi`
1209      elif test -f "$KRB5CONFIG"; then
1210         GSSAPI_INCS=`$KRB5CONFIG --cflags gssapi`
1211      elif test "$GSSAPI_ROOT" != "yes"; then
1212         GSSAPI_INCS="-I$GSSAPI_ROOT/include"
1213      fi
1214   fi
1215
1216   CPPFLAGS="$CPPFLAGS $GSSAPI_INCS"
1217
1218   AC_CHECK_HEADER(gss.h,
1219     [
1220       dnl found in the given dirs
1221       AC_DEFINE(HAVE_GSSGNU, 1, [if you have GNU GSS])
1222       gnu_gss=yes
1223     ],
1224     [
1225       dnl not found, check Heimdal or MIT
1226       AC_CHECK_HEADERS([gssapi/gssapi.h], [], [not_mit=1])
1227       AC_CHECK_HEADERS(
1228         [gssapi/gssapi_generic.h gssapi/gssapi_krb5.h],
1229         [],
1230         [not_mit=1],
1231         [
1232 AC_INCLUDES_DEFAULT
1233 #ifdef HAVE_GSSAPI_GSSAPI_H
1234 #include <gssapi/gssapi.h>
1235 #endif
1236         ])
1237       if test "x$not_mit" = "x1"; then
1238         dnl MIT not found, check for Heimdal
1239         AC_CHECK_HEADER(gssapi.h,
1240             [
1241               dnl found
1242               AC_DEFINE(HAVE_GSSHEIMDAL, 1, [if you have Heimdal])
1243             ],
1244             [
1245               dnl no header found, disabling GSS
1246               want_gss=no
1247               AC_MSG_WARN(disabling GSS-API support since no header files were found)
1248             ]
1249           )
1250       else
1251         dnl MIT found
1252         AC_DEFINE(HAVE_GSSMIT, 1, [if you have MIT Kerberos])
1253         dnl check if we have a really old MIT Kerberos version (<= 1.2)
1254         AC_MSG_CHECKING([if GSS-API headers declare GSS_C_NT_HOSTBASED_SERVICE])
1255         AC_COMPILE_IFELSE([
1256           AC_LANG_PROGRAM([[
1257 #include <gssapi/gssapi.h>
1258 #include <gssapi/gssapi_generic.h>
1259 #include <gssapi/gssapi_krb5.h>
1260           ]],[[
1261             gss_import_name(
1262                             (OM_uint32 *)0,
1263                             (gss_buffer_t)0,
1264                             GSS_C_NT_HOSTBASED_SERVICE,
1265                             (gss_name_t *)0);
1266           ]])
1267         ],[
1268           AC_MSG_RESULT([yes])
1269         ],[
1270           AC_MSG_RESULT([no])
1271           AC_DEFINE(HAVE_OLD_GSSMIT, 1,
1272             [if you have an old MIT Kerberos version, lacking GSS_C_NT_HOSTBASED_SERVICE])
1273         ])
1274       fi
1275     ]
1276   )
1277 else
1278   AC_MSG_RESULT(no)
1279 fi
1280 if test x"$want_gss" = xyes; then
1281   AC_DEFINE(HAVE_GSSAPI, 1, [if you have GSS-API libraries])
1282   HAVE_GSSAPI=1
1283   curl_gss_msg="enabled (MIT Kerberos/Heimdal)"
1284
1285   if test -n "$gnu_gss"; then
1286     curl_gss_msg="enabled (GNU GSS)"
1287     LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
1288     LIBS="-lgss $LIBS"
1289   elif test -z "$GSSAPI_LIB_DIR"; then
1290      case $host in
1291      *-*-darwin*)
1292         LIBS="-lgssapi_krb5 -lresolv $LIBS"
1293         ;;
1294      *)
1295         if test -n "$host_alias" -a -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then
1296            dnl krb5-config doesn't have --libs-only-L or similar, put everything
1297            dnl into LIBS
1298            gss_libs=`$GSSAPI_ROOT/bin/$host_alias-krb5-config --libs gssapi`
1299            LIBS="$gss_libs $LIBS"
1300         elif test -f "$KRB5CONFIG"; then
1301            dnl krb5-config doesn't have --libs-only-L or similar, put everything
1302            dnl into LIBS
1303            gss_libs=`$KRB5CONFIG --libs gssapi`
1304            LIBS="$gss_libs $LIBS"
1305         else
1306            case $host in
1307            *-hp-hpux*)
1308               gss_libname="gss"
1309               ;;
1310            *)
1311               gss_libname="gssapi"
1312               ;;
1313            esac
1314
1315            if test "$GSSAPI_ROOT" != "yes"; then
1316               LDFLAGS="$LDFLAGS -L$GSSAPI_ROOT/lib$libsuff"
1317               LIBS="-l$gss_libname $LIBS"
1318            else
1319               LIBS="-l$gss_libname $LIBS"
1320            fi
1321         fi
1322         ;;
1323      esac
1324   else
1325      LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
1326      case $host in
1327      *-hp-hpux*)
1328         LIBS="-lgss $LIBS"
1329         ;;
1330      *)
1331         LIBS="-lgssapi $LIBS"
1332         ;;
1333      esac
1334   fi
1335 else
1336   CPPFLAGS="$save_CPPFLAGS"
1337 fi
1338
1339 dnl -------------------------------------------------
1340 dnl check winssl option before other SSL libraries
1341 dnl -------------------------------------------------
1342
1343 OPT_WINSSL=no
1344 AC_ARG_WITH(winssl,dnl
1345 AC_HELP_STRING([--with-winssl],[enable Windows native SSL/TLS])
1346 AC_HELP_STRING([--without-winssl], [disable Windows native SSL/TLS]),
1347   OPT_WINSSL=$withval)
1348
1349 AC_MSG_CHECKING([whether to enable Windows native SSL/TLS (Windows native builds only)])
1350 if test "$curl_ssl_msg" = "$init_ssl_msg"; then
1351   if test "x$OPT_WINSSL" != "xno"  &&
1352      test "x$ac_cv_native_windows" = "xyes"; then
1353     AC_MSG_RESULT(yes)
1354     AC_DEFINE(USE_SCHANNEL, 1, [to enable Windows native SSL/TLS support])
1355     AC_SUBST(USE_SCHANNEL, [1])
1356     curl_ssl_msg="enabled (Windows-native)"
1357     WINSSL_ENABLED=1
1358     # --with-winssl implies --enable-sspi
1359     AC_DEFINE(USE_WINDOWS_SSPI, 1, [to enable SSPI support])
1360     AC_SUBST(USE_WINDOWS_SSPI, [1])
1361     curl_sspi_msg="enabled"
1362   else
1363     AC_MSG_RESULT(no)
1364   fi
1365 else
1366   AC_MSG_RESULT(no)
1367 fi
1368
1369 OPT_DARWINSSL=no
1370 AC_ARG_WITH(darwinssl,dnl
1371 AC_HELP_STRING([--with-darwinssl],[enable iOS/Mac OS X native SSL/TLS])
1372 AC_HELP_STRING([--without-darwinssl], [disable iOS/Mac OS X native SSL/TLS]),
1373   OPT_DARWINSSL=$withval)
1374
1375 AC_MSG_CHECKING([whether to enable iOS/Mac OS X native SSL/TLS])
1376 if test "$curl_ssl_msg" = "$init_ssl_msg"; then
1377   if test "x$OPT_DARWINSSL" != "xno" &&
1378      test -d "/System/Library/Frameworks/Security.framework"; then
1379     AC_MSG_RESULT(yes)
1380     AC_DEFINE(USE_DARWINSSL, 1, [to enable iOS/Mac OS X native SSL/TLS support])
1381     AC_SUBST(USE_DARWINSSL, [1])
1382     curl_ssl_msg="enabled (iOS/Mac OS X-native)"
1383     DARWINSSL_ENABLED=1
1384     LDFLAGS="$LDFLAGS -framework CoreFoundation -framework Security"
1385   else
1386     AC_MSG_RESULT(no)
1387   fi
1388 else
1389   AC_MSG_RESULT(no)
1390 fi
1391
1392 dnl **********************************************************************
1393 dnl Check for the presence of SSL libraries and headers
1394 dnl **********************************************************************
1395
1396 dnl Default to compiler & linker defaults for SSL files & libraries.
1397 OPT_SSL=off
1398 dnl Default to no CA bundle
1399 ca="no"
1400 AC_ARG_WITH(ssl,dnl
1401 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])
1402 AC_HELP_STRING([--without-ssl], [disable OpenSSL]),
1403   OPT_SSL=$withval)
1404
1405 if test "$curl_ssl_msg" = "$init_ssl_msg" && test X"$OPT_SSL" != Xno; then
1406   dnl backup the pre-ssl variables
1407   CLEANLDFLAGS="$LDFLAGS"
1408   CLEANCPPFLAGS="$CPPFLAGS"
1409   CLEANLIBS="$LIBS"
1410
1411   dnl This is for Msys/Mingw
1412   case $host in
1413     *-*-msys* | *-*-mingw*)
1414       AC_MSG_CHECKING([for gdi32])
1415       my_ac_save_LIBS=$LIBS
1416       LIBS="-lgdi32 $LIBS"
1417       AC_TRY_LINK([#include <windef.h>
1418                    #include <wingdi.h>],
1419                    [GdiFlush();],
1420                    [ dnl worked!
1421                    AC_MSG_RESULT([yes])],
1422                    [ dnl failed, restore LIBS
1423                    LIBS=$my_ac_save_LIBS
1424                    AC_MSG_RESULT(no)]
1425                   )
1426       ;;
1427   esac
1428
1429   case "$OPT_SSL" in
1430   yes)
1431     dnl --with-ssl (without path) used
1432     if test x$cross_compiling != xyes; then
1433       dnl only do pkg-config magic when not cross-compiling
1434       PKGTEST="yes"
1435     fi
1436     PREFIX_OPENSSL=/usr/local/ssl
1437     LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
1438     ;;
1439   off)
1440     dnl no --with-ssl option given, just check default places
1441     if test x$cross_compiling != xyes; then
1442       dnl only do pkg-config magic when not cross-compiling
1443       PKGTEST="yes"
1444     fi
1445     PREFIX_OPENSSL=
1446     ;;
1447   *)
1448     dnl check the given --with-ssl spot
1449     PKGTEST="no"
1450     PREFIX_OPENSSL=$OPT_SSL
1451
1452     dnl Try pkg-config even when cross-compiling.  Since we
1453     dnl specify PKG_CONFIG_LIBDIR we're only looking where
1454     dnl the user told us to look
1455     OPENSSL_PCDIR="$OPT_SSL/lib/pkgconfig"
1456     AC_MSG_NOTICE([PKG_CONFIG_LIBDIR will be set to "$OPENSSL_PCDIR"])
1457     if test -f "$OPENSSL_PCDIR/openssl.pc"; then
1458       PKGTEST="yes"
1459     fi
1460
1461     dnl in case pkg-config comes up empty, use what we got
1462     dnl via --with-ssl
1463     LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
1464     if test "$PREFIX_OPENSSL" != "/usr" ; then
1465       SSL_LDFLAGS="-L$LIB_OPENSSL"
1466       SSL_CPPFLAGS="-I$PREFIX_OPENSSL/include"
1467     fi
1468     SSL_CPPFLAGS="$SSL_CPPFLAGS -I$PREFIX_OPENSSL/include/openssl"
1469     ;;
1470   esac
1471
1472   if test "$PKGTEST" = "yes"; then
1473
1474     CURL_CHECK_PKGCONFIG(openssl, [$OPENSSL_PCDIR])
1475
1476     if test "$PKGCONFIG" != "no" ; then
1477       SSL_LIBS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
1478         $PKGCONFIG --libs-only-l openssl 2>/dev/null`
1479
1480       SSL_LDFLAGS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
1481         $PKGCONFIG --libs-only-L openssl 2>/dev/null`
1482
1483       SSL_CPPFLAGS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
1484         $PKGCONFIG --cflags-only-I openssl 2>/dev/null`
1485
1486       AC_SUBST(SSL_LIBS)
1487       AC_MSG_NOTICE([pkg-config: SSL_LIBS: "$SSL_LIBS"])
1488       AC_MSG_NOTICE([pkg-config: SSL_LDFLAGS: "$SSL_LDFLAGS"])
1489       AC_MSG_NOTICE([pkg-config: SSL_CPPFLAGS: "$SSL_CPPFLAGS"])
1490
1491       LIB_OPENSSL=`echo $SSL_LDFLAGS | sed -e 's/-L//g'`
1492
1493       dnl use the values pkg-config reported.  This is here
1494       dnl instead of below with CPPFLAGS and LDFLAGS because we only
1495       dnl learn about this via pkg-config.  If we only have
1496       dnl the argument to --with-ssl we don't know what
1497       dnl additional libs may be necessary.  Hope that we
1498       dnl don't need any.
1499       LIBS="$SSL_LIBS $LIBS"
1500     fi
1501   fi
1502
1503   dnl finally, set flags to use SSL
1504   CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
1505   LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
1506
1507   AC_CHECK_LIB(crypto, HMAC_Update,[
1508      HAVECRYPTO="yes"
1509      LIBS="-lcrypto $LIBS"
1510      ],[
1511      LDFLAGS="$CLEANLDFLAGS -L$LIB_OPENSSL"
1512      CPPFLAGS="$CLEANCPPFLAGS -I$PREFIX_OPENSSL/include/openssl -I$PREFIX_OPENSSL/include"
1513      AC_CHECK_LIB(crypto, HMAC_Init_ex,[
1514        HAVECRYPTO="yes"
1515        LIBS="-lcrypto $LIBS"], [
1516        LDFLAGS="$CLEANLDFLAGS"
1517        CPPFLAGS="$CLEANCPPFLAGS"
1518        LIBS="$CLEANLIBS"
1519        ])
1520     ])
1521
1522
1523   if test X"$HAVECRYPTO" = X"yes"; then
1524      AC_MSG_CHECKING([OpenSSL linking without -ldl])
1525      saved_libs=$LIBS
1526      AC_TRY_LINK(
1527         [
1528           #include <openssl/evp.h>
1529         ],
1530         [
1531           SSLeay_add_all_algorithms();
1532         ],
1533         [
1534           AC_MSG_RESULT(yes)
1535           LIBS="$saved_libs"
1536         ],
1537         [
1538           AC_MSG_RESULT(no)
1539           AC_MSG_CHECKING([OpenSSL linking with -ldl])
1540           LIBS="-ldl $LIBS"
1541           AC_TRY_LINK(
1542           [
1543             #include <openssl/evp.h>
1544           ],
1545           [
1546             SSLeay_add_all_algorithms();
1547           ],
1548           [
1549             AC_MSG_RESULT(yes)
1550             LIBS="$saved_libs -ldl"
1551           ],
1552           [
1553             AC_MSG_RESULT(no)
1554             LIBS="$saved_libs"
1555           ]
1556           )
1557
1558         ]
1559      )
1560
1561   fi
1562
1563   if test X"$HAVECRYPTO" = X"yes"; then
1564     dnl This is only reasonable to do if crypto actually is there: check for
1565     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
1566
1567     AC_CHECK_LIB(ssl, SSL_connect)
1568
1569     if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
1570         dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
1571         AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
1572         OLIBS=$LIBS
1573         LIBS="-lRSAglue -lrsaref $LIBS"
1574         AC_CHECK_LIB(ssl, SSL_connect)
1575         if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
1576             dnl still no SSL_connect
1577             AC_MSG_RESULT(no)
1578             LIBS=$OLIBS
1579         else
1580             AC_MSG_RESULT(yes)
1581         fi
1582
1583     else
1584
1585       dnl Have the libraries--check for OpenSSL headers
1586       AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
1587                        openssl/pem.h openssl/ssl.h openssl/err.h,
1588         curl_ssl_msg="enabled (OpenSSL)"
1589         OPENSSL_ENABLED=1
1590         AC_DEFINE(USE_OPENSSL, 1, [if OpenSSL is in use]))
1591
1592       if test $ac_cv_header_openssl_x509_h = no; then
1593         dnl we don't use the "action" part of the AC_CHECK_HEADERS macro
1594         dnl since 'err.h' might in fact find a krb4 header with the same
1595         dnl name
1596         AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h)
1597
1598         if test $ac_cv_header_x509_h = yes &&
1599            test $ac_cv_header_crypto_h = yes &&
1600            test $ac_cv_header_ssl_h = yes; then
1601           dnl three matches
1602           curl_ssl_msg="enabled (OpenSSL)"
1603           OPENSSL_ENABLED=1
1604         fi
1605       fi
1606     fi
1607
1608     if test X"$OPENSSL_ENABLED" = X"1"; then
1609        dnl is there a pkcs12.h header present?
1610        AC_CHECK_HEADERS(openssl/pkcs12.h)
1611     else
1612        LIBS="$CLEANLIBS"
1613     fi
1614
1615     if test X"$OPT_SSL" != Xoff &&
1616        test "$OPENSSL_ENABLED" != "1"; then
1617       AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
1618     fi
1619   fi
1620
1621   if test X"$OPENSSL_ENABLED" = X"1"; then
1622     dnl If the ENGINE library seems to be around, check for the OpenSSL engine
1623     dnl stuff, it is kind of "separated" from the main SSL check
1624     AC_CHECK_FUNC(ENGINE_init,
1625               [
1626                 AC_CHECK_HEADERS(openssl/engine.h)
1627                 AC_CHECK_FUNCS( ENGINE_load_builtin_engines )
1628               ])
1629
1630     dnl These can only exist if OpenSSL exists
1631     dnl Older versions of Cyassl (some time before 2.9.4) don't have
1632     dnl SSL_get_shutdown (but this check won't actually detect it there
1633     dnl as it's a macro that needs the header files be included)
1634
1635     AC_CHECK_FUNCS( RAND_status \
1636                     RAND_screen \
1637                     RAND_egd \
1638                     ENGINE_cleanup \
1639                     CRYPTO_cleanup_all_ex_data \
1640                     SSL_get_shutdown \
1641                     SSLv2_client_method )
1642
1643     AC_MSG_CHECKING([for BoringSSL])
1644     AC_COMPILE_IFELSE([
1645         AC_LANG_PROGRAM([[
1646                 #include <openssl/base.h>
1647                 ]],[[
1648                 #ifndef OPENSSL_IS_BORINGSSL
1649                 #error not boringssl
1650                 #endif
1651        ]])
1652     ],[
1653         AC_MSG_RESULT([yes])
1654         AC_DEFINE_UNQUOTED(HAVE_BORINGSSL, 1,
1655                            [Define to 1 if using BoringSSL.])
1656         curl_ssl_msg="enabled (BoringSSL)"
1657     ],[
1658         AC_MSG_RESULT([no])
1659     ])
1660
1661     AC_MSG_CHECKING([for libressl])
1662     AC_COMPILE_IFELSE([
1663       AC_LANG_PROGRAM([[
1664 #include <openssl/opensslv.h>
1665       ]],[[
1666         int dummy = LIBRESSL_VERSION_NUMBER;
1667       ]])
1668     ],[
1669       AC_MSG_RESULT([yes])
1670       AC_DEFINE_UNQUOTED(HAVE_LIBRESSL, 1,
1671         [Define to 1 if using libressl.])
1672       curl_ssl_msg="enabled (libressl)"
1673     ],[
1674       AC_MSG_RESULT([no])
1675     ])
1676   fi
1677
1678   if test "$OPENSSL_ENABLED" = "1"; then
1679     if test -n "$LIB_OPENSSL"; then
1680        dnl when the ssl shared libs were found in a path that the run-time
1681        dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
1682        dnl to prevent further configure tests to fail due to this
1683        if test "x$cross_compiling" != "xyes"; then
1684          LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIB_OPENSSL"
1685          export LD_LIBRARY_PATH
1686          AC_MSG_NOTICE([Added $LIB_OPENSSL to LD_LIBRARY_PATH])
1687        fi
1688     fi
1689     CURL_CHECK_OPENSSL_API
1690   fi
1691
1692 fi
1693
1694 dnl **********************************************************************
1695 dnl Check for the random seed preferences
1696 dnl **********************************************************************
1697
1698 if test X"$OPENSSL_ENABLED" = X"1"; then
1699   AC_ARG_WITH(egd-socket,
1700   AC_HELP_STRING([--with-egd-socket=FILE],
1701                  [Entropy Gathering Daemon socket pathname]),
1702       [ EGD_SOCKET="$withval" ]
1703   )
1704   if test -n "$EGD_SOCKET" ; then
1705           AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET",
1706           [your Entropy Gathering Daemon socket pathname] )
1707   fi
1708
1709   dnl Check for user-specified random device
1710   AC_ARG_WITH(random,
1711   AC_HELP_STRING([--with-random=FILE],
1712                  [read randomness from FILE (default=/dev/urandom)]),
1713       [ RANDOM_FILE="$withval" ],
1714       [
1715           if test x$cross_compiling != xyes; then
1716             dnl Check for random device
1717             AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
1718           else
1719             AC_MSG_WARN([skipped the /dev/urandom detection when cross-compiling])
1720           fi
1721       ]
1722   )
1723   if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
1724           AC_SUBST(RANDOM_FILE)
1725           AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
1726           [a suitable file to read random data from])
1727   fi
1728 fi
1729
1730 dnl ---
1731 dnl We require OpenSSL with SRP support.
1732 dnl ---
1733 if test "$OPENSSL_ENABLED" = "1"; then
1734   AC_CHECK_LIB(crypto, SRP_Calc_client_key,
1735    [
1736      AC_DEFINE(HAVE_OPENSSL_SRP, 1, [if you have the function SRP_Calc_client_key])
1737      AC_SUBST(HAVE_OPENSSL_SRP, [1])
1738    ])
1739 fi
1740
1741 dnl ----------------------------------------------------
1742 dnl check for GnuTLS
1743 dnl ----------------------------------------------------
1744
1745 dnl Default to compiler & linker defaults for GnuTLS files & libraries.
1746 OPT_GNUTLS=no
1747
1748 AC_ARG_WITH(gnutls,dnl
1749 AC_HELP_STRING([--with-gnutls=PATH],[where to look for GnuTLS, PATH points to the installation root])
1750 AC_HELP_STRING([--without-gnutls], [disable GnuTLS detection]),
1751   OPT_GNUTLS=$withval)
1752
1753 if test "$curl_ssl_msg" = "$init_ssl_msg"; then
1754
1755   if test X"$OPT_GNUTLS" != Xno; then
1756
1757     addld=""
1758     addlib=""
1759     gtlslib=""
1760     version=""
1761     addcflags=""
1762
1763     if test "x$OPT_GNUTLS" = "xyes"; then
1764       dnl this is with no partiular path given
1765       CURL_CHECK_PKGCONFIG(gnutls)
1766
1767       if test "$PKGCONFIG" != "no" ; then
1768         addlib=`$PKGCONFIG --libs-only-l gnutls`
1769         addld=`$PKGCONFIG --libs-only-L gnutls`
1770         addcflags=`$PKGCONFIG --cflags-only-I gnutls`
1771         version=`$PKGCONFIG --modversion gnutls`
1772         gtlslib=`echo $addld | $SED -e 's/-L//'`
1773       else
1774         dnl without pkg-config, we try libgnutls-config as that was how it
1775         dnl used to be done
1776         check=`libgnutls-config --version 2>/dev/null`
1777         if test -n "$check"; then
1778           addlib=`libgnutls-config --libs`
1779           addcflags=`libgnutls-config --cflags`
1780           version=`libgnutls-config --version`
1781           gtlslib=`libgnutls-config --prefix`/lib$libsuff
1782         fi
1783       fi
1784     else
1785       dnl this is with a given path, first check if there's a libgnutls-config
1786       dnl there and if not, make an educated guess
1787       cfg=$OPT_GNUTLS/bin/libgnutls-config
1788       check=`$cfg --version 2>/dev/null`
1789       if test -n "$check"; then
1790         addlib=`$cfg --libs`
1791         addcflags=`$cfg --cflags`
1792         version=`$cfg --version`
1793         gtlslib=`$cfg --prefix`/lib$libsuff
1794       else
1795         dnl without pkg-config and libgnutls-config, we guess a lot!
1796         addlib=-lgnutls
1797         addld=-L$OPT_GNUTLS/lib$libsuff
1798         addcflags=-I$OPT_GNUTLS/include
1799         version="" # we just don't know
1800         gtlslib=$OPT_GNUTLS/lib$libsuff
1801       fi
1802     fi
1803
1804     if test -z "$version"; then
1805       dnl lots of efforts, still no go
1806       version="unknown"
1807     fi
1808
1809     if test -n "$addlib"; then
1810
1811       CLEANLIBS="$LIBS"
1812       CLEANCPPFLAGS="$CPPFLAGS"
1813       CLEANLDFLAGS="$LDFLAGS"
1814
1815       LIBS="$addlib $LIBS"
1816       LDFLAGS="$LDFLAGS $addld"
1817       if test "$addcflags" != "-I/usr/include"; then
1818          CPPFLAGS="$CPPFLAGS $addcflags"
1819       fi
1820
1821       AC_CHECK_LIB(gnutls, gnutls_check_version,
1822        [
1823        AC_DEFINE(USE_GNUTLS, 1, [if GnuTLS is enabled])
1824        AC_SUBST(USE_GNUTLS, [1])
1825        GNUTLS_ENABLED=1
1826        USE_GNUTLS="yes"
1827        curl_ssl_msg="enabled (GnuTLS)"
1828        ],
1829        [
1830          LIBS="$CLEANLIBS"
1831          CPPFLAGS="$CLEANCPPFLAGS"
1832        ])
1833
1834       if test "x$USE_GNUTLS" = "xyes"; then
1835         AC_MSG_NOTICE([detected GnuTLS version $version])
1836
1837         if test -n "$gtlslib"; then
1838           dnl when shared libs were found in a path that the run-time
1839           dnl linker doesn't search through, we need to add it to
1840           dnl LD_LIBRARY_PATH to prevent further configure tests to fail
1841           dnl due to this
1842           if test "x$cross_compiling" != "xyes"; then 
1843             LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$gtlslib"
1844             export LD_LIBRARY_PATH
1845             AC_MSG_NOTICE([Added $gtlslib to LD_LIBRARY_PATH])
1846           fi
1847         fi
1848         AC_CHECK_FUNCS(gnutls_certificate_set_x509_key_file2)
1849       fi
1850
1851     fi
1852
1853   fi dnl GNUTLS not disabled
1854
1855 fi
1856
1857 dnl ---
1858 dnl Check which crypto backend GnuTLS uses
1859 dnl ---
1860
1861 if test "$GNUTLS_ENABLED" = "1"; then
1862   USE_GNUTLS_NETTLE=
1863   # First check if we can detect either crypto library via transitive linking
1864   AC_CHECK_LIB(gnutls, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ])
1865   if test "$USE_GNUTLS_NETTLE" = ""; then
1866     AC_CHECK_LIB(gnutls, gcry_control, [ USE_GNUTLS_NETTLE=0 ])
1867   fi
1868   # If not, try linking directly to both of them to see if they are available
1869   if test "$USE_GNUTLS_NETTLE" = ""; then
1870     AC_CHECK_LIB(nettle, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ])
1871   fi
1872   if test "$USE_GNUTLS_NETTLE" = ""; then
1873     AC_CHECK_LIB(gcrypt, gcry_control, [ USE_GNUTLS_NETTLE=0 ])
1874   fi
1875   if test "$USE_GNUTLS_NETTLE" = ""; then
1876     AC_MSG_ERROR([GnuTLS found, but neither gcrypt nor nettle found])
1877   fi
1878   if test "$USE_GNUTLS_NETTLE" = "1"; then
1879     AC_DEFINE(USE_GNUTLS_NETTLE, 1, [if GnuTLS uses nettle as crypto backend])
1880     AC_SUBST(USE_GNUTLS_NETTLE, [1])
1881     LIBS="-lnettle $LIBS"
1882   else
1883     LIBS="-lgcrypt $LIBS"
1884   fi
1885 fi
1886
1887 dnl ---
1888 dnl We require GnuTLS with SRP support.
1889 dnl ---
1890 if test "$GNUTLS_ENABLED" = "1"; then
1891   AC_CHECK_LIB(gnutls, gnutls_srp_verifier,
1892    [
1893      AC_DEFINE(HAVE_GNUTLS_SRP, 1, [if you have the function gnutls_srp_verifier])
1894      AC_SUBST(HAVE_GNUTLS_SRP, [1])
1895    ])
1896 fi
1897
1898 dnl ----------------------------------------------------
1899 dnl check for PolarSSL
1900 dnl ----------------------------------------------------
1901
1902 dnl Default to compiler & linker defaults for PolarSSL files & libraries.
1903 OPT_POLARSSL=no
1904
1905 _cppflags=$CPPFLAGS
1906 _ldflags=$LDFLAGS
1907 AC_ARG_WITH(polarssl,dnl
1908 AC_HELP_STRING([--with-polarssl=PATH],[where to look for PolarSSL, PATH points to the installation root])
1909 AC_HELP_STRING([--without-polarssl], [disable PolarSSL detection]),
1910   OPT_POLARSSL=$withval)
1911
1912 if test "$curl_ssl_msg" = "$init_ssl_msg"; then
1913
1914   if test X"$OPT_POLARSSL" != Xno; then
1915
1916     if test "$OPT_POLARSSL" = "yes"; then
1917       OPT_POLARSSL=""
1918     fi
1919
1920     if test -z "$OPT_POLARSSL" ; then
1921       dnl check for lib first without setting any new path
1922
1923       AC_CHECK_LIB(polarssl, havege_init,
1924       dnl libpolarssl found, set the variable
1925        [
1926          AC_DEFINE(USE_POLARSSL, 1, [if PolarSSL is enabled])
1927          AC_SUBST(USE_POLARSSL, [1])
1928          POLARSSL_ENABLED=1
1929          USE_POLARSSL="yes"
1930          curl_ssl_msg="enabled (PolarSSL)"
1931         ])
1932     fi
1933
1934     addld=""
1935     addlib=""
1936     addcflags=""
1937     polarssllib=""
1938
1939     if test "x$USE_POLARSSL" != "xyes"; then
1940       dnl add the path and test again
1941       addld=-L$OPT_POLARSSL/lib$libsuff
1942       addcflags=-I$OPT_POLARSSL/include
1943       polarssllib=$OPT_POLARSSL/lib$libsuff
1944
1945       LDFLAGS="$LDFLAGS $addld"
1946       if test "$addcflags" != "-I/usr/include"; then
1947          CPPFLAGS="$CPPFLAGS $addcflags"
1948       fi
1949
1950       AC_CHECK_LIB(polarssl, ssl_init,
1951        [
1952        AC_DEFINE(USE_POLARSSL, 1, [if PolarSSL is enabled])
1953        AC_SUBST(USE_POLARSSL, [1])
1954        POLARSSL_ENABLED=1
1955        USE_POLARSSL="yes"
1956        curl_ssl_msg="enabled (PolarSSL)"
1957        ],
1958        [
1959          CPPFLAGS=$_cppflags
1960          LDFLAGS=$_ldflags
1961        ])
1962     fi
1963
1964     if test "x$USE_POLARSSL" = "xyes"; then
1965       AC_MSG_NOTICE([detected PolarSSL])
1966
1967       LIBS="-lpolarssl $LIBS"
1968
1969       if test -n "$polarssllib"; then
1970         dnl when shared libs were found in a path that the run-time
1971         dnl linker doesn't search through, we need to add it to
1972         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
1973         dnl due to this
1974         if test "x$cross_compiling" != "xyes"; then
1975           LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$polarssllib"
1976           export LD_LIBRARY_PATH
1977           AC_MSG_NOTICE([Added $polarssllib to LD_LIBRARY_PATH])
1978         fi
1979       fi
1980     fi
1981
1982   fi dnl PolarSSL not disabled
1983
1984 fi
1985
1986 dnl ----------------------------------------------------
1987 dnl check for mbedTLS
1988 dnl ----------------------------------------------------
1989
1990 OPT_MBEDTLS=no
1991
1992 _cppflags=$CPPFLAGS
1993 _ldflags=$LDFLAGS
1994 AC_ARG_WITH(mbedtls,dnl
1995 AC_HELP_STRING([--with-mbedtls=PATH],[where to look for mbedTLS, PATH points to the installation root])
1996 AC_HELP_STRING([--without-mbedtls], [disable mbedTLS detection]),
1997   OPT_MBEDTLS=$withval)
1998
1999 if test "$curl_ssl_msg" = "$init_ssl_msg"; then
2000
2001   if test X"$OPT_MBEDTLS" != Xno; then
2002
2003     if test "$OPT_MBEDTLS" = "yes"; then
2004       OPT_MBEDTLS=""
2005     fi
2006
2007     if test -z "$OPT_MBEDTLS" ; then
2008       dnl check for lib first without setting any new path
2009
2010       AC_CHECK_LIB(mbedtls, mbedtls_havege_init,
2011       dnl libmbedtls found, set the variable
2012        [
2013          AC_DEFINE(USE_MBEDTLS, 1, [if mbedTLS is enabled])
2014          AC_SUBST(USE_MBEDTLS, [1])
2015          MBEDTLS_ENABLED=1
2016          USE_MBEDTLS="yes"
2017          curl_ssl_msg="enabled (mbedTLS)"
2018         ], [], -lmbedx509 -lmbedcrypto)
2019     fi
2020
2021     addld=""
2022     addlib=""
2023     addcflags=""
2024     mbedtlslib=""
2025
2026     if test "x$USE_MBEDTLS" != "xyes"; then
2027       dnl add the path and test again
2028       addld=-L$OPT_MBEDTLS/lib$libsuff
2029       addcflags=-I$OPT_MBEDTLS/include
2030       mbedtlslib=$OPT_MBEDTLS/lib$libsuff
2031
2032       LDFLAGS="$LDFLAGS $addld"
2033       if test "$addcflags" != "-I/usr/include"; then
2034          CPPFLAGS="$CPPFLAGS $addcflags"
2035       fi
2036
2037       AC_CHECK_LIB(mbedtls, mbedtls_ssl_init,
2038        [
2039        AC_DEFINE(USE_MBEDTLS, 1, [if mbedTLS is enabled])
2040        AC_SUBST(USE_MBEDTLS, [1])
2041        MBEDTLS_ENABLED=1
2042        USE_MBEDTLS="yes"
2043        curl_ssl_msg="enabled (mbedTLS)"
2044        ],
2045        [
2046          CPPFLAGS=$_cppflags
2047          LDFLAGS=$_ldflags
2048        ], -lmbedx509 -lmbedcrypto)
2049     fi
2050
2051     if test "x$USE_MBEDTLS" = "xyes"; then
2052       AC_MSG_NOTICE([detected mbedTLS])
2053
2054       LIBS="-lmbedtls -lmbedx509 -lmbedcrypto $LIBS"
2055
2056       if test -n "$mbedtlslib"; then
2057         dnl when shared libs were found in a path that the run-time
2058         dnl linker doesn't search through, we need to add it to
2059         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
2060         dnl due to this
2061         if test "x$cross_compiling" != "xyes"; then
2062           LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$mbedtlslib"
2063           export LD_LIBRARY_PATH
2064           AC_MSG_NOTICE([Added $mbedtlslib to LD_LIBRARY_PATH])
2065         fi
2066       fi
2067     fi
2068
2069   fi dnl mbedTLS not disabled
2070
2071 fi
2072
2073 dnl ----------------------------------------------------
2074 dnl check for CyaSSL
2075 dnl ----------------------------------------------------
2076
2077 dnl Default to compiler & linker defaults for CyaSSL files & libraries.
2078 OPT_CYASSL=no
2079
2080 _cppflags=$CPPFLAGS
2081 _ldflags=$LDFLAGS
2082 AC_ARG_WITH(cyassl,dnl
2083 AC_HELP_STRING([--with-cyassl=PATH],[where to look for CyaSSL, PATH points to the installation root (default: system lib default)])
2084 AC_HELP_STRING([--without-cyassl], [disable CyaSSL detection]),
2085   OPT_CYASSL=$withval)
2086
2087 if test "$curl_ssl_msg" = "$init_ssl_msg"; then
2088
2089   if test X"$OPT_CYASSL" != Xno; then
2090
2091     if test "$OPT_CYASSL" = "yes"; then
2092       OPT_CYASSL=""
2093     fi
2094
2095     dnl This should be reworked to use pkg-config instead
2096
2097     cyassllibname=cyassl
2098
2099     if test -z "$OPT_CYASSL" ; then
2100       dnl check for lib in system default first
2101
2102       AC_CHECK_LIB(cyassl, CyaSSL_Init,
2103       dnl libcyassl found, set the variable
2104        [
2105          AC_DEFINE(USE_CYASSL, 1, [if CyaSSL is enabled])
2106          AC_SUBST(USE_CYASSL, [1])
2107          CYASSL_ENABLED=1
2108          USE_CYASSL="yes"
2109          curl_ssl_msg="enabled (CyaSSL)"
2110         ])
2111     fi
2112
2113     addld=""
2114     addlib=""
2115     addcflags=""
2116     cyassllib=""
2117
2118     if test "x$USE_CYASSL" != "xyes"; then
2119       dnl add the path and test again
2120       addld=-L$OPT_CYASSL/lib$libsuff
2121       addcflags=-I$OPT_CYASSL/include
2122       cyassllib=$OPT_CYASSL/lib$libsuff
2123
2124       LDFLAGS="$LDFLAGS $addld"
2125       if test "$addcflags" != "-I/usr/include"; then
2126          CPPFLAGS="$CPPFLAGS $addcflags"
2127       fi
2128
2129       AC_CHECK_LIB(cyassl, CyaSSL_Init,
2130        [
2131        AC_DEFINE(USE_CYASSL, 1, [if CyaSSL is enabled])
2132        AC_SUBST(USE_CYASSL, [1])
2133        CYASSL_ENABLED=1
2134        USE_CYASSL="yes"
2135        curl_ssl_msg="enabled (CyaSSL)"
2136        ],
2137        [
2138          CPPFLAGS=$_cppflags
2139          LDFLAGS=$_ldflags
2140          cyassllib=""
2141        ])
2142     fi
2143
2144     addld=""
2145     addlib=""
2146     addcflags=""
2147
2148     if test "x$USE_CYASSL" != "xyes"; then
2149       dnl libcyassl renamed to libwolfssl as of 3.4.0
2150       addld=-L$OPT_CYASSL/lib$libsuff
2151       addcflags=-I$OPT_CYASSL/include
2152       cyassllib=$OPT_CYASSL/lib$libsuff
2153
2154       LDFLAGS="$LDFLAGS $addld"
2155       if test "$addcflags" != "-I/usr/include"; then
2156          CPPFLAGS="$CPPFLAGS $addcflags"
2157       fi
2158
2159       cyassllibname=wolfssl
2160       my_ac_save_LIBS="$LIBS"
2161       LIBS="-l$cyassllibname -lm $LIBS"
2162
2163       AC_MSG_CHECKING([for CyaSSL_Init in -lwolfssl])
2164       AC_LINK_IFELSE([
2165         AC_LANG_PROGRAM([[
2166 /* These aren't needed for detection and confuse WolfSSL.
2167    They are set up properly later if it is detected.  */
2168 #undef SIZEOF_LONG
2169 #undef SIZEOF_LONG_LONG
2170 #include <cyassl/ssl.h>
2171         ]],[[
2172           return CyaSSL_Init();
2173         ]])
2174       ],[
2175          AC_MSG_RESULT(yes)
2176          AC_DEFINE(USE_CYASSL, 1, [if CyaSSL/WolfSSL is enabled])
2177          AC_SUBST(USE_CYASSL, [1])
2178          CYASSL_ENABLED=1
2179          USE_CYASSL="yes"
2180          curl_ssl_msg="enabled (WolfSSL)"
2181        ],
2182        [
2183          AC_MSG_RESULT(no)
2184          CPPFLAGS=$_cppflags
2185          LDFLAGS=$_ldflags
2186          cyassllib=""
2187        ])
2188       LIBS="$my_ac_save_LIBS"
2189     fi
2190
2191     if test "x$USE_CYASSL" = "xyes"; then
2192       AC_MSG_NOTICE([detected $cyassllibname])
2193
2194       dnl cyassl/ctaocrypt/types.h needs SIZEOF_LONG_LONG defined!
2195       AC_CHECK_SIZEOF(long long)
2196
2197       dnl Versions since at least 2.6.0 may have options.h
2198       AC_CHECK_HEADERS(cyassl/options.h)
2199
2200       dnl Versions since at least 2.9.4 renamed error.h to error-ssl.h
2201       AC_CHECK_HEADERS(cyassl/error-ssl.h)
2202
2203       LIBS="-l$cyassllibname -lm $LIBS"
2204
2205       if test "x$cyassllibname" = "xwolfssl"; then
2206         dnl Recent WolfSSL versions build without SSLv3 by default
2207         dnl WolfSSL needs configure --enable-opensslextra to have *get_peer*
2208         AC_CHECK_FUNCS(wolfSSLv3_client_method \
2209                        wolfSSL_get_peer_certificate)
2210       else
2211         dnl Cyassl needs configure --enable-opensslextra to have *get_peer*
2212         AC_CHECK_FUNCS(CyaSSL_get_peer_certificate)
2213       fi
2214
2215       if test -n "$cyassllib"; then
2216         dnl when shared libs were found in a path that the run-time
2217         dnl linker doesn't search through, we need to add it to
2218         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
2219         dnl due to this
2220         if test "x$cross_compiling" != "xyes"; then
2221           LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$cyassllib"
2222           export LD_LIBRARY_PATH
2223           AC_MSG_NOTICE([Added $cyassllib to LD_LIBRARY_PATH])
2224         fi
2225       fi
2226
2227     fi
2228
2229   fi dnl CyaSSL not disabled
2230
2231 fi
2232
2233 dnl ----------------------------------------------------
2234 dnl NSS. Only check if GnuTLS and OpenSSL are not enabled
2235 dnl ----------------------------------------------------
2236
2237 dnl Default to compiler & linker defaults for NSS files & libraries.
2238 OPT_NSS=no
2239
2240 AC_ARG_WITH(nss,dnl
2241 AC_HELP_STRING([--with-nss=PATH],[where to look for NSS, PATH points to the installation root])
2242 AC_HELP_STRING([--without-nss], [disable NSS detection]),
2243   OPT_NSS=$withval)
2244
2245 if test "$curl_ssl_msg" = "$init_ssl_msg"; then
2246
2247   if test X"$OPT_NSS" != Xno; then
2248
2249     addld=""
2250     addlib=""
2251     addcflags=""
2252     nssprefix=""
2253     version=""
2254
2255     if test "x$OPT_NSS" = "xyes"; then
2256
2257       CURL_CHECK_PKGCONFIG(nss)
2258
2259       if test "$PKGCONFIG" != "no" ; then
2260         addlib=`$PKGCONFIG --libs nss`
2261         addcflags=`$PKGCONFIG --cflags nss`
2262         version=`$PKGCONFIG --modversion nss`
2263         nssprefix=`$PKGCONFIG --variable=prefix nss`
2264       else
2265         dnl Without pkg-config, we check for nss-config
2266
2267         check=`nss-config --version 2>/dev/null`
2268         if test -n "$check"; then
2269           addlib=`nss-config --libs`
2270           addcflags=`nss-config --cflags`
2271           version=`nss-config --version`
2272           nssprefix=`nss-config --prefix`
2273         else
2274           addlib="-lnss3"
2275           addcflags=""
2276           version="unknown"
2277         fi
2278       fi
2279     else
2280       NSS_PCDIR="$OPT_NSS/lib/pkgconfig"
2281       if test -f "$NSS_PCDIR/nss.pc"; then
2282         CURL_CHECK_PKGCONFIG(nss, [$NSS_PCDIR])
2283         if test "$PKGCONFIG" != "no" ; then
2284           addld=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --libs-only-L nss`
2285           addlib=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --libs-only-l nss`
2286           addcflags=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --cflags nss`
2287           version=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --modversion nss`
2288           nssprefix=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --variable=prefix nss`
2289         fi
2290       fi
2291     fi
2292
2293     if test -z "$addlib"; then
2294       # Without pkg-config, we'll kludge in some defaults
2295       AC_MSG_WARN([Using hard-wired libraries and compilation flags for NSS.])
2296       addld="-L$OPT_NSS/lib"
2297       addlib="-lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4"
2298       addcflags="-I$OPT_NSS/include"
2299       version="unknown"
2300       nssprefix=$OPT_NSS
2301     fi
2302
2303     CLEANLDFLAGS="$LDFLAGS"
2304     CLEANLIBS="$LIBS"
2305     CLEANCPPFLAGS="$CPPFLAGS"
2306
2307     LDFLAGS="$addld $LDFLAGS"
2308     LIBS="$addlib $LIBS"
2309     if test "$addcflags" != "-I/usr/include"; then
2310        CPPFLAGS="$CPPFLAGS $addcflags"
2311     fi
2312
2313     dnl The function SSL_VersionRangeSet() is needed to enable TLS > 1.0
2314     AC_CHECK_LIB(nss3, SSL_VersionRangeSet,
2315      [
2316      AC_DEFINE(USE_NSS, 1, [if NSS is enabled])
2317      AC_SUBST(USE_NSS, [1])
2318      USE_NSS="yes"
2319      NSS_ENABLED=1
2320      curl_ssl_msg="enabled (NSS)"
2321      ],
2322      [
2323        LDFLAGS="$CLEANLDFLAGS"
2324        LIBS="$CLEANLIBS"
2325        CPPFLAGS="$CLEANCPPFLAGS"
2326      ])
2327
2328     if test "x$USE_NSS" = "xyes"; then
2329       AC_MSG_NOTICE([detected NSS version $version])
2330
2331       dnl needed when linking the curl tool without USE_EXPLICIT_LIB_DEPS
2332       NSS_LIBS=$addlib
2333       AC_SUBST([NSS_LIBS])
2334
2335       dnl when shared libs were found in a path that the run-time
2336       dnl linker doesn't search through, we need to add it to
2337       dnl LD_LIBRARY_PATH to prevent further configure tests to fail
2338       dnl due to this
2339       if test "x$cross_compiling" != "xyes"; then
2340         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$nssprefix/lib$libsuff"
2341         export LD_LIBRARY_PATH
2342         AC_MSG_NOTICE([Added $nssprefix/lib$libsuff to LD_LIBRARY_PATH])
2343       fi
2344
2345     fi dnl NSS found
2346
2347   fi dnl NSS not disabled
2348
2349 fi dnl curl_ssl_msg = init_ssl_msg
2350
2351 OPT_AXTLS=off
2352
2353 AC_ARG_WITH(axtls,dnl
2354 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.])
2355 AC_HELP_STRING([--without-axtls], [disable axTLS]),
2356   OPT_AXTLS=$withval)
2357
2358 if test "$curl_ssl_msg" = "$init_ssl_msg"; then
2359   if test X"$OPT_AXTLS" != Xno; then
2360     dnl backup the pre-axtls variables
2361     CLEANLDFLAGS="$LDFLAGS"
2362     CLEANCPPFLAGS="$CPPFLAGS"
2363     CLEANLIBS="$LIBS"
2364
2365     case "$OPT_AXTLS" in
2366     yes)
2367       dnl --with-axtls (without path) used
2368       PREFIX_AXTLS=/usr/local
2369       LIB_AXTLS="$PREFIX_AXTLS/lib"
2370       LDFLAGS="$LDFLAGS -L$LIB_AXTLS"
2371       CPPFLAGS="$CPPFLAGS -I$PREFIX_AXTLS/include"
2372       ;;
2373     off)
2374       dnl no --with-axtls option given, just check default places
2375       PREFIX_AXTLS=
2376       ;;
2377     *)
2378       dnl check the given --with-axtls spot
2379       PREFIX_AXTLS=$OPT_AXTLS
2380       LIB_AXTLS="$PREFIX_AXTLS/lib"
2381       LDFLAGS="$LDFLAGS -L$LIB_AXTLS"
2382       CPPFLAGS="$CPPFLAGS -I$PREFIX_AXTLS/include"
2383       ;;
2384     esac
2385
2386     AC_CHECK_LIB(axtls, ssl_version,[
2387       LIBS="-laxtls $LIBS"
2388       AC_DEFINE(USE_AXTLS, 1, [if axTLS is enabled])
2389       AC_SUBST(USE_AXTLS, [1])
2390       AXTLS_ENABLED=1
2391       USE_AXTLS="yes"
2392       curl_ssl_msg="enabled (axTLS)"
2393
2394       if test "x$cross_compiling" != "xyes"; then
2395         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIB_AXTLS"
2396         export LD_LIBRARY_PATH
2397         AC_MSG_NOTICE([Added $LIB_AXTLS to LD_LIBRARY_PATH])
2398       fi
2399       ],[
2400       LDFLAGS="$CLEANLDFLAGS"
2401       CPPFLAGS="$CLEANCPPFLAGS"
2402       LIBS="$CLEANLIBS"
2403     ])
2404   fi
2405 fi
2406
2407 if test "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$POLARSSL_ENABLED$MBEDTLS_ENABLED$AXTLS_ENABLED$CYASSL_ENABLED$WINSSL_ENABLED$DARWINSSL_ENABLED" = "x"; then
2408   AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
2409   AC_MSG_WARN([Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss, --with-axtls, --with-winssl, or --with-darwinssl to address this.])
2410 else
2411   # SSL is enabled, genericly
2412   AC_SUBST(SSL_ENABLED)
2413   SSL_ENABLED="1"
2414 fi
2415
2416 dnl **********************************************************************
2417 dnl Check for the CA bundle
2418 dnl **********************************************************************
2419
2420 CURL_CHECK_CA_BUNDLE
2421
2422 dnl **********************************************************************
2423 dnl Check for libpsl
2424 dnl **********************************************************************
2425
2426 AC_ARG_WITH(libpsl,
2427            AS_HELP_STRING([--without-libpsl],
2428            [disable support for libpsl cookie checking]),
2429            with_libpsl=$withval,
2430            with_libpsl=yes)
2431 if test $with_libpsl != "no"; then
2432   AC_SEARCH_LIBS(psl_builtin, psl,
2433     [curl_psl_msg="yes";
2434      AC_DEFINE([USE_LIBPSL], [1], [PSL support enabled])
2435      ],
2436     [curl_psl_msg="no      (libpsl not found)";
2437      AC_MSG_WARN([libpsl was not found])
2438      ]
2439   )
2440 fi
2441 AM_CONDITIONAL([USE_LIBPSL], [test "$curl_psl_msg" = "yes"])
2442
2443 dnl **********************************************************************
2444 dnl Check for libmetalink
2445 dnl **********************************************************************
2446
2447 OPT_LIBMETALINK=no
2448
2449 AC_ARG_WITH(libmetalink,dnl
2450 AC_HELP_STRING([--with-libmetalink=PATH],[where to look for libmetalink, PATH points to the installation root])
2451 AC_HELP_STRING([--without-libmetalink], [disable libmetalink detection]),
2452   OPT_LIBMETALINK=$withval)
2453
2454 if test X"$OPT_LIBMETALINK" != Xno; then
2455
2456   addld=""
2457   addlib=""
2458   addcflags=""
2459   version=""
2460   libmetalinklib=""
2461
2462   PKGTEST="no"
2463   if test "x$OPT_LIBMETALINK" = "xyes"; then
2464     dnl this is with no partiular path given
2465     PKGTEST="yes"
2466     CURL_CHECK_PKGCONFIG(libmetalink)
2467   else
2468     dnl When particular path is given, set PKG_CONFIG_LIBDIR using the path.
2469     LIBMETALINK_PCDIR="$OPT_LIBMETALINK/lib/pkgconfig"
2470     AC_MSG_NOTICE([PKG_CONFIG_LIBDIR will be set to "$LIBMETALINK_PCDIR"])
2471     if test -f "$LIBMETALINK_PCDIR/libmetalink.pc"; then
2472       PKGTEST="yes"
2473     fi
2474     if test "$PKGTEST" = "yes"; then
2475       CURL_CHECK_PKGCONFIG(libmetalink, [$LIBMETALINK_PCDIR])
2476     fi
2477   fi
2478   if test "$PKGTEST" = "yes" && test "$PKGCONFIG" != "no"; then
2479     addlib=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2480       $PKGCONFIG --libs-only-l libmetalink`
2481     addld=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2482       $PKGCONFIG --libs-only-L libmetalink`
2483     addcflags=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2484       $PKGCONFIG --cflags-only-I libmetalink`
2485     version=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
2486       $PKGCONFIG --modversion libmetalink`
2487     libmetalinklib=`echo $addld | $SED -e 's/-L//'`
2488   fi
2489   if test -n "$addlib"; then
2490
2491     clean_CPPFLAGS="$CPPFLAGS"
2492     clean_LDFLAGS="$LDFLAGS"
2493     clean_LIBS="$LIBS"
2494     CPPFLAGS="$addcflags $clean_CPPFLAGS"
2495     LDFLAGS="$addld $clean_LDFLAGS"
2496     LIBS="$addlib $clean_LIBS"
2497     AC_MSG_CHECKING([if libmetalink is recent enough])
2498     AC_LINK_IFELSE([
2499       AC_LANG_PROGRAM([[
2500 #       include <metalink/metalink.h>
2501       ]],[[
2502         if(0 != metalink_strerror(0)) /* added in 0.1.0 */
2503           return 1;
2504       ]])
2505     ],[
2506       AC_MSG_RESULT([yes ($version)])
2507       want_metalink="yes"
2508     ],[
2509       AC_MSG_RESULT([no ($version)])
2510       AC_MSG_NOTICE([libmetalink library defective or too old])
2511       want_metalink="no"
2512     ])
2513     CPPFLAGS="$clean_CPPFLAGS"
2514     LDFLAGS="$clean_LDFLAGS"
2515     LIBS="$clean_LIBS"
2516     if test "$want_metalink" = "yes"; then
2517       dnl finally libmetalink will be used
2518       AC_DEFINE(USE_METALINK, 1, [Define to enable metalink support])
2519       LIBMETALINK_LIBS=$addlib
2520       LIBMETALINK_LDFLAGS=$addld
2521       LIBMETALINK_CPPFLAGS=$addcflags
2522       AC_SUBST([LIBMETALINK_LIBS])
2523       AC_SUBST([LIBMETALINK_LDFLAGS])
2524       AC_SUBST([LIBMETALINK_CPPFLAGS])
2525       curl_mtlnk_msg="enabled"
2526     fi
2527
2528   fi
2529 fi
2530
2531 dnl **********************************************************************
2532 dnl Check for the presence of LIBSSH2 libraries and headers
2533 dnl **********************************************************************
2534
2535 dnl Default to compiler & linker defaults for LIBSSH2 files & libraries.
2536 OPT_LIBSSH2=off
2537 AC_ARG_WITH(libssh2,dnl
2538 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])
2539 AC_HELP_STRING([--without-libssh2], [disable LIBSSH2]),
2540   OPT_LIBSSH2=$withval)
2541
2542 if test X"$OPT_LIBSSH2" != Xno; then
2543   dnl backup the pre-libssh2 variables
2544   CLEANLDFLAGS="$LDFLAGS"
2545   CLEANCPPFLAGS="$CPPFLAGS"
2546   CLEANLIBS="$LIBS"
2547
2548   case "$OPT_LIBSSH2" in
2549   yes)
2550     dnl --with-libssh2 (without path) used
2551     CURL_CHECK_PKGCONFIG(libssh2)
2552
2553     if test "$PKGCONFIG" != "no" ; then
2554       LIB_SSH2=`$PKGCONFIG --libs-only-l libssh2`
2555       LD_SSH2=`$PKGCONFIG --libs-only-L libssh2`
2556       CPP_SSH2=`$PKGCONFIG --cflags-only-I libssh2`
2557       version=`$PKGCONFIG --modversion libssh2`
2558       DIR_SSH2=`echo $LD_SSH2 | $SED -e 's/-L//'`
2559     fi
2560
2561     ;;
2562   off)
2563     dnl no --with-libssh2 option given, just check default places
2564     ;;
2565   *)
2566     dnl use the given --with-libssh2 spot
2567     PREFIX_SSH2=$OPT_LIBSSH2
2568     ;;
2569   esac
2570
2571   dnl if given with a prefix, we set -L and -I based on that
2572   if test -n "$PREFIX_SSH2"; then
2573     LIB_SSH2="-lssh2"
2574     LD_SSH2=-L${PREFIX_SSH2}/lib$libsuff
2575     CPP_SSH2=-I${PREFIX_SSH2}/include
2576     DIR_SSH2=${PREFIX_SSH2}/lib$libsuff
2577   fi
2578
2579   LDFLAGS="$LDFLAGS $LD_SSH2"
2580   CPPFLAGS="$CPPFLAGS $CPP_SSH2"
2581   LIBS="$LIB_SSH2 $LIBS"
2582
2583   AC_CHECK_LIB(ssh2, libssh2_channel_open_ex)
2584
2585   AC_CHECK_HEADERS(libssh2.h,
2586     curl_ssh_msg="enabled (libSSH2)"
2587     LIBSSH2_ENABLED=1
2588     AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use])
2589     AC_SUBST(USE_LIBSSH2, [1])
2590   )
2591
2592   if test X"$OPT_LIBSSH2" != Xoff &&
2593      test "$LIBSSH2_ENABLED" != "1"; then
2594     AC_MSG_ERROR([libSSH2 libs and/or directories were not found where specified!])
2595   fi
2596
2597   if test "$LIBSSH2_ENABLED" = "1"; then
2598     if test -n "$DIR_SSH2"; then
2599        dnl when the libssh2 shared libs were found in a path that the run-time
2600        dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
2601        dnl to prevent further configure tests to fail due to this
2602
2603        if test "x$cross_compiling" != "xyes"; then
2604          LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DIR_SSH2"
2605          export LD_LIBRARY_PATH
2606          AC_MSG_NOTICE([Added $DIR_SSH2 to LD_LIBRARY_PATH])
2607        fi
2608     fi
2609   else
2610     dnl no libssh2, revert back to clean variables
2611     LDFLAGS=$CLEANLDFLAGS
2612     CPPFLAGS=$CLEANCPPFLAGS
2613     LIBS=$CLEANLIBS
2614   fi
2615 fi
2616
2617 dnl **********************************************************************
2618 dnl Check for the presence of LIBRTMP libraries and headers
2619 dnl **********************************************************************
2620
2621 dnl Default to compiler & linker defaults for LIBRTMP files & libraries.
2622 OPT_LIBRTMP=off
2623 AC_ARG_WITH(librtmp,dnl
2624 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])
2625 AC_HELP_STRING([--without-librtmp], [disable LIBRTMP]),
2626   OPT_LIBRTMP=$withval)
2627
2628 if test X"$OPT_LIBRTMP" != Xno; then
2629   dnl backup the pre-librtmp variables
2630   CLEANLDFLAGS="$LDFLAGS"
2631   CLEANCPPFLAGS="$CPPFLAGS"
2632   CLEANLIBS="$LIBS"
2633
2634   case "$OPT_LIBRTMP" in
2635   yes)
2636     dnl --with-librtmp (without path) used
2637     CURL_CHECK_PKGCONFIG(librtmp)
2638
2639     if test "$PKGCONFIG" != "no" ; then
2640       LIB_RTMP=`$PKGCONFIG --libs-only-l librtmp`
2641       LD_RTMP=`$PKGCONFIG --libs-only-L librtmp`
2642       CPP_RTMP=`$PKGCONFIG --cflags-only-I librtmp`
2643       version=`$PKGCONFIG --modversion librtmp`
2644       DIR_RTMP=`echo $LD_RTMP | $SED -e 's/-L//'`
2645     else
2646       dnl To avoid link errors, we do not allow --librtmp without
2647       dnl a pkgconfig file
2648       AC_MSG_ERROR([--librtmp was specified but could not find librtmp pkgconfig file.])
2649     fi
2650
2651     ;;
2652   off)
2653     dnl no --with-librtmp option given, just check default places
2654     LIB_RTMP="-lrtmp"
2655     ;;
2656   *)
2657     dnl use the given --with-librtmp spot
2658     PREFIX_RTMP=$OPT_LIBRTMP
2659     ;;
2660   esac
2661
2662   dnl if given with a prefix, we set -L and -I based on that
2663   if test -n "$PREFIX_RTMP"; then
2664     LD_RTMP=-L${PREFIX_RTMP}/lib$libsuff
2665     CPP_RTMP=-I${PREFIX_RTMP}/include
2666     DIR_RTMP=${PREFIX_RTMP}/lib$libsuff
2667   fi
2668
2669   LDFLAGS="$LDFLAGS $LD_RTMP"
2670   CPPFLAGS="$CPPFLAGS $CPP_RTMP"
2671   LIBS="$LIB_RTMP $LIBS"
2672
2673   AC_CHECK_LIB(rtmp, RTMP_Init,
2674     [
2675      AC_CHECK_HEADERS(librtmp/rtmp.h,
2676         curl_rtmp_msg="enabled (librtmp)"
2677         LIBRTMP_ENABLED=1
2678         AC_DEFINE(USE_LIBRTMP, 1, [if librtmp is in use])
2679         AC_SUBST(USE_LIBRTMP, [1])
2680      )
2681     ],
2682       dnl not found, revert back to clean variables
2683       LDFLAGS=$CLEANLDFLAGS
2684       CPPFLAGS=$CLEANCPPFLAGS
2685       LIBS=$CLEANLIBS
2686   )
2687
2688   if test X"$OPT_LIBRTMP" != Xoff &&
2689      test "$LIBRTMP_ENABLED" != "1"; then
2690     AC_MSG_ERROR([librtmp libs and/or directories were not found where specified!])
2691   fi
2692
2693 fi
2694
2695 dnl **********************************************************************
2696 dnl Check for linker switch for versioned symbols
2697 dnl **********************************************************************
2698
2699 versioned_symbols_flavour=
2700 AC_MSG_CHECKING([whether versioned symbols are wanted])
2701 AC_ARG_ENABLE(versioned-symbols,
2702 AC_HELP_STRING([--enable-versioned-symbols], [Enable versioned symbols in shared library])
2703 AC_HELP_STRING([--disable-versioned-symbols], [Disable versioned symbols in shared library]),
2704 [ case "$enableval" in
2705   yes) AC_MSG_RESULT(yes)
2706     AC_MSG_CHECKING([if libraries can be versioned])
2707     GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
2708     if test -z "$GLD"; then
2709         AC_MSG_RESULT(no)
2710         AC_MSG_WARN([You need an ld version supporting the --version-script option])
2711     else
2712         AC_MSG_RESULT(yes)
2713         if test "x$OPENSSL_ENABLED" = "x1"; then
2714           versioned_symbols_flavour="OPENSSL_"
2715         elif test "x$GNUTLS_ENABLED" = "x1"; then
2716           versioned_symbols_flavour="GNUTLS_"
2717         elif test "x$NSS_ENABLED" = "x1"; then
2718           versioned_symbols_flavour="NSS_"
2719         elif test "x$POLARSSL_ENABLED" = "x1"; then
2720           versioned_symbols_flavour="POLARSSL_"
2721         elif test "x$CYASSL_ENABLED" = "x1"; then
2722           versioned_symbols_flavour="CYASSL_"
2723         elif test "x$AXTLS_ENABLED" = "x1"; then
2724           versioned_symbols_flavour="AXTLS_"
2725         elif test "x$WINSSL_ENABLED" = "x1"; then
2726           versioned_symbols_flavour="WINSSL_"
2727         elif test "x$DARWINSSL_ENABLED" = "x1"; then
2728           versioned_symbols_flavour="DARWINSSL_"
2729         else
2730           versioned_symbols_flavour=""
2731         fi
2732         versioned_symbols="yes"
2733     fi
2734     ;;
2735
2736   *)   AC_MSG_RESULT(no)
2737     ;;
2738   esac
2739 ], [
2740 AC_MSG_RESULT(no)
2741 ]
2742 )
2743
2744 AC_SUBST([CURL_LT_SHLIB_VERSIONED_FLAVOUR],
2745   ["$versioned_symbols_flavour"])
2746 AM_CONDITIONAL([CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS],
2747   [test "x$versioned_symbols" = 'xyes'])
2748
2749 dnl -------------------------------------------------
2750 dnl check winidn option before other IDN libraries
2751 dnl -------------------------------------------------
2752
2753 AC_MSG_CHECKING([whether to enable Windows native IDN (Windows native builds only)])
2754 OPT_WINIDN="default"
2755 AC_ARG_WITH(winidn,
2756 AC_HELP_STRING([--with-winidn=PATH],[enable Windows native IDN])
2757 AC_HELP_STRING([--without-winidn], [disable Windows native IDN]),
2758   OPT_WINIDN=$withval)
2759 case "$OPT_WINIDN" in
2760   no|default)
2761     dnl --without-winidn option used or configure option not specified
2762     want_winidn="no"
2763     AC_MSG_RESULT([no])
2764     ;;
2765   yes)
2766     dnl --with-winidn option used without path
2767     want_winidn="yes"
2768     want_winidn_path="default"
2769     AC_MSG_RESULT([yes])
2770     ;;
2771   *)
2772     dnl --with-winidn option used with path
2773     want_winidn="yes"
2774     want_winidn_path="$withval"
2775     AC_MSG_RESULT([yes ($withval)])
2776     ;;
2777 esac
2778
2779 if test "$want_winidn" = "yes"; then
2780   dnl winidn library support has been requested
2781   clean_CPPFLAGS="$CPPFLAGS"
2782   clean_LDFLAGS="$LDFLAGS"
2783   clean_LIBS="$LIBS"
2784   WINIDN_LIBS="-lnormaliz"
2785   #
2786   if test "$want_winidn_path" != "default"; then
2787     dnl path has been specified
2788     dnl pkg-config not available or provides no info
2789     WINIDN_LDFLAGS="-L$want_winidn_path/lib$libsuff"
2790     WINIDN_CPPFLAGS="-I$want_winidn_path/include"
2791     WINIDN_DIR="$want_winidn_path/lib$libsuff"
2792   fi
2793   #
2794   CPPFLAGS="$WINIDN_CPPFLAGS $CPPFLAGS"
2795   LDFLAGS="$WINIDN_LDFLAGS $LDFLAGS"
2796   LIBS="$WINIDN_LIBS $LIBS"
2797   #
2798   AC_MSG_CHECKING([if IdnToUnicode can be linked])
2799   AC_LINK_IFELSE([
2800     AC_LANG_FUNC_LINK_TRY([IdnToUnicode])
2801   ],[
2802     AC_MSG_RESULT([yes])
2803     tst_links_winidn="yes"
2804   ],[
2805     AC_MSG_RESULT([no])
2806     tst_links_winidn="no"
2807   ])
2808   #
2809   if test "$tst_links_winidn" = "yes"; then
2810     AC_DEFINE(USE_WIN32_IDN, 1, [Define to 1 if you have the `normaliz' (WinIDN) library (-lnormaliz).])
2811     AC_DEFINE(WANT_IDN_PROTOTYPES, 1, [Define to 1 to provide own prototypes.])
2812     AC_SUBST([IDN_ENABLED], [1])
2813     curl_idn_msg="enabled (Windows-native)"
2814   else
2815     AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
2816     CPPFLAGS="$clean_CPPFLAGS"
2817     LDFLAGS="$clean_LDFLAGS"
2818     LIBS="$clean_LIBS"
2819   fi
2820 fi
2821
2822 dnl **********************************************************************
2823 dnl Check for the presence of IDN libraries and headers
2824 dnl **********************************************************************
2825
2826 AC_MSG_CHECKING([whether to build with libidn])
2827 OPT_IDN="default"
2828 AC_ARG_WITH(libidn,
2829 AC_HELP_STRING([--with-libidn=PATH],[Enable libidn usage])
2830 AC_HELP_STRING([--without-libidn],[Disable libidn usage]),
2831   [OPT_IDN=$withval])
2832 case "$OPT_IDN" in
2833   no)
2834     dnl --without-libidn option used
2835     want_idn="no"
2836     AC_MSG_RESULT([no])
2837     ;;
2838   default)
2839     dnl configure option not specified
2840     want_idn="yes"
2841     want_idn_path="default"
2842     AC_MSG_RESULT([(assumed) yes])
2843     ;;
2844   yes)
2845     dnl --with-libidn option used without path
2846     want_idn="yes"
2847     want_idn_path="default"
2848     AC_MSG_RESULT([yes])
2849     ;;
2850   *)
2851     dnl --with-libidn option used with path
2852     want_idn="yes"
2853     want_idn_path="$withval"
2854     AC_MSG_RESULT([yes ($withval)])
2855     ;;
2856 esac
2857
2858 if test "$want_idn" = "yes"; then
2859   dnl idn library support has been requested
2860   clean_CPPFLAGS="$CPPFLAGS"
2861   clean_LDFLAGS="$LDFLAGS"
2862   clean_LIBS="$LIBS"
2863   PKGCONFIG="no"
2864   #
2865   if test "$want_idn_path" != "default"; then
2866     dnl path has been specified
2867     IDN_PCDIR="$want_idn_path/lib$libsuff/pkgconfig"
2868     CURL_CHECK_PKGCONFIG(libidn, [$IDN_PCDIR])
2869     if test "$PKGCONFIG" != "no"; then
2870       IDN_LIBS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
2871         $PKGCONFIG --libs-only-l libidn 2>/dev/null`
2872       IDN_LDFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
2873         $PKGCONFIG --libs-only-L libidn 2>/dev/null`
2874       IDN_CPPFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
2875         $PKGCONFIG --cflags-only-I libidn 2>/dev/null`
2876       IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
2877     else
2878       dnl pkg-config not available or provides no info
2879       IDN_LIBS="-lidn"
2880       IDN_LDFLAGS="-L$want_idn_path/lib$libsuff"
2881       IDN_CPPFLAGS="-I$want_idn_path/include"
2882       IDN_DIR="$want_idn_path/lib$libsuff"
2883     fi
2884   else
2885     dnl path not specified
2886     CURL_CHECK_PKGCONFIG(libidn)
2887     if test "$PKGCONFIG" != "no"; then
2888       IDN_LIBS=`$PKGCONFIG --libs-only-l libidn 2>/dev/null`
2889       IDN_LDFLAGS=`$PKGCONFIG --libs-only-L libidn 2>/dev/null`
2890       IDN_CPPFLAGS=`$PKGCONFIG --cflags-only-I libidn 2>/dev/null`
2891       IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
2892     else
2893       dnl pkg-config not available or provides no info
2894       IDN_LIBS="-lidn"
2895     fi
2896   fi
2897   #
2898   if test "$PKGCONFIG" != "no"; then
2899     AC_MSG_NOTICE([pkg-config: IDN_LIBS: "$IDN_LIBS"])
2900     AC_MSG_NOTICE([pkg-config: IDN_LDFLAGS: "$IDN_LDFLAGS"])
2901     AC_MSG_NOTICE([pkg-config: IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
2902     AC_MSG_NOTICE([pkg-config: IDN_DIR: "$IDN_DIR"])
2903   else
2904     AC_MSG_NOTICE([IDN_LIBS: "$IDN_LIBS"])
2905     AC_MSG_NOTICE([IDN_LDFLAGS: "$IDN_LDFLAGS"])
2906     AC_MSG_NOTICE([IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
2907     AC_MSG_NOTICE([IDN_DIR: "$IDN_DIR"])
2908   fi
2909   #
2910   CPPFLAGS="$IDN_CPPFLAGS $CPPFLAGS"
2911   LDFLAGS="$IDN_LDFLAGS $LDFLAGS"
2912   LIBS="$IDN_LIBS $LIBS"
2913   #
2914   AC_MSG_CHECKING([if idna_to_ascii_4i can be linked])
2915   AC_LINK_IFELSE([
2916     AC_LANG_FUNC_LINK_TRY([idna_to_ascii_4i])
2917   ],[
2918     AC_MSG_RESULT([yes])
2919     tst_links_libidn="yes"
2920   ],[
2921     AC_MSG_RESULT([no])
2922     tst_links_libidn="no"
2923   ])
2924   if test "$tst_links_libidn" = "no"; then
2925     AC_MSG_CHECKING([if idna_to_ascii_lz can be linked])
2926     AC_LINK_IFELSE([
2927       AC_LANG_FUNC_LINK_TRY([idna_to_ascii_lz])
2928     ],[
2929       AC_MSG_RESULT([yes])
2930       tst_links_libidn="yes"
2931     ],[
2932       AC_MSG_RESULT([no])
2933       tst_links_libidn="no"
2934     ])
2935   fi
2936   #
2937   if test "$tst_links_libidn" = "yes"; then
2938     AC_DEFINE(HAVE_LIBIDN, 1, [Define to 1 if you have the `idn' library (-lidn).])
2939     dnl different versions of libidn have different setups of these:
2940     AC_CHECK_FUNCS( idn_free idna_strerror tld_strerror )
2941     AC_CHECK_HEADERS( idn-free.h tld.h )
2942     if test "x$ac_cv_header_tld_h" = "xyes"; then
2943       AC_SUBST([IDN_ENABLED], [1])
2944       curl_idn_msg="enabled"
2945       if test -n "$IDN_DIR" -a "x$cross_compiling" != "xyes"; then
2946         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$IDN_DIR"
2947         export LD_LIBRARY_PATH
2948         AC_MSG_NOTICE([Added $IDN_DIR to LD_LIBRARY_PATH])
2949       fi
2950     else
2951       AC_MSG_WARN([Libraries for IDN support too old: IDN disabled])
2952       CPPFLAGS="$clean_CPPFLAGS"
2953       LDFLAGS="$clean_LDFLAGS"
2954       LIBS="$clean_LIBS"
2955     fi
2956   else
2957     AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
2958     CPPFLAGS="$clean_CPPFLAGS"
2959     LDFLAGS="$clean_LDFLAGS"
2960     LIBS="$clean_LIBS"
2961   fi
2962 fi
2963
2964
2965 dnl Let's hope this split URL remains working:
2966 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
2967 dnl genprogc/thread_quick_ref.htm
2968
2969
2970 dnl **********************************************************************
2971 dnl Check for nghttp2
2972 dnl **********************************************************************
2973
2974 OPT_H2="yes"
2975 AC_ARG_WITH(nghttp2,
2976 AC_HELP_STRING([--with-nghttp2=PATH],[Enable nghttp2 usage])
2977 AC_HELP_STRING([--without-nghttp2],[Disable nghttp2 usage]),
2978   [OPT_H2=$withval])
2979 case "$OPT_H2" in
2980   no)
2981     dnl --without-nghttp2 option used
2982     want_h2="no"
2983     ;;
2984   yes)
2985     dnl --with-nghttp2 option used without path
2986     want_h2="default"
2987     want_h2_path=""
2988     ;;
2989   *)
2990     dnl --with-nghttp2 option used with path
2991     want_h2="yes"
2992     want_h2_path="$withval/lib/pkgconfig"
2993     ;;
2994 esac
2995
2996 curl_h2_msg="disabled (--with-nghttp2)"
2997 if test X"$want_h2" != Xno; then
2998   dnl backup the pre-nghttp2 variables
2999   CLEANLDFLAGS="$LDFLAGS"
3000   CLEANCPPFLAGS="$CPPFLAGS"
3001   CLEANLIBS="$LIBS"
3002
3003   CURL_CHECK_PKGCONFIG(libnghttp2, $want_h2_path)
3004
3005   if test "$PKGCONFIG" != "no" ; then
3006     LIB_H2=`CURL_EXPORT_PCDIR([$want_h2_path])
3007       $PKGCONFIG --libs-only-l libnghttp2`
3008     AC_MSG_NOTICE([-l is $LIB_H2])
3009
3010     CPP_H2=`CURL_EXPORT_PCDIR([$want_h2_path]) dnl
3011       $PKGCONFIG --cflags-only-I libnghttp2`
3012     AC_MSG_NOTICE([-I is $CPP_H2])
3013
3014     LD_H2=`CURL_EXPORT_PCDIR([$want_h2_path])
3015       $PKGCONFIG --libs-only-L libnghttp2`
3016     AC_MSG_NOTICE([-L is $LD_H2])
3017
3018     LDFLAGS="$LDFLAGS $LD_H2"
3019     CPPFLAGS="$CPPFLAGS $CPP_H2"
3020     LIBS="$LIB_H2 $LIBS"
3021
3022     # use nghttp2_option_set_no_recv_client_magic to require nghttp2
3023     # >= 1.0.0
3024     AC_CHECK_LIB(nghttp2, nghttp2_option_set_no_recv_client_magic,
3025       [
3026        AC_CHECK_HEADERS(nghttp2/nghttp2.h,
3027           curl_h2_msg="enabled (nghttp2)"
3028           NGHTTP2_ENABLED=1
3029           AC_DEFINE(USE_NGHTTP2, 1, [if nghttp2 is in use])
3030           AC_SUBST(USE_NGHTTP2, [1])
3031        )
3032       ],
3033         dnl not found, revert back to clean variables
3034         LDFLAGS=$CLEANLDFLAGS
3035         CPPFLAGS=$CLEANCPPFLAGS
3036         LIBS=$CLEANLIBS
3037     )
3038
3039   else
3040     dnl no nghttp2 pkg-config found, deal with it
3041     if test X"$want_h2" != Xdefault; then
3042       dnl To avoid link errors, we do not allow --with-nghttp2 without
3043       dnl a pkgconfig file
3044       AC_MSG_ERROR([--with-nghttp2 was specified but could not find libnghttp2 pkg-config file.])
3045     fi
3046   fi
3047
3048 fi
3049
3050 dnl **********************************************************************
3051 dnl Check for zsh completion path
3052 dnl **********************************************************************
3053
3054 OPT_ZSH_FPATH=default
3055 AC_ARG_WITH(zsh-functions-dir,
3056 AC_HELP_STRING([--with-zsh-functions-dir=PATH],[Install zsh completions to PATH])
3057 AC_HELP_STRING([--without-zsh-functions-dir],[Do not install zsh completions]),
3058   [OPT_ZSH_FPATH=$withval])
3059 case "$OPT_ZSH_FPATH" in
3060   no)
3061     dnl --without-zsh-functions-dir option used
3062     ;;
3063   default|yes)
3064     dnl --with-zsh-functions-dir option used without path
3065     ZSH_FUNCTIONS_DIR="$datarootdir/zsh/site-functions"
3066     AC_SUBST(ZSH_FUNCTIONS_DIR)
3067     ;;
3068   *)
3069     dnl --with-zsh-functions-dir option used with path
3070     ZSH_FUNCTIONS_DIR="$withval"
3071     AC_SUBST(ZSH_FUNCTIONS_DIR)
3072     ;;
3073 esac
3074
3075 dnl **********************************************************************
3076 dnl Back to "normal" configuring
3077 dnl **********************************************************************
3078
3079 dnl Checks for header files.
3080 AC_HEADER_STDC
3081
3082 CURL_CHECK_HEADER_MALLOC
3083 CURL_CHECK_HEADER_MEMORY
3084
3085 dnl Now check for the very most basic headers. Then we can use these
3086 dnl ones as default-headers when checking for the rest!
3087 AC_CHECK_HEADERS(
3088         sys/types.h \
3089         sys/time.h \
3090         sys/select.h \
3091         sys/socket.h \
3092         sys/ioctl.h \
3093         sys/uio.h \
3094         assert.h \
3095         unistd.h \
3096         stdlib.h \
3097         limits.h \
3098         arpa/inet.h \
3099         net/if.h \
3100         netinet/in.h \
3101         sys/un.h \
3102         netinet/tcp.h \
3103         netdb.h \
3104         sys/sockio.h \
3105         sys/stat.h \
3106         sys/param.h \
3107         termios.h \
3108         termio.h \
3109         sgtty.h \
3110         fcntl.h \
3111         alloca.h \
3112         time.h \
3113         io.h \
3114         pwd.h \
3115         utime.h \
3116         sys/utime.h \
3117         sys/poll.h \
3118         poll.h \
3119         socket.h \
3120         sys/resource.h \
3121         libgen.h \
3122         locale.h \
3123         errno.h \
3124         stdbool.h \
3125         arpa/tftp.h \
3126         sys/filio.h \
3127         sys/wait.h \
3128         setjmp.h,
3129 dnl to do if not found
3130 [],
3131 dnl to do if found
3132 [],
3133 dnl default includes
3134 [
3135 #ifdef HAVE_SYS_TYPES_H
3136 #include <sys/types.h>
3137 #endif
3138 #ifdef HAVE_SYS_TIME_H
3139 #include <sys/time.h>
3140 #endif
3141 #ifdef HAVE_SYS_SELECT_H
3142 #include <sys/select.h>
3143 #endif
3144 #ifdef HAVE_SYS_SOCKET_H
3145 #include <sys/socket.h>
3146 #endif
3147 #ifdef HAVE_NETINET_IN_H
3148 #include <netinet/in.h>
3149 #endif
3150 #ifdef HAVE_SYS_UN_H
3151 #include <sys/un.h>
3152 #endif
3153 ]
3154 )
3155
3156 dnl Checks for typedefs, structures, and compiler characteristics.
3157 AC_C_CONST
3158 CURL_CHECK_VARIADIC_MACROS
3159 AC_TYPE_SIZE_T
3160 AC_HEADER_TIME
3161 CURL_CHECK_STRUCT_TIMEVAL
3162 CURL_VERIFY_RUNTIMELIBS
3163
3164 AC_CHECK_SIZEOF(size_t)
3165 AC_CHECK_SIZEOF(long)
3166 AC_CHECK_SIZEOF(int)
3167 AC_CHECK_SIZEOF(short)
3168 CURL_CONFIGURE_LONG
3169 AC_CHECK_SIZEOF(time_t)
3170 AC_CHECK_SIZEOF(off_t)
3171
3172 soname_bump=no
3173 if test x"$ac_cv_native_windows" != "xyes" &&
3174    test $ac_cv_sizeof_off_t -ne $curl_sizeof_curl_off_t; then
3175   AC_MSG_WARN([This libcurl built is probably not ABI compatible with previous])
3176   AC_MSG_WARN([builds! You MUST read lib/README.curl_off_t to figure it out.])
3177   soname_bump=yes
3178 fi
3179
3180
3181 AC_CHECK_TYPE(long long,
3182    [AC_DEFINE(HAVE_LONGLONG, 1,
3183       [Define to 1 if the compiler supports the 'long long' data type.])]
3184    longlong="yes"
3185 )
3186
3187 if test "xyes" = "x$longlong"; then
3188   AC_MSG_CHECKING([if numberLL works])
3189   AC_COMPILE_IFELSE([
3190     AC_LANG_PROGRAM([[
3191     ]],[[
3192       long long val = 1000LL;
3193     ]])
3194   ],[
3195     AC_MSG_RESULT([yes])
3196     AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
3197   ],[
3198     AC_MSG_RESULT([no])
3199   ])
3200 fi
3201
3202
3203 # check for ssize_t
3204 AC_CHECK_TYPE(ssize_t, ,
3205    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
3206
3207 # check for bool type
3208 AC_CHECK_TYPE([bool],[
3209   AC_DEFINE(HAVE_BOOL_T, 1,
3210     [Define to 1 if bool is an available type.])
3211 ], ,[
3212 #ifdef HAVE_SYS_TYPES_H
3213 #include <sys/types.h>
3214 #endif
3215 #ifdef HAVE_STDBOOL_H
3216 #include <stdbool.h>
3217 #endif
3218 ])
3219
3220 CURL_CONFIGURE_CURL_SOCKLEN_T
3221
3222 CURL_CONFIGURE_PULL_SYS_POLL
3223
3224 TYPE_IN_ADDR_T
3225
3226 TYPE_SOCKADDR_STORAGE
3227
3228 TYPE_SIG_ATOMIC_T
3229
3230 AC_TYPE_SIGNAL
3231
3232 CURL_CHECK_FUNC_SELECT
3233
3234 CURL_CHECK_FUNC_RECV
3235 CURL_CHECK_FUNC_SEND
3236 CURL_CHECK_MSG_NOSIGNAL
3237
3238 CURL_CHECK_FUNC_ALARM
3239 CURL_CHECK_FUNC_BASENAME
3240 CURL_CHECK_FUNC_CLOSESOCKET
3241 CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
3242 CURL_CHECK_FUNC_CONNECT
3243 CURL_CHECK_FUNC_FCNTL
3244 CURL_CHECK_FUNC_FDOPEN
3245 CURL_CHECK_FUNC_FREEADDRINFO
3246 CURL_CHECK_FUNC_FREEIFADDRS
3247 CURL_CHECK_FUNC_FSETXATTR
3248 CURL_CHECK_FUNC_FTRUNCATE
3249 CURL_CHECK_FUNC_GETADDRINFO
3250 CURL_CHECK_FUNC_GAI_STRERROR
3251 CURL_CHECK_FUNC_GETHOSTBYADDR
3252 CURL_CHECK_FUNC_GETHOSTBYADDR_R
3253 CURL_CHECK_FUNC_GETHOSTBYNAME
3254 CURL_CHECK_FUNC_GETHOSTBYNAME_R
3255 CURL_CHECK_FUNC_GETHOSTNAME
3256 CURL_CHECK_FUNC_GETIFADDRS
3257 CURL_CHECK_FUNC_GETSERVBYPORT_R
3258 CURL_CHECK_FUNC_GMTIME_R
3259 CURL_CHECK_FUNC_INET_NTOA_R
3260 CURL_CHECK_FUNC_INET_NTOP
3261 CURL_CHECK_FUNC_INET_PTON
3262 CURL_CHECK_FUNC_IOCTL
3263 CURL_CHECK_FUNC_IOCTLSOCKET
3264 CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
3265 CURL_CHECK_FUNC_LOCALTIME_R
3266 CURL_CHECK_FUNC_MEMRCHR
3267 CURL_CHECK_FUNC_POLL
3268 CURL_CHECK_FUNC_SETSOCKOPT
3269 CURL_CHECK_FUNC_SIGACTION
3270 CURL_CHECK_FUNC_SIGINTERRUPT
3271 CURL_CHECK_FUNC_SIGNAL
3272 CURL_CHECK_FUNC_SIGSETJMP
3273 CURL_CHECK_FUNC_SOCKET
3274 CURL_CHECK_FUNC_SOCKETPAIR
3275 CURL_CHECK_FUNC_STRCASECMP
3276 CURL_CHECK_FUNC_STRCMPI
3277 CURL_CHECK_FUNC_STRDUP
3278 CURL_CHECK_FUNC_STRERROR_R
3279 CURL_CHECK_FUNC_STRICMP
3280 CURL_CHECK_FUNC_STRNCASECMP
3281 CURL_CHECK_FUNC_STRNCMPI
3282 CURL_CHECK_FUNC_STRNICMP
3283 CURL_CHECK_FUNC_STRSTR
3284 CURL_CHECK_FUNC_STRTOK_R
3285 CURL_CHECK_FUNC_STRTOLL
3286 CURL_CHECK_FUNC_WRITEV
3287
3288 case $host in
3289   *msdosdjgpp)
3290      ac_cv_func_pipe=no
3291      skipcheck_pipe=yes
3292      AC_MSG_NOTICE([skip check for pipe on msdosdjgpp])
3293     ;;
3294 esac
3295
3296 AC_CHECK_FUNCS([fork \
3297   geteuid \
3298   getpass_r \
3299   getppid \
3300   getprotobyname \
3301   getpwuid \
3302   getpwuid_r \
3303   getrlimit \
3304   gettimeofday \
3305   if_nametoindex \
3306   inet_addr \
3307   perror \
3308   pipe \
3309   setlocale \
3310   setmode \
3311   setrlimit \
3312   uname \
3313   utime
3314 ],[
3315 ],[
3316   func="$ac_func"
3317   eval skipcheck=\$skipcheck_$func
3318   if test "x$skipcheck" != "xyes"; then
3319     AC_MSG_CHECKING([deeper for $func])
3320     AC_LINK_IFELSE([
3321       AC_LANG_PROGRAM([[
3322       ]],[[
3323         $func ();
3324       ]])
3325     ],[
3326       AC_MSG_RESULT([yes])
3327       eval "ac_cv_func_$func=yes"
3328       AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
3329         [Define to 1 if you have the $func function.])
3330     ],[
3331       AC_MSG_RESULT([but still no])
3332     ])
3333   fi
3334 ])
3335
3336 dnl Check if the getnameinfo function is available
3337 dnl and get the types of five of its arguments.
3338 CURL_CHECK_FUNC_GETNAMEINFO
3339
3340 if test "$ipv6" = "yes"; then
3341   if test "$ac_cv_func_getaddrinfo" = "yes"; then
3342     AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
3343     IPV6_ENABLED=1
3344     AC_SUBST(IPV6_ENABLED)
3345   fi
3346   CURL_CHECK_NI_WITHSCOPEID
3347 fi
3348
3349 CURL_CHECK_NONBLOCKING_SOCKET
3350
3351 dnl ************************************************************
3352 dnl nroff tool stuff
3353 dnl
3354
3355 AC_PATH_PROG( PERL, perl, ,
3356   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
3357 AC_SUBST(PERL)
3358
3359 AC_PATH_PROGS( NROFF, gnroff nroff, ,
3360   $PATH:/usr/bin/:/usr/local/bin )
3361 AC_SUBST(NROFF)
3362
3363 if test -n "$NROFF"; then
3364   dnl only check for nroff options if an nroff command was found
3365
3366   AC_MSG_CHECKING([how to use *nroff to get plain text from man pages])
3367   MANOPT="-man"
3368   mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
3369   if test -z "$mancheck"; then
3370     MANOPT="-mandoc"
3371    mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
3372     if test -z "$mancheck"; then
3373       MANOPT=""
3374       AC_MSG_RESULT([failed])
3375       AC_MSG_WARN([found no *nroff option to get plaintext from man pages])
3376     else
3377       AC_MSG_RESULT([$MANOPT])
3378     fi
3379   else
3380     AC_MSG_RESULT([$MANOPT])
3381   fi
3382   AC_SUBST(MANOPT)
3383 fi
3384
3385 if test -z "$MANOPT"
3386 then
3387   dnl if no nroff tool was found, or no option that could convert man pages
3388   dnl was found, then disable the built-in manual stuff
3389   AC_MSG_WARN([disabling built-in manual])
3390   USE_MANUAL="no";
3391 fi
3392
3393 dnl *************************************************************************
3394 dnl If the manual variable still is set, then we go with providing a built-in
3395 dnl manual
3396
3397 if test "$USE_MANUAL" = "1"; then
3398   AC_DEFINE(USE_MANUAL, 1, [If you want to build curl with the built-in manual])
3399   curl_manual_msg="enabled"
3400 fi
3401
3402 dnl set variable for use in automakefile(s)
3403 AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1)
3404
3405 CURL_CHECK_LIB_ARES
3406 AM_CONDITIONAL(USE_EMBEDDED_ARES, test x$embedded_ares = xyes)
3407
3408 if test "x$ac_cv_native_windows" != "xyes" &&
3409    test "x$enable_shared" = "xyes"; then
3410   build_libhostname=yes
3411 else
3412   build_libhostname=no
3413 fi
3414 AM_CONDITIONAL(BUILD_LIBHOSTNAME, test x$build_libhostname = xyes)
3415
3416 CURL_CHECK_OPTION_THREADED_RESOLVER
3417
3418 if test "x$want_thres" = xyes && test "x$want_ares" = xyes; then
3419   AC_MSG_ERROR(
3420 [Options --enable-threaded-resolver and --enable-ares are mutually exclusive])
3421 fi
3422
3423 if test "$want_thres" = "yes" && test "$dontwant_rt" = "no"; then
3424   AC_CHECK_HEADER(pthread.h,
3425     [ AC_DEFINE(HAVE_PTHREAD_H, 1, [if you have <pthread.h>])
3426       save_CFLAGS="$CFLAGS"
3427
3428       dnl first check for function without lib
3429       AC_CHECK_FUNC(pthread_create, [USE_THREADS_POSIX=1] )
3430
3431       dnl if it wasn't found without lib, search for it in pthread lib
3432       if test "$USE_THREADS_POSIX" != "1"
3433       then
3434         CFLAGS="$CFLAGS -pthread"
3435         AC_CHECK_LIB(pthread, pthread_create,
3436                      [USE_THREADS_POSIX=1],
3437                      [ CFLAGS="$save_CFLAGS"])
3438       fi
3439
3440       if test "x$USE_THREADS_POSIX" = "x1"
3441       then
3442         AC_DEFINE(USE_THREADS_POSIX, 1, [if you want POSIX threaded DNS lookup])
3443         curl_res_msg="POSIX threaded"
3444       fi
3445
3446
3447   ])
3448 fi
3449
3450 dnl ************************************************************
3451 dnl disable verbose text strings
3452 dnl
3453 AC_MSG_CHECKING([whether to enable verbose strings])
3454 AC_ARG_ENABLE(verbose,
3455 AC_HELP_STRING([--enable-verbose],[Enable verbose strings])
3456 AC_HELP_STRING([--disable-verbose],[Disable verbose strings]),
3457 [ case "$enableval" in
3458   no)
3459        AC_MSG_RESULT(no)
3460        AC_DEFINE(CURL_DISABLE_VERBOSE_STRINGS, 1, [to disable verbose strings])
3461        curl_verbose_msg="no"
3462        ;;
3463   *)   AC_MSG_RESULT(yes)
3464        ;;
3465   esac ],
3466        AC_MSG_RESULT(yes)
3467 )
3468
3469 dnl ************************************************************
3470 dnl enable SSPI support
3471 dnl
3472 AC_MSG_CHECKING([whether to enable SSPI support (Windows native builds only)])
3473 AC_ARG_ENABLE(sspi,
3474 AC_HELP_STRING([--enable-sspi],[Enable SSPI])
3475 AC_HELP_STRING([--disable-sspi],[Disable SSPI]),
3476 [ case "$enableval" in
3477   yes)
3478        if test "$ac_cv_native_windows" = "yes"; then
3479          AC_MSG_RESULT(yes)
3480          AC_DEFINE(USE_WINDOWS_SSPI, 1, [to enable SSPI support])
3481          AC_SUBST(USE_WINDOWS_SSPI, [1])
3482          curl_sspi_msg="enabled"
3483        else
3484          AC_MSG_RESULT(no)
3485          AC_MSG_WARN([--enable-sspi Ignored. Only supported on native Windows builds.])
3486        fi
3487        ;;
3488   *)
3489        if test "x$WINSSL_ENABLED" = "x1"; then
3490          # --with-winssl implies --enable-sspi
3491          AC_MSG_RESULT(yes)
3492        else
3493          AC_MSG_RESULT(no)
3494        fi
3495        ;;
3496   esac ],
3497        if test "x$WINSSL_ENABLED" = "x1"; then
3498          # --with-winssl implies --enable-sspi
3499          AC_MSG_RESULT(yes)
3500        else
3501          AC_MSG_RESULT(no)
3502        fi
3503 )
3504
3505 dnl ************************************************************
3506 dnl disable cryptographic authentication
3507 dnl
3508 AC_MSG_CHECKING([whether to enable cryptographic authentication methods])
3509 AC_ARG_ENABLE(crypto-auth,
3510 AC_HELP_STRING([--enable-crypto-auth],[Enable cryptographic authentication])
3511 AC_HELP_STRING([--disable-crypto-auth],[Disable cryptographic authentication]),
3512 [ case "$enableval" in
3513   no)
3514        AC_MSG_RESULT(no)
3515        AC_DEFINE(CURL_DISABLE_CRYPTO_AUTH, 1, [to disable cryptographic authentication])
3516        CURL_DISABLE_CRYPTO_AUTH=1
3517        ;;
3518   *)   AC_MSG_RESULT(yes)
3519        ;;
3520   esac ],
3521        AC_MSG_RESULT(yes)
3522 )
3523
3524 CURL_CHECK_OPTION_NTLM_WB
3525
3526 CURL_CHECK_NTLM_WB
3527
3528 dnl ************************************************************
3529 dnl disable TLS-SRP authentication
3530 dnl
3531 AC_MSG_CHECKING([whether to enable TLS-SRP authentication])
3532 AC_ARG_ENABLE(tls-srp,
3533 AC_HELP_STRING([--enable-tls-srp],[Enable TLS-SRP authentication])
3534 AC_HELP_STRING([--disable-tls-srp],[Disable TLS-SRP authentication]),
3535 [ case "$enableval" in
3536   no)
3537        AC_MSG_RESULT(no)
3538        AC_DEFINE(CURL_DISABLE_TLS_SRP, 1, [to disable TLS-SRP authentication])
3539        want_tls_srp=no
3540        ;;
3541   *)   AC_MSG_RESULT(yes)
3542        want_tls_srp=yes
3543        ;;
3544   esac ],
3545        AC_MSG_RESULT(yes)
3546        want_tls_srp=yes
3547 )
3548
3549 if test "$want_tls_srp" = "yes" && ( test "x$HAVE_GNUTLS_SRP" = "x1" || test "x$HAVE_OPENSSL_SRP" = "x1") ; then
3550    AC_DEFINE(USE_TLS_SRP, 1, [Use TLS-SRP authentication])
3551    USE_TLS_SRP=1
3552    curl_tls_srp_msg="enabled"
3553 fi
3554
3555 dnl ************************************************************
3556 dnl disable Unix domain sockets support
3557 dnl
3558 AC_MSG_CHECKING([whether to enable Unix domain sockets])
3559 AC_ARG_ENABLE(unix-sockets,
3560 AC_HELP_STRING([--enable-unix-sockets],[Enable Unix domain sockets])
3561 AC_HELP_STRING([--disable-unix-sockets],[Disable Unix domain sockets]),
3562 [ case "$enableval" in
3563   no)  AC_MSG_RESULT(no)
3564        want_unix_sockets=no
3565        ;;
3566   *)   AC_MSG_RESULT(yes)
3567        want_unix_sockets=yes
3568        ;;
3569   esac ], [
3570        AC_MSG_RESULT(auto)
3571        want_unix_sockets=auto
3572        ]
3573 )
3574 if test "x$want_unix_sockets" != "xno"; then
3575   AC_CHECK_MEMBER([struct sockaddr_un.sun_path], [
3576     AC_DEFINE(USE_UNIX_SOCKETS, 1, [Use Unix domain sockets])
3577     AC_SUBST(USE_UNIX_SOCKETS, [1])
3578     curl_unix_sockets_msg="enabled"
3579   ], [
3580     if test "x$want_unix_sockets" = "xyes"; then
3581       AC_MSG_ERROR([--enable-unix-sockets is not available on this platform!])
3582     fi
3583   ], [
3584     #include <sys/un.h>
3585   ])
3586 fi
3587
3588 dnl ************************************************************
3589 dnl disable cookies support
3590 dnl
3591 AC_MSG_CHECKING([whether to enable support for cookies])
3592 AC_ARG_ENABLE(cookies,
3593 AC_HELP_STRING([--enable-cookies],[Enable cookies support])
3594 AC_HELP_STRING([--disable-cookies],[Disable cookies support]),
3595 [ case "$enableval" in
3596   no)
3597        AC_MSG_RESULT(no)
3598        AC_DEFINE(CURL_DISABLE_COOKIES, 1, [to disable cookies support])
3599        ;;
3600   *)   AC_MSG_RESULT(yes)
3601        ;;
3602   esac ],
3603        AC_MSG_RESULT(yes)
3604 )
3605
3606 dnl ************************************************************
3607 dnl hiding of library internal symbols
3608 dnl
3609 CURL_CONFIGURE_SYMBOL_HIDING
3610
3611 dnl ************************************************************
3612 dnl enforce SONAME bump
3613 dnl
3614
3615 AC_MSG_CHECKING([whether to enforce SONAME bump])
3616 AC_ARG_ENABLE(soname-bump,
3617 AC_HELP_STRING([--enable-soname-bump],[Enable enforced SONAME bump])
3618 AC_HELP_STRING([--disable-soname-bump],[Disable enforced SONAME bump]),
3619 [ case "$enableval" in
3620   yes)   AC_MSG_RESULT(yes)
3621          soname_bump=yes
3622          ;;
3623   *)
3624          AC_MSG_RESULT(no)
3625          ;;
3626   esac ],
3627         AC_MSG_RESULT($soname_bump)
3628 )
3629 AM_CONDITIONAL(SONAME_BUMP, test x$soname_bump = xyes)
3630
3631 dnl
3632 dnl All the library dependencies put into $LIB apply to libcurl only.
3633 dnl
3634 LIBCURL_LIBS=$LIBS
3635
3636 AC_SUBST(LIBCURL_LIBS)
3637 AC_SUBST(CURL_NETWORK_LIBS)
3638 AC_SUBST(CURL_NETWORK_AND_TIME_LIBS)
3639
3640 dnl BLANK_AT_MAKETIME may be used in our Makefile.am files to blank
3641 dnl LIBS variable used in generated makefile at makefile processing
3642 dnl time. Doing this functionally prevents LIBS from being used for
3643 dnl all link targets in given makefile.
3644 BLANK_AT_MAKETIME=
3645 AC_SUBST(BLANK_AT_MAKETIME)
3646
3647 AM_CONDITIONAL(CROSSCOMPILING, test x$cross_compiling = xyes)
3648
3649 dnl yes or no
3650 ENABLE_SHARED="$enable_shared"
3651 AC_SUBST(ENABLE_SHARED)
3652
3653 dnl to let curl-config output the static libraries correctly
3654 ENABLE_STATIC="$enable_static"
3655 AC_SUBST(ENABLE_STATIC)
3656
3657
3658 dnl
3659 dnl For keeping supported features and protocols also in pkg-config file
3660 dnl since it is more cross-compile friendly than curl-config
3661 dnl
3662
3663 if test "x$OPENSSL_ENABLED" = "x1"; then
3664   SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
3665 elif test -n "$SSL_ENABLED"; then
3666   SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
3667 fi
3668 if test "x$IPV6_ENABLED" = "x1"; then
3669   SUPPORT_FEATURES="$SUPPORT_FEATURES IPv6"
3670 fi
3671 if test "x$USE_UNIX_SOCKETS" = "x1"; then
3672   SUPPORT_FEATURES="$SUPPORT_FEATURES UnixSockets"
3673 fi
3674 if test "x$HAVE_LIBZ" = "x1"; then
3675   SUPPORT_FEATURES="$SUPPORT_FEATURES libz"
3676 fi
3677 if test "x$USE_ARES" = "x1" -o "x$USE_THREADS_POSIX" = "x1"; then
3678   SUPPORT_FEATURES="$SUPPORT_FEATURES AsynchDNS"
3679 fi
3680 if test "x$IDN_ENABLED" = "x1"; then
3681   SUPPORT_FEATURES="$SUPPORT_FEATURES IDN"
3682 fi
3683 if test "x$USE_WINDOWS_SSPI" = "x1"; then
3684   SUPPORT_FEATURES="$SUPPORT_FEATURES SSPI"
3685 fi
3686
3687 if test "x$HAVE_GSSAPI" = "x1"; then
3688   SUPPORT_FEATURES="$SUPPORT_FEATURES GSS-API"
3689 fi
3690
3691 if test "x$curl_psl_msg" = "xyes"; then
3692   SUPPORT_FEATURES="$SUPPORT_FEATURES PSL"
3693 fi
3694
3695 if test "x$CURL_DISABLE_CRYPTO_AUTH" != "x1" -a \
3696     \( "x$HAVE_GSSAPI" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \); then
3697   SUPPORT_FEATURES="$SUPPORT_FEATURES SPNEGO"
3698 fi
3699
3700 if test "x$CURL_DISABLE_CRYPTO_AUTH" != "x1" -a \
3701     \( "x$HAVE_GSSAPI" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \); then
3702   SUPPORT_FEATURES="$SUPPORT_FEATURES Kerberos"
3703 fi
3704
3705 if test "x$CURL_DISABLE_CRYPTO_AUTH" != "x1"; then
3706   if test "x$OPENSSL_ENABLED" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \
3707       -o "x$GNUTLS_ENABLED" = "x1" -o "x$NSS_ENABLED" = "x1" \
3708       -o "x$DARWINSSL_ENABLED" = "x1"; then
3709     SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM"
3710
3711     if test "x$CURL_DISABLE_HTTP" != "x1" -a \
3712         "x$NTLM_WB_ENABLED" = "x1"; then
3713       SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM_WB"
3714     fi
3715   fi
3716 fi
3717
3718 if test "x$USE_TLS_SRP" = "x1"; then
3719   SUPPORT_FEATURES="$SUPPORT_FEATURES TLS-SRP"
3720 fi
3721
3722 if test "x$USE_NGHTTP2" = "x1"; then
3723   SUPPORT_FEATURES="$SUPPORT_FEATURES HTTP2"
3724 fi
3725
3726 AC_SUBST(SUPPORT_FEATURES)
3727
3728 dnl For supported protocols in pkg-config file
3729 if test "x$CURL_DISABLE_HTTP" != "x1"; then
3730   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTP"
3731   if test "x$SSL_ENABLED" = "x1"; then
3732     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTPS"
3733   fi
3734 fi
3735 if test "x$CURL_DISABLE_FTP" != "x1"; then
3736   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTP"
3737   if test "x$SSL_ENABLED" = "x1"; then
3738     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTPS"
3739   fi
3740 fi
3741 if test "x$CURL_DISABLE_FILE" != "x1"; then
3742   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FILE"
3743 fi
3744 if test "x$CURL_DISABLE_TELNET" != "x1"; then
3745   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TELNET"
3746 fi
3747 if test "x$CURL_DISABLE_LDAP" != "x1"; then
3748   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAP"
3749   if test "x$CURL_DISABLE_LDAPS" != "x1"; then
3750     if (test "x$USE_OPENLDAP" = "x1" && test "x$SSL_ENABLED" = "x1") ||
3751       (test "x$USE_OPENLDAP" != "x1"  && test "x$HAVE_LDAP_SSL" = "x1"); then
3752       SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAPS"
3753     fi
3754   fi
3755 fi
3756 if test "x$CURL_DISABLE_DICT" != "x1"; then
3757   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS DICT"
3758 fi
3759 if test "x$CURL_DISABLE_TFTP" != "x1"; then
3760   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TFTP"
3761 fi
3762 if test "x$CURL_DISABLE_GOPHER" != "x1"; then
3763   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS GOPHER"
3764 fi
3765 if test "x$CURL_DISABLE_POP3" != "x1"; then
3766   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3"
3767   if test "x$SSL_ENABLED" = "x1"; then
3768     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3S"
3769   fi
3770 fi
3771 if test "x$CURL_DISABLE_IMAP" != "x1"; then
3772   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAP"
3773   if test "x$SSL_ENABLED" = "x1"; then
3774     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAPS"
3775   fi
3776 fi
3777 if test "x$CURL_DISABLE_SMB" != "x1" \
3778     -a "x$CURL_DISABLE_CRYPTO_AUTH" != "x1" \
3779     -a \( "x$OPENSSL_ENABLED" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \
3780       -o "x$GNUTLS_ENABLED" = "x1" -o "x$NSS_ENABLED" = "x1" \
3781       -o "x$DARWINSSL_ENABLED" = "x1" \); then
3782   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMB"
3783   if test "x$SSL_ENABLED" = "x1"; then
3784     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMBS"
3785   fi
3786 fi
3787 if test "x$CURL_DISABLE_SMTP" != "x1"; then
3788   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTP"
3789   if test "x$SSL_ENABLED" = "x1"; then
3790     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTPS"
3791   fi
3792 fi
3793 if test "x$USE_LIBSSH2" = "x1"; then
3794   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
3795   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
3796 fi
3797 if test "x$CURL_DISABLE_RTSP" != "x1"; then
3798   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTSP"
3799 fi
3800 if test "x$USE_LIBRTMP" = "x1"; then
3801   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTMP"
3802 fi
3803
3804 dnl replace spaces with newlines
3805 dnl sort the lines
3806 dnl replace the newlines back to spaces
3807 SUPPORT_PROTOCOLS=`echo $SUPPORT_PROTOCOLS | tr ' ' '\012' | sort | tr '\012' ' '`
3808
3809 AC_SUBST(SUPPORT_PROTOCOLS)
3810
3811 dnl squeeze whitespace out of some variables
3812
3813 squeeze CFLAGS
3814 squeeze CPPFLAGS
3815 squeeze DEFS
3816 squeeze LDFLAGS
3817 squeeze LIBS
3818
3819 squeeze LIBCURL_LIBS
3820 squeeze CURL_NETWORK_LIBS
3821 squeeze CURL_NETWORK_AND_TIME_LIBS
3822
3823 squeeze SUPPORT_FEATURES
3824 squeeze SUPPORT_PROTOCOLS
3825
3826 XC_CHECK_BUILD_FLAGS
3827
3828 if test "x$want_curldebug_assumed" = "xyes" &&
3829   test "x$want_curldebug" = "xyes" && test "x$USE_ARES" = "x1"; then
3830   ac_configure_args="$ac_configure_args --enable-curldebug"
3831 fi
3832
3833 AC_CONFIG_FILES([Makefile \
3834            docs/Makefile \
3835            docs/examples/Makefile \
3836            docs/libcurl/Makefile \
3837            docs/libcurl/opts/Makefile \
3838            include/Makefile \
3839            include/curl/Makefile \
3840            src/Makefile \
3841            lib/Makefile \
3842            lib/libcurl.vers \
3843            tests/Makefile \
3844            tests/certs/Makefile \
3845            tests/certs/scripts/Makefile \
3846            tests/data/Makefile \
3847            tests/server/Makefile \
3848            tests/libtest/Makefile \
3849            tests/unit/Makefile \
3850            packages/Makefile \
3851            packages/Win32/Makefile \
3852            packages/Win32/cygwin/Makefile \
3853            packages/Linux/Makefile \
3854            packages/Linux/RPM/Makefile \
3855            packages/Linux/RPM/curl.spec \
3856            packages/Linux/RPM/curl-ssl.spec \
3857            packages/Solaris/Makefile \
3858            packages/EPM/curl.list \
3859            packages/EPM/Makefile \
3860            packages/vms/Makefile \
3861            packages/AIX/Makefile \
3862            packages/AIX/RPM/Makefile \
3863            packages/AIX/RPM/curl.spec \
3864            curl-config \
3865            libcurl.pc
3866 ])
3867 AC_OUTPUT
3868
3869 CURL_GENERATE_CONFIGUREHELP_PM
3870
3871 XC_AMEND_DISTCLEAN([lib src tests/unit tests/server tests/libtest docs/examples])
3872
3873 AC_MSG_NOTICE([Configured to build curl/libcurl:
3874
3875   curl version:     ${CURLVERSION}
3876   Host setup:       ${host}
3877   Install prefix:   ${prefix}
3878   Compiler:         ${CC}
3879   SSL support:      ${curl_ssl_msg}
3880   SSH support:      ${curl_ssh_msg}
3881   zlib support:     ${curl_zlib_msg}
3882   GSS-API support:  ${curl_gss_msg}
3883   TLS-SRP support:  ${curl_tls_srp_msg}
3884   resolver:         ${curl_res_msg}
3885   IPv6 support:     ${curl_ipv6_msg}
3886   Unix sockets support: ${curl_unix_sockets_msg}
3887   IDN support:      ${curl_idn_msg}
3888   Build libcurl:    Shared=${enable_shared}, Static=${enable_static}
3889   Built-in manual:  ${curl_manual_msg}
3890   --libcurl option: ${curl_libcurl_msg}
3891   Verbose errors:   ${curl_verbose_msg}
3892   SSPI support:     ${curl_sspi_msg}
3893   ca cert bundle:   ${ca}${ca_warning}
3894   ca cert path:     ${capath}${capath_warning}
3895   ca fallback:      ${with_ca_fallback}
3896   LDAP support:     ${curl_ldap_msg}
3897   LDAPS support:    ${curl_ldaps_msg}
3898   RTSP support:     ${curl_rtsp_msg}
3899   RTMP support:     ${curl_rtmp_msg}
3900   metalink support: ${curl_mtlnk_msg}
3901   PSL support:      ${curl_psl_msg}
3902   HTTP2 support:    ${curl_h2_msg}
3903   Protocols:        ${SUPPORT_PROTOCOLS}
3904 ])
3905
3906 if test "x$soname_bump" = "xyes"; then
3907
3908 cat <<EOM
3909   SONAME bump:     yes - WARNING: this library will be built with the SONAME
3910                    number bumped due to (a detected) ABI breakage.
3911                    See lib/README.curl_off_t for details on this.
3912 EOM
3913
3914 fi
3915