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