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