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