now compiler warnings are activated for all gcc builds, not only debug ones.
[platform/upstream/curl.git] / configure.ac
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2008, 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 # $Id$
22 #***************************************************************************
23 dnl Process this file with autoconf to produce a configure script.
24
25 AC_PREREQ(2.57)
26
27 dnl We don't know the version number "statically" so we use a dash here
28 AC_INIT([curl], [-], [a suitable curl mailing list => http://curl.haxx.se/mail/])
29
30 dnl configure script copyright
31 AC_COPYRIGHT([Copyright (c) 1998 - 2008 Daniel Stenberg, <daniel@haxx.se>
32 This configure script may be copied, distributed and modified under the
33 terms of the curl license; see COPYING for more details])
34
35 AC_CONFIG_SRCDIR([lib/urldata.h])
36 AM_CONFIG_HEADER(lib/config.h src/config.h include/curl/curlbuild.h)
37 AM_MAINTAINER_MODE
38
39 dnl SED is mandatory for configure process and libtool.
40 dnl Set it now, allowing it to be changed later.
41 AC_PATH_PROG([SED], [sed], [not_found],
42   [$PATH:/usr/bin:/usr/local/bin])
43 if test -z "$SED" || test "$SED" = "not_found"; then
44   AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
45 fi
46 AC_SUBST([SED])
47
48 dnl GREP is mandatory for configure process and libtool.
49 dnl Set it now, allowing it to be changed later.
50 AC_PATH_PROG([GREP], [grep], [not_found],
51   [$PATH:/usr/bin:/usr/local/bin])
52 if test -z "$GREP" || test "$GREP" = "not_found"; then
53   AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
54 fi
55 AC_SUBST([GREP])
56
57 dnl EGREP is mandatory for configure process and libtool.
58 dnl Set it now, allowing it to be changed later.
59 if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
60   AC_MSG_CHECKING([for egrep])
61   EGREP="$GREP -E"
62   AC_MSG_RESULT([$EGREP])
63 else
64   AC_PATH_PROG([EGREP], [egrep], [not_found],
65     [$PATH:/usr/bin:/usr/local/bin])
66 fi
67 if test -z "$EGREP" || test "$EGREP" = "not_found"; then
68   AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
69 fi
70 AC_SUBST([EGREP])
71
72 dnl AR is mandatory for configure process and libtool.
73 dnl This is target dependant, so check it as a tool.
74 AC_PATH_TOOL([AR], [ar], [not_found],
75   [$PATH:/usr/bin:/usr/local/bin])
76 if test -z "$AR" || test "$AR" = "not_found"; then
77   AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
78 fi
79 AC_SUBST([AR])
80
81 AC_SUBST(libext)
82
83 dnl figure out the libcurl version
84 VERSION=`$SED -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curlver.h`
85 AM_INIT_AUTOMAKE(curl,$VERSION)
86 AC_MSG_CHECKING([curl version])
87 AC_MSG_RESULT($VERSION)
88
89 dnl
90 dnl we extract the numerical version for curl-config only
91 VERSIONNUM=`$SED -ne 's/^#define LIBCURL_VERSION_NUM 0x\(.*\)/\1/p' ${srcdir}/include/curl/curlver.h`
92 AC_SUBST(VERSIONNUM)
93
94 dnl Solaris pkgadd support definitions
95 PKGADD_PKG="HAXXcurl"
96 PKGADD_NAME="cURL - a client that groks URLs"
97 PKGADD_VENDOR="curl.haxx.se"
98 AC_SUBST(PKGADD_PKG)
99 AC_SUBST(PKGADD_NAME)
100 AC_SUBST(PKGADD_VENDOR)
101
102 dnl
103 dnl initialize all the info variables
104     curl_ssl_msg="no      (--with-ssl / --with-gnutls)"
105     curl_ssh_msg="no      (--with-libssh2)"
106    curl_zlib_msg="no      (--with-zlib)"
107    curl_krb4_msg="no      (--with-krb4*)"
108     curl_gss_msg="no      (--with-gssapi)"
109  curl_spnego_msg="no      (--with-spnego)"
110    curl_ares_msg="no      (--enable-ares)"
111    curl_ipv6_msg="no      (--enable-ipv6)"
112     curl_idn_msg="no      (--with-libidn)"
113  curl_manual_msg="no      (--enable-manual)"
114 curl_verbose_msg="enabled (--disable-verbose)"
115    curl_sspi_msg="no      (--enable-sspi)"
116    curl_ldap_msg="no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)"
117   curl_ldaps_msg="no      (--enable-ldaps)"
118
119 dnl
120 dnl Save anything in $LIBS for later
121 dnl
122 ALL_LIBS=$LIBS
123
124 dnl
125 dnl Detect the canonical host and target build environment
126 dnl
127
128 AC_CANONICAL_HOST
129 dnl Get system canonical name
130 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
131
132 dnl Checks for programs.
133 AC_PROG_CC
134
135 dnl Our curl_off_t internal and external configure settings
136 CURL_CONFIGURE_CURL_OFF_T
137
138 dnl This defines _ALL_SOURCE for AIX
139 CURL_CHECK_AIX_ALL_SOURCE
140
141 dnl Our configure and build reentrant settings
142 CURL_CONFIGURE_REENTRANT
143
144 dnl check for how to do large files
145 AC_SYS_LARGEFILE
146
147 dnl support building of Windows DLLs
148 AC_LIBTOOL_WIN32_DLL
149
150 dnl skip libtool C++ and Fortran compiler checks
151 m4_ifdef([AC_PROG_CXX], [m4_undefine([AC_PROG_CXX])])
152 m4_defun([AC_PROG_CXX],[])
153 m4_ifdef([AC_PROG_CXXCPP], [m4_undefine([AC_PROG_CXXCPP])])
154 m4_defun([AC_PROG_CXXCPP],[true])
155 m4_ifdef([AC_PROG_F77], [m4_undefine([AC_PROG_F77])])
156 m4_defun([AC_PROG_F77],[])
157
158 dnl skip libtool C++ and Fortran linker checks
159 m4_ifdef([AC_LIBTOOL_CXX], [m4_undefine([AC_LIBTOOL_CXX])])
160 m4_defun([AC_LIBTOOL_CXX],[])
161 m4_ifdef([AC_LIBTOOL_CXXCPP], [m4_undefine([AC_LIBTOOL_CXXCPP])])
162 m4_defun([AC_LIBTOOL_CXXCPP],[true])
163 m4_ifdef([AC_LIBTOOL_F77], [m4_undefine([AC_LIBTOOL_F77])])
164 m4_defun([AC_LIBTOOL_F77],[])
165
166 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
167 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
168 case $host in
169   x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
170     AC_MSG_RESULT([yes])
171     with_pic=yes
172     ;;
173   *)
174     AC_MSG_RESULT([no])
175     ;;
176 esac
177
178 dnl libtool setup
179 AC_PROG_LIBTOOL
180
181 AC_MSG_CHECKING([if we need -no-undefined])
182 case $host in
183   *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
184     need_no_undefined=yes
185     ;;
186   *)
187     need_no_undefined=no
188     ;;
189 esac
190 AC_MSG_RESULT($need_no_undefined)
191 AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
192
193 AC_MSG_CHECKING([if we need -mimpure-text])
194 mimpure=no
195 case $host in
196   *-*-solaris2*)
197     if test "$GCC" = "yes"; then
198       mimpure="yes"
199     fi
200     ;;
201   *)
202     ;;
203 esac
204 AC_MSG_RESULT($mimpure)
205 AM_CONDITIONAL(MIMPURE, test x$mimpure = xyes)
206 AM_CONDITIONAL(STATICLIB, false)
207
208 AC_MSG_CHECKING([if we need BUILDING_LIBCURL])
209 case $host in
210   *-*-mingw*)
211     AC_DEFINE(BUILDING_LIBCURL, 1, [when building libcurl itself])
212     AC_MSG_RESULT(yes)
213     AC_MSG_CHECKING([if we need CURL_STATICLIB])
214     if test "X$enable_shared" = "Xno"
215     then
216       AC_DEFINE(CURL_STATICLIB, 1, [when not building a shared library])
217       AC_MSG_RESULT(yes)
218       AM_CONDITIONAL(STATICLIB, true)
219     else
220       AC_MSG_RESULT(no)
221     fi
222     ;;
223   *)
224     AC_MSG_RESULT(no)
225     ;;
226 esac
227
228 # Determine whether all dependent libraries must be specified when linking
229 if test "X$enable_shared" = "Xyes" -a "X$link_all_deplibs" = "Xno"
230 then
231     REQUIRE_LIB_DEPS=no
232 else
233     REQUIRE_LIB_DEPS=yes
234 fi
235 AC_SUBST(REQUIRE_LIB_DEPS)
236
237 dnl The install stuff has already been taken care of by the automake stuff
238 dnl AC_PROG_INSTALL
239 AC_PROG_MAKE_SET
240
241 dnl check if there's a way to force code inline
242 AC_C_INLINE
243
244 dnl **********************************************************************
245 dnl platform/compiler/architecture specific checks/flags
246 dnl **********************************************************************
247
248 ac_cv_compiler="unknown"
249 ac_cv_compiler_num="unknown"
250
251 AC_MSG_CHECKING([whether we are using the IBM C compiler])
252 CURL_CHECK_DEF([__IBMC__], [], [silent])
253 if test "$curl_cv_have_def___IBMC__" = "yes"; then
254   AC_MSG_RESULT([yes])
255   ac_cv_compiler="IBMC"
256   dnl Ensure that compiler optimizations are always thread-safe.
257   CFLAGS="$CFLAGS -qthreaded"
258   dnl Disable type based strict aliasing optimizations, using worst
259   dnl case aliasing assumptions when compiling. Type based aliasing
260   dnl would restrict the lvalues that could be safely used to access
261   dnl a data object.
262   CFLAGS="$CFLAGS -qnoansialias"
263   dnl Force compiler to stop after the compilation phase, without
264   dnl generating an object code file when compilation has errors.
265   CFLAGS="$CFLAGS -qhalt=e"
266 else
267   AC_MSG_RESULT([no])
268 fi
269
270 AC_MSG_CHECKING([whether we are using the Intel C compiler])
271 CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
272 if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
273   AC_MSG_RESULT([yes])
274   ac_cv_compiler="ICC"
275   ac_cv_compiler_num="$curl_cv_def___INTEL_COMPILER"
276   dnl On unix this compiler uses gcc's header files, so
277   dnl we select ANSI C89 dialect plus GNU extensions.
278   CPPFLAGS="$CPPFLAGS -std=gnu89"
279   if test "$ac_cv_compiler_num" -gt "600"; then
280     dnl Show errors, warnings, and remarks
281     CPPFLAGS="$CPPFLAGS -Wall"
282     dnl Perform extra compile-time code checking
283     CPPFLAGS="$CPPFLAGS -Wcheck"
284   fi
285   dnl Change some warnings into errors
286   dnl #140: too many arguments in function call
287   dnl #147: declaration is incompatible with 'previous one'
288   dnl #165: too few arguments in function call
289   dnl #266: function declared implicitly
290   CPPFLAGS="$CPPFLAGS -we 140,147,165,266"
291   dnl Disable some remarks
292   dnl #279: controlling expression is constant
293   dnl #981: operands are evaluated in unspecified order
294   dnl #1469: "cc" clobber ignored
295   if test "$ac_cv_compiler_num" -lt "910"; then
296     CPPFLAGS="$CPPFLAGS -wd 279"
297   fi
298   CPPFLAGS="$CPPFLAGS -wd 981,1469"
299   dnl Disable use of ANSI C aliasing rules in optimizations
300   CFLAGS="$CFLAGS -no-ansi-alias"
301   dnl Disable floating point optimizations
302   CFLAGS="$CFLAGS -fp-model precise -mp"
303 else
304   AC_MSG_RESULT([no])
305 fi
306
307 AC_MSG_CHECKING([whether we are using the DEC/Compaq C compiler])
308 CURL_CHECK_DEF([__DECC], [], [silent])
309 CURL_CHECK_DEF([__DECC_VER], [], [silent])
310 if test "$curl_cv_have_def___DECC" = "yes" &&
311   test "$curl_cv_have_def___DECC_VER" = "yes"; then
312   AC_MSG_RESULT([yes])
313   ac_cv_compiler="DECC"
314   dnl Select strict ANSI C compiler mode
315   CFLAGS="$CFLAGS -std1"
316   dnl Turn off optimizer ANSI C aliasing rules
317   CFLAGS="$CFLAGS -noansi_alias"
318   dnl Select a higher warning level than default level2
319   CFLAGS="$CFLAGS -msg_enable level3"
320   dnl Generate warnings for missing function prototypes
321   CFLAGS="$CFLAGS -warnprotos"
322   dnl Change some warnings into fatal errors
323   CFLAGS="$CFLAGS -msg_fatal toofewargs,toomanyargs"
324 else
325   AC_MSG_RESULT([no])
326 fi
327
328 AC_MSG_CHECKING([whether we are using the GNU C compiler])
329 CURL_CHECK_DEF([__GNUC__], [], [silent])
330 if test "$curl_cv_have_def___GNUC__" = "yes" &&
331   test "$ac_cv_compiler" = "unknown"; then
332   AC_MSG_RESULT([yes])
333   ac_cv_compiler="GNUC"
334   gccver=`$CC -dumpversion`
335   gccvhi=`echo $gccver | cut -d . -f1`
336   gccvlo=`echo $gccver | cut -d . -f2`
337   gccnum=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
338   ac_cv_compiler_num="$gccnum"
339   dnl this is a set of options we believe *ALL* gcc versions support:
340   WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
341   dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
342   if test "$ac_cv_compiler_num" -ge "207"; then
343     dnl gcc 2.7 or later
344     WARN="$WARN -Wmissing-declarations"
345   fi
346   if test "$ac_cv_compiler_num" -gt "295"; then
347     dnl only if the compiler is newer than 2.95 since we got lots of
348     dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
349     dnl gcc 2.95.4 on FreeBSD 4.9!
350     WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
351   fi
352   if test "$ac_cv_compiler_num" -ge "296"; then
353     dnl gcc 2.96 or later
354     WARN="$WARN -Wfloat-equal"
355   fi
356   if test "$ac_cv_compiler_num" -gt "296"; then
357     dnl this option does not exist in 2.96
358     WARN="$WARN -Wno-format-nonliteral"
359   fi
360   dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
361   dnl on i686-Linux as it gives us heaps with false positives.
362   dnl Also, on gcc 4.0.X it is totally unbearable and complains all
363   dnl over making it unusable for generic purposes. Let's not use it.
364   if test "$ac_cv_compiler_num" -ge "303"; then
365     dnl gcc 3.3 and later
366     WARN="$WARN -Wendif-labels -Wstrict-prototypes"
367   fi
368   if test "$ac_cv_compiler_num" -ge "304"; then
369     # try these on gcc 3.4
370     WARN="$WARN -Wdeclaration-after-statement"
371   fi
372   for flag in $CPPFLAGS; do
373     case "$flag" in
374       -I*)
375         dnl Include path, provide a -isystem option for the same dir
376         dnl to prevent warnings in those dirs. The -isystem was not very
377         dnl reliable on earlier gcc versions.
378         add=`echo $flag | sed 's/^-I/-isystem /g'`
379         WARN="$WARN $add"
380         ;;
381     esac
382   done
383   CFLAGS="$CFLAGS $WARN"
384   AC_MSG_NOTICE([Added this set of compiler options: $WARN])
385 else
386   AC_MSG_RESULT([no])
387 fi
388
389 case $host in
390   #
391   x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
392     #
393     if test "$ac_cv_compiler" = "ICC"; then
394       #
395       if test "$ac_cv_compiler_num" -ge "900" &&
396         test "$ac_cv_compiler_num" -lt "1000"; then
397         dnl icc 9.X specific
398         CFLAGS="$CFLAGS -i-dynamic"
399       fi
400       #
401       if test "$ac_cv_compiler_num" -ge "1000"; then
402         dnl icc 10.X or later
403         CFLAGS="$CFLAGS -shared-intel"
404       fi
405       #
406     fi
407     ;;
408   #
409 esac
410
411 CURL_CHECK_COMPILER_HALT_ON_ERROR
412 CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
413
414 dnl **********************************************************************
415 dnl Compilation based checks should not be done before this point.
416 dnl **********************************************************************
417
418 dnl **********************************************************************
419 dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
420 dnl and ws2tcpip.h take precedence over any other further checks which
421 dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
422 dnl this specific header files. And do them before its results are used.
423 dnl **********************************************************************
424
425 CURL_CHECK_HEADER_WINDOWS
426 CURL_CHECK_NATIVE_WINDOWS
427 case X-"$ac_cv_native_windows" in
428   X-yes)
429     CURL_CHECK_HEADER_WINSOCK
430     CURL_CHECK_HEADER_WINSOCK2
431     CURL_CHECK_HEADER_WS2TCPIP
432     CURL_CHECK_HEADER_WINLDAP
433     CURL_CHECK_HEADER_WINBER
434     ;;
435   *)
436     ac_cv_header_winsock_h="no"
437     ac_cv_header_winsock2_h="no"
438     ac_cv_header_ws2tcpip_h="no"
439     ac_cv_header_winldap_h="no"
440     ac_cv_header_winber_h="no"
441     ;;
442 esac
443 CURL_CHECK_WIN32_LARGEFILE
444
445 dnl ************************************************************
446 dnl switch off particular protocols
447 dnl
448 AC_MSG_CHECKING([whether to support http])
449 AC_ARG_ENABLE(http,
450 AC_HELP_STRING([--enable-http],[Enable HTTP support])
451 AC_HELP_STRING([--disable-http],[Disable HTTP support]),
452 [ case "$enableval" in
453   no)
454        AC_MSG_RESULT(no)
455        AC_DEFINE(CURL_DISABLE_HTTP, 1, [to disable HTTP])
456        AC_MSG_WARN([disable HTTP disables FTP over proxy])
457        AC_SUBST(CURL_DISABLE_HTTP, [1])
458        ;;
459   *)   AC_MSG_RESULT(yes)
460        ;;
461   esac ],
462        AC_MSG_RESULT(yes)
463 )
464 AC_MSG_CHECKING([whether to support ftp])
465 AC_ARG_ENABLE(ftp,
466 AC_HELP_STRING([--enable-ftp],[Enable FTP support])
467 AC_HELP_STRING([--disable-ftp],[Disable FTP support]),
468 [ case "$enableval" in
469   no)
470        AC_MSG_RESULT(no)
471        AC_DEFINE(CURL_DISABLE_FTP, 1, [to disable FTP])
472        AC_SUBST(CURL_DISABLE_FTP, [1])
473        ;;
474   *)   AC_MSG_RESULT(yes)
475        ;;
476   esac ],
477        AC_MSG_RESULT(yes)
478 )
479 AC_MSG_CHECKING([whether to support file])
480 AC_ARG_ENABLE(file,
481 AC_HELP_STRING([--enable-file],[Enable FILE support])
482 AC_HELP_STRING([--disable-file],[Disable FILE support]),
483 [ case "$enableval" in
484   no)
485        AC_MSG_RESULT(no)
486        AC_DEFINE(CURL_DISABLE_FILE, 1, [to disable FILE])
487        AC_SUBST(CURL_DISABLE_FILE, [1])
488        ;;
489   *)   AC_MSG_RESULT(yes)
490        ;;
491   esac ],
492        AC_MSG_RESULT(yes)
493 )
494 AC_MSG_CHECKING([whether to support ldap])
495 AC_ARG_ENABLE(ldap,
496 AC_HELP_STRING([--enable-ldap],[Enable LDAP support])
497 AC_HELP_STRING([--disable-ldap],[Disable LDAP support]),
498 [ case "$enableval" in
499   no)
500        AC_MSG_RESULT(no)
501        AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
502        AC_SUBST(CURL_DISABLE_LDAP, [1])
503        ;;
504   *)
505        case $host in
506          *-*-cygwin*)
507            # Force no ldap. config/build process is broken for cygwin
508            AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
509            AC_SUBST(CURL_DISABLE_LDAP, [1])
510            AC_MSG_RESULT(no)
511            ;;
512          *)
513            AC_MSG_RESULT(yes)
514        esac
515        ;;
516   esac ],[
517        case $host in
518          *-*-cygwin*)
519            # Force no ldap. config/build process is broken for cygwin
520            AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
521            AC_SUBST(CURL_DISABLE_LDAP, [1])
522            AC_MSG_RESULT(no)
523            ;;
524          *)
525            AC_MSG_RESULT(yes)
526        esac ]
527 )
528 AC_MSG_CHECKING([whether to support ldaps])
529 AC_ARG_ENABLE(ldaps,
530 AC_HELP_STRING([--enable-ldaps],[Enable LDAPS support])
531 AC_HELP_STRING([--disable-ldaps],[Disable LDAPS support]),
532 [ case "$enableval" in
533   no)
534        AC_MSG_RESULT(no)
535        AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
536        AC_SUBST(CURL_DISABLE_LDAPS, [1])
537        ;;
538   *)   if test x$CURL_DISABLE_LDAP = x1 ; then
539                AC_MSG_RESULT(LDAP support needs to be enabled in order to enable LDAPS support!)
540                AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
541                AC_SUBST(CURL_DISABLE_LDAPS, [1])
542        else
543                AC_MSG_RESULT(yes)
544                AC_DEFINE(HAVE_LDAP_SSL, 1, [Use LDAPS implementation])
545                curl_ldaps_msg="enabled"
546        fi
547        ;;
548   esac ],
549        AC_MSG_RESULT(no)
550        AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
551        AC_SUBST(CURL_DISABLE_LDAPS, [1])
552 )
553
554 AC_MSG_CHECKING([whether to support proxies])
555 AC_ARG_ENABLE(proxy,
556 AC_HELP_STRING([--enable-proxy],[Enable proxy support])
557 AC_HELP_STRING([--disable-proxy],[Disable proxy support]),
558 [ case "$enableval" in
559   no)
560        AC_MSG_RESULT(no)
561        AC_DEFINE(CURL_DISABLE_PROXY, 1, [to disable proxies])
562        AC_SUBST(CURL_DISABLE_PROXY, [1])
563        ;;
564   *)   AC_MSG_RESULT(yes)
565        ;;
566   esac ],
567        AC_MSG_RESULT(yes)
568 )
569
570 AC_MSG_CHECKING([whether to support dict])
571 AC_ARG_ENABLE(dict,
572 AC_HELP_STRING([--enable-dict],[Enable DICT support])
573 AC_HELP_STRING([--disable-dict],[Disable DICT support]),
574 [ case "$enableval" in
575   no)
576        AC_MSG_RESULT(no)
577        AC_DEFINE(CURL_DISABLE_DICT, 1, [to disable DICT])
578        AC_SUBST(CURL_DISABLE_DICT, [1])
579        ;;
580   *)   AC_MSG_RESULT(yes)
581        ;;
582   esac ],
583        AC_MSG_RESULT(yes)
584 )
585 AC_MSG_CHECKING([whether to support telnet])
586 AC_ARG_ENABLE(telnet,
587 AC_HELP_STRING([--enable-telnet],[Enable TELNET support])
588 AC_HELP_STRING([--disable-telnet],[Disable TELNET support]),
589 [ case "$enableval" in
590   no)
591        AC_MSG_RESULT(no)
592        AC_DEFINE(CURL_DISABLE_TELNET, 1, [to disable TELNET])
593        AC_SUBST(CURL_DISABLE_TELNET, [1])
594        ;;
595   *)   AC_MSG_RESULT(yes)
596        ;;
597   esac ],
598        AC_MSG_RESULT(yes)
599 )
600 AC_MSG_CHECKING([whether to support tftp])
601 AC_ARG_ENABLE(tftp,
602 AC_HELP_STRING([--enable-tftp],[Enable TFTP support])
603 AC_HELP_STRING([--disable-tftp],[Disable TFTP support]),
604 [ case "$enableval" in
605   no)
606        AC_MSG_RESULT(no)
607        AC_DEFINE(CURL_DISABLE_TFTP, 1, [to disable TFTP])
608        AC_SUBST(CURL_DISABLE_TFTP, [1])
609        ;;
610   *)   AC_MSG_RESULT(yes)
611        ;;
612   esac ],
613        AC_MSG_RESULT(yes)
614 )
615
616 dnl **********************************************************************
617 dnl Check for built-in manual
618 dnl **********************************************************************
619
620 AC_MSG_CHECKING([whether to provide built-in manual])
621 AC_ARG_ENABLE(manual,
622 AC_HELP_STRING([--enable-manual],[Enable built-in manual])
623 AC_HELP_STRING([--disable-manual],[Disable built-in manual]),
624 [ case "$enableval" in
625   no)
626        AC_MSG_RESULT(no)
627        ;;
628   *)   AC_MSG_RESULT(yes)
629        USE_MANUAL="1"
630        ;;
631   esac ],
632        AC_MSG_RESULT(yes)
633        USE_MANUAL="1"
634 )
635 dnl The actual use of the USE_MANUAL variable is done much later in this
636 dnl script to allow other actions to disable it as well.
637
638 dnl **********************************************************************
639 dnl Checks for libraries.
640 dnl **********************************************************************
641
642 dnl gethostbyname without lib or in the nsl lib?
643 AC_CHECK_FUNC(gethostbyname,
644               [HAVE_GETHOSTBYNAME="1"
645               ],
646               [ AC_CHECK_LIB(nsl, gethostbyname,
647                              [HAVE_GETHOSTBYNAME="1"
648                              LIBS="$LIBS -lnsl"
649                              ])
650               ])
651
652 if test "$HAVE_GETHOSTBYNAME" != "1"
653 then
654   dnl gethostbyname in the socket lib?
655   AC_CHECK_LIB(socket, gethostbyname,
656                [HAVE_GETHOSTBYNAME="1"
657                LIBS="$LIBS -lsocket"
658                ])
659 fi
660
661 dnl At least one system has been identified to require BOTH nsl and socket
662 dnl libs at the same time to link properly.
663 if test "$HAVE_GETHOSTBYNAME" != "1"
664 then
665   AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
666   my_ac_save_LIBS=$LIBS
667   LIBS="-lnsl -lsocket $LIBS"
668   AC_LINK_IFELSE([
669     AC_LANG_PROGRAM([[
670     ]],[[
671       gethostbyname();
672     ]])
673   ],[
674     AC_MSG_RESULT([yes])
675     HAVE_GETHOSTBYNAME="1"
676   ],[
677     AC_MSG_RESULT([no])
678     LIBS=$my_ac_save_LIBS
679   ])
680 fi
681
682 if test "$HAVE_GETHOSTBYNAME" != "1"
683 then
684   dnl This is for winsock systems
685   if test "$ac_cv_header_windows_h" = "yes"; then
686     if test "$ac_cv_header_winsock_h" = "yes"; then
687       case $host in
688         *-*-mingw32ce*)
689           winsock_LIB="-lwinsock"
690           ;;
691         *)
692           winsock_LIB="-lwsock32"
693           ;;
694       esac
695     fi
696     if test "$ac_cv_header_winsock2_h" = "yes"; then
697       winsock_LIB="-lws2_32"
698     fi
699     if test ! -z "$winsock_LIB"; then
700       my_ac_save_LIBS=$LIBS
701       LIBS="$winsock_LIB $LIBS"
702       AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
703       AC_LINK_IFELSE([
704         AC_LANG_PROGRAM([[
705 #ifdef HAVE_WINDOWS_H
706 #ifndef WIN32_LEAN_AND_MEAN
707 #define WIN32_LEAN_AND_MEAN
708 #endif
709 #include <windows.h>
710 #ifdef HAVE_WINSOCK2_H
711 #include <winsock2.h>
712 #else
713 #ifdef HAVE_WINSOCK_H
714 #include <winsock.h>
715 #endif
716 #endif
717 #endif
718         ]],[[
719           gethostbyname("www.dummysite.com");
720         ]])
721       ],[
722         AC_MSG_RESULT([yes])
723         HAVE_GETHOSTBYNAME="1"
724       ],[
725         AC_MSG_RESULT([no])
726         winsock_LIB=""
727         LIBS=$my_ac_save_LIBS
728       ])
729     fi
730   fi
731 fi
732
733 if test "$HAVE_GETHOSTBYNAME" != "1"
734 then
735   dnl This is for Minix 3.1
736   AC_MSG_CHECKING([for gethostbyname for Minix 3])
737   AC_LINK_IFELSE([
738     AC_LANG_PROGRAM([[
739 /* Older Minix versions may need <net/gen/netdb.h> here instead */
740 #include <netdb.h>
741     ]],[[
742       gethostbyname("www.dummysite.com");
743     ]])
744   ],[
745     AC_MSG_RESULT([yes])
746     HAVE_GETHOSTBYNAME="1"
747   ],[
748     AC_MSG_RESULT([no])
749   ])
750 fi
751
752 if test "$HAVE_GETHOSTBYNAME" != "1"
753 then
754   dnl This is for eCos with a stubbed DNS implementation
755   AC_MSG_CHECKING([for gethostbyname for eCos])
756   AC_LINK_IFELSE([
757     AC_LANG_PROGRAM([[
758 #include <stdio.h>
759 #include <netdb.h>
760     ]],[[
761       gethostbyname("www.dummysite.com");
762     ]])
763   ],[
764     AC_MSG_RESULT([yes])
765     HAVE_GETHOSTBYNAME="1"
766   ],[
767     AC_MSG_RESULT([no])
768   ])
769 fi
770
771 if test "$HAVE_GETHOSTBYNAME" != "1"
772 then
773   dnl gethostbyname in the network lib - for Haiku OS
774   AC_CHECK_LIB(network, gethostbyname,
775                [HAVE_GETHOSTBYNAME="1"
776                LIBS="$LIBS -lnetwork"
777                ])
778 fi
779
780 if test "$HAVE_GETHOSTBYNAME" != "1"
781 then
782   dnl gethostbyname in the net lib - for BeOS
783   AC_CHECK_LIB(net, gethostbyname,
784                [HAVE_GETHOSTBYNAME="1"
785                LIBS="$LIBS -lnet"
786                ])
787 fi
788
789
790 if test "$HAVE_GETHOSTBYNAME" = "1"; then
791   AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
792 else
793   AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
794 fi
795
796 dnl resolve lib?
797 AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
798
799 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
800   AC_CHECK_LIB(resolve, strcasecmp,
801               [LIBS="-lresolve $LIBS"],
802                ,
803                -lnsl)
804 fi
805 ac_cv_func_strcasecmp="no"
806
807 dnl socket lib?
808 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
809
810 dnl **********************************************************************
811 dnl In case that function clock_gettime with monotonic timer is available,
812 dnl check for additional required libraries.
813 dnl **********************************************************************
814 CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
815
816 dnl **********************************************************************
817 dnl The preceding library checks are all potentially useful for test
818 dnl servers (for providing networking support).  Save the list of required
819 dnl libraries at this point for use while linking those test servers.
820 dnl **********************************************************************
821 TEST_SERVER_LIBS=$LIBS
822
823 dnl **********************************************************************
824 AC_MSG_CHECKING([whether to use libgcc])
825 AC_ARG_ENABLE(libgcc,
826 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
827 [ case "$enableval" in
828   yes)
829         ALL_LIBS="$ALL_LIBS -lgcc"
830        AC_MSG_RESULT(yes)
831        ;;
832   *)   AC_MSG_RESULT(no)
833        ;;
834   esac ],
835        AC_MSG_RESULT(no)
836 )
837
838 dnl **********************************************************************
839 dnl Check for LDAP
840 dnl **********************************************************************
841
842 LDAPLIBNAME=""
843 AC_ARG_WITH(ldap-lib,
844 AC_HELP_STRING([--with-ldap-lib=libname],[Specify name of ldap lib file]),
845  [LDAPLIBNAME="$withval"])
846
847 LBERLIBNAME=""
848 AC_ARG_WITH(lber-lib,
849 AC_HELP_STRING([--with-lber-lib=libname],[Specify name of lber lib file]),
850  [LBERLIBNAME="$withval"])
851
852 if test x$CURL_DISABLE_LDAP != x1 ; then
853
854   CURL_CHECK_HEADER_LBER
855   CURL_CHECK_HEADER_LDAP
856   CURL_CHECK_HEADER_LDAPSSL
857   CURL_CHECK_HEADER_LDAP_SSL
858
859   if test -z "$LDAPLIBNAME" ; then
860     case $host in
861       *-*-cygwin* | *-*-mingw* | *-*-pw32*)
862         dnl Windows uses a single and unique OpenLDAP DLL name
863         LDAPLIBNAME="wldap32"
864         LBERLIBNAME="no"
865         ;;
866     esac
867   fi
868
869   if test "$LDAPLIBNAME" ; then
870     AC_CHECK_LIB("$LDAPLIBNAME", ldap_init,, [
871       AC_MSG_WARN(["$LDAPLIBNAME" is not an LDAP library: LDAP disabled])
872       AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
873       AC_SUBST(CURL_DISABLE_LDAP, [1])])
874       AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
875       AC_SUBST(CURL_DISABLE_LDAPS, [1])
876   else
877     dnl Try to find the right ldap libraries for this system
878     CURL_CHECK_LIBS_LDAP
879     case X-"$curl_cv_ldap_LIBS" in
880       X-unknown)
881         AC_MSG_WARN([Cannot find libraries for LDAP support: LDAP disabled])
882         AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
883         AC_SUBST(CURL_DISABLE_LDAP, [1])
884         AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
885         AC_SUBST(CURL_DISABLE_LDAPS, [1])
886         ;;
887     esac
888   fi
889 fi
890
891 if test x$CURL_DISABLE_LDAP != x1 ; then
892
893   if test "$LBERLIBNAME" ; then
894     dnl If name is "no" then don't define this library at all
895     dnl (it's only needed if libldap.so's dependencies are broken).
896     if test "$LBERLIBNAME" != "no" ; then
897       AC_CHECK_LIB("$LBERLIBNAME", ber_free,, [
898         AC_MSG_WARN(["$LBERLIBNAME" is not an LBER library: LDAP disabled])
899         AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP])
900         AC_SUBST(CURL_DISABLE_LDAP, [1])])
901         AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS])
902         AC_SUBST(CURL_DISABLE_LDAPS, [1])
903     fi
904   fi
905 fi
906
907 if test x$CURL_DISABLE_LDAP != x1 ; then
908   AC_CHECK_FUNCS([ldap_url_parse])
909
910   if test "$LDAPLIBNAME" = "wldap32"; then
911     curl_ldap_msg="enabled (winldap)"
912     AC_DEFINE(CURL_LDAP_WIN, 1, [Use W$ LDAP implementation])
913     case $host in
914       *-*-cygwin* | *-*-pw32*)
915         AC_DEFINE(CURL_LDAP_HYBRID, 1, [W$ LDAP with non-W$ compiler])
916         ;;
917     esac
918   else
919     curl_ldap_msg="enabled (OpenLDAP)"
920   fi
921 fi
922
923 dnl **********************************************************************
924 dnl Checks for IPv6
925 dnl **********************************************************************
926
927 AC_MSG_CHECKING([whether to enable ipv6])
928 AC_ARG_ENABLE(ipv6,
929 AC_HELP_STRING([--enable-ipv6],[Enable ipv6 (with ipv4) support])
930 AC_HELP_STRING([--disable-ipv6],[Disable ipv6 support]),
931 [ case "$enableval" in
932   no)
933        AC_MSG_RESULT(no)
934        ipv6=no
935        ;;
936   *)   AC_MSG_RESULT(yes)
937        ipv6=yes
938        ;;
939   esac ],
940
941   AC_TRY_RUN([ /* is AF_INET6 available? */
942 #include <sys/types.h>
943 #include <sys/socket.h>
944 main()
945 {
946  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
947    exit(1);
948  else
949    exit(0);
950 }
951 ],
952   AC_MSG_RESULT(yes)
953   ipv6=yes,
954   AC_MSG_RESULT(no)
955   ipv6=no,
956   AC_MSG_RESULT(no)
957   ipv6=no
958 ))
959
960 if test "$ipv6" = "yes"; then
961   curl_ipv6_msg="enabled"
962 fi
963
964 dnl **********************************************************************
965 dnl Check how non-blocking sockets are set
966 dnl **********************************************************************
967 AC_ARG_ENABLE(nonblocking,
968 AC_HELP_STRING([--enable-nonblocking],[Enable detecting how to do it])
969 AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking socket detection]),
970 [
971   if test "$enableval" = "no" ; then
972     AC_MSG_WARN([non-blocking sockets disabled])
973     AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
974     [to disable NON-BLOCKING connections])
975   else
976     CURL_CHECK_NONBLOCKING_SOCKET
977   fi
978 ],
979 [
980   CURL_CHECK_NONBLOCKING_SOCKET
981 ])
982
983 dnl **********************************************************************
984 dnl Check if the operating system allows programs to write to their own argv[]
985 dnl **********************************************************************
986
987 AC_MSG_CHECKING([if argv can be written to])
988 AC_CACHE_VAL(curl_cv_writable_argv, [
989 AC_RUN_IFELSE([[
990 int main(int argc, char ** argv) {
991         argv[0][0] = ' ';
992         return (argv[0][0] == ' ')?0:1;
993 }
994         ]],
995         curl_cv_writable_argv=yes,
996         curl_cv_writable_argv=no,
997         curl_cv_writable_argv=cross)
998 ])
999 case $curl_cv_writable_argv in
1000 yes)
1001         AC_DEFINE(HAVE_WRITABLE_ARGV, 1, [Define this symbol if your OS supports changing the contents of argv])
1002         AC_MSG_RESULT(yes)
1003         ;;
1004 no)
1005         AC_MSG_RESULT(no)
1006         ;;
1007 *)
1008         AC_MSG_RESULT(no)
1009         AC_MSG_WARN([the previous check could not be made default was used])
1010         ;;
1011 esac
1012
1013 dnl **********************************************************************
1014 dnl Check for the presence of Kerberos4 libraries and headers
1015 dnl **********************************************************************
1016
1017 AC_ARG_WITH(krb4-includes,
1018 AC_HELP_STRING([--with-krb4-includes=DIR],
1019                [Specify location of kerberos4 headers]),[
1020  CPPFLAGS="$CPPFLAGS -I$withval"
1021  KRB4INC="$withval"
1022  want_krb4=yes
1023  ])
1024
1025 AC_ARG_WITH(krb4-libs,
1026 AC_HELP_STRING([--with-krb4-libs=DIR],[Specify location of kerberos4 libs]),[
1027  LDFLAGS="$LDFLAGS -L$withval"
1028  KRB4LIB="$withval"
1029  want_krb4=yes
1030  ])
1031
1032
1033 OPT_KRB4=off
1034 AC_ARG_WITH(krb4,dnl
1035 AC_HELP_STRING([--with-krb4=DIR],[where to look for Kerberos4]),[
1036   OPT_KRB4="$withval"
1037   if test X"$OPT_KRB4" != Xno; then
1038     want_krb4="yes"
1039     if test X"$OPT_KRB4" != Xyes; then
1040       LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib$libsuff"
1041       KRB4LIB="$OPT_KRB4/lib$libsuff"
1042       CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
1043       KRB4INC="$OPT_KRB4/include"
1044     fi
1045   fi
1046  ])
1047
1048 AC_MSG_CHECKING([if Kerberos4 support is requested])
1049
1050 if test "$want_krb4" = yes
1051 then
1052   if test "$ipv6" = "yes"; then
1053     echo krb4 is not compatible with IPv6
1054     exit 1
1055   fi
1056   AC_MSG_RESULT(yes)
1057
1058   dnl Check for & handle argument to --with-krb4
1059
1060   AC_MSG_CHECKING(where to look for Kerberos4)
1061   if test X"$OPT_KRB4" = Xyes
1062   then
1063     AC_MSG_RESULT([defaults])
1064   else
1065     AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
1066   fi
1067
1068   dnl Check for DES library
1069   AC_CHECK_LIB(des, des_pcbc_encrypt,
1070   [
1071     AC_CHECK_HEADERS(des.h)
1072
1073     dnl resolv lib?
1074     AC_CHECK_FUNC(res_search, , [AC_CHECK_LIB(resolv, res_search)])
1075
1076     dnl Check for the Kerberos4 library
1077     AC_CHECK_LIB(krb, krb_net_read,
1078     [
1079       dnl Check for header files
1080       AC_CHECK_HEADERS(krb.h)
1081
1082       dnl we found the required libraries, add to LIBS
1083       LIBS="-lkrb -lcom_err -ldes $LIBS"
1084
1085       dnl Check for function krb_get_our_ip_for_realm
1086       dnl this is needed for NAT networks
1087       AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
1088
1089       dnl add define KRB4
1090       AC_DEFINE(HAVE_KRB4, 1,
1091       [if you have the Kerberos4 libraries (including -ldes)])
1092
1093       dnl substitute it too!
1094       KRB4_ENABLED=1
1095       AC_SUBST(KRB4_ENABLED)
1096
1097       curl_krb4_msg="enabled"
1098
1099       dnl the krb4 stuff needs a strlcpy()
1100       AC_CHECK_FUNCS(strlcpy)
1101
1102     ])
1103   ])
1104 else
1105   AC_MSG_RESULT(no)
1106 fi
1107
1108 dnl **********************************************************************
1109 dnl Check for FBopenssl(SPNEGO) libraries
1110 dnl **********************************************************************
1111
1112 AC_ARG_WITH(spnego,
1113   AC_HELP_STRING([--with-spnego=DIR],
1114                  [Specify location of SPNEGO library fbopenssl]), [
1115   SPNEGO_ROOT="$withval"
1116   if test x"$SPNEGO_ROOT" != xno; then
1117     want_spnego="yes"
1118   fi
1119 ])
1120
1121 AC_MSG_CHECKING([if SPNEGO support is requested])
1122 if test x"$want_spnego" = xyes; then
1123
1124   if test X"$SPNEGO_ROOT" = Xyes; then
1125      AC_MSG_ERROR([FBOpenSSL libs and/or directories were not found where specified!])
1126      AC_MSG_RESULT(no)
1127   else
1128      if test -z "$SPNEGO_LIB_DIR"; then
1129         LDFLAGS="$LDFLAGS -L$SPNEGO_ROOT -lfbopenssl"
1130      else
1131         LDFLAGS="$LDFLAGS $SPNEGO_LIB_DIR"
1132      fi
1133
1134      AC_MSG_RESULT(yes)
1135      AC_DEFINE(HAVE_SPNEGO, 1,
1136                [Define this if you have the SPNEGO library fbopenssl])
1137      curl_spnego_msg="enabled"
1138   fi
1139 else
1140   AC_MSG_RESULT(no)
1141 fi
1142
1143 dnl **********************************************************************
1144 dnl Check for GSS-API libraries
1145 dnl **********************************************************************
1146
1147 dnl check for gss stuff in the /usr as default
1148
1149 GSSAPI_ROOT="/usr"
1150 AC_ARG_WITH(gssapi-includes,
1151   AC_HELP_STRING([--with-gssapi-includes=DIR],
1152                  [Specify location of GSSAPI header]),
1153   [ GSSAPI_INCS="-I$withval"
1154     want_gss="yes" ]
1155 )
1156
1157 AC_ARG_WITH(gssapi-libs,
1158   AC_HELP_STRING([--with-gssapi-libs=DIR],
1159                  [Specify location of GSSAPI libs]),
1160   [ GSSAPI_LIB_DIR="-L$withval"
1161     want_gss="yes" ]
1162 )
1163
1164 AC_ARG_WITH(gssapi,
1165   AC_HELP_STRING([--with-gssapi=DIR],
1166                  [Where to look for GSSAPI]), [
1167   GSSAPI_ROOT="$withval"
1168   if test x"$GSSAPI_ROOT" != xno; then
1169     want_gss="yes"
1170     if test x"$GSSAPI_ROOT" = xyes; then
1171       dnl if yes, then use default root
1172       GSSAPI_ROOT="/usr"
1173     fi
1174   fi
1175 ])
1176
1177 save_CPPFLAGS="$CPPFLAGS"
1178 AC_MSG_CHECKING([if GSSAPI support is requested])
1179 if test x"$want_gss" = xyes; then
1180   AC_MSG_RESULT(yes)
1181
1182   if test -z "$GSSAPI_INCS"; then
1183      if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
1184         GSSAPI_INCS=`$GSSAPI_ROOT/bin/krb5-config --cflags gssapi`
1185         GSSAPI_LIBS=`$GSSAPI_ROOT/bin/krb5-config --libs gssapi`
1186      elif test "$GSSAPI_ROOT" != "yes"; then
1187         GSSAPI_INCS="-I$GSSAPI_ROOT/include"
1188         GSSAPI_LIBS="-lgssapi"
1189      fi
1190   fi
1191
1192   CPPFLAGS="$CPPFLAGS $GSSAPI_INCS"
1193   LIBS="$LIBS $GSSAPI_LIBS"
1194
1195   AC_CHECK_HEADER(gss.h,
1196     [
1197       dnl found in the given dirs
1198       AC_DEFINE(HAVE_GSSGNU, 1, [if you have the GNU gssapi libraries])
1199       gnu_gss=yes
1200     ],
1201     [
1202       dnl not found, check Heimdal or MIT
1203       AC_CHECK_HEADERS(
1204         [gssapi/gssapi.h gssapi/gssapi_generic.h gssapi/gssapi_krb5.h],
1205         [],
1206         [not_mit=1])
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      if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
1261         dnl krb5-config doesn't have --libs-only-L or similar, put everything
1262         dnl into LIBS
1263         gss_libs=`$GSSAPI_ROOT/bin/krb5-config --libs gssapi`
1264         LIBS="$LIBS $gss_libs"
1265      elif test "$GSSAPI_ROOT" != "yes"; then
1266         LDFLAGS="$LDFLAGS -L$GSSAPI_ROOT/lib$libsuff"
1267         LIBS="$LIBS -lgssapi"
1268      else
1269         LIBS="$LIBS -lgssapi"
1270      fi
1271   else
1272      LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
1273      LIBS="$LIBS -lgssapi"
1274   fi
1275 else
1276   CPPFLAGS="$save_CPPFLAGS"
1277 fi
1278
1279 dnl **********************************************************************
1280 dnl Check for the presence of SSL libraries and headers
1281 dnl **********************************************************************
1282
1283 dnl Default to compiler & linker defaults for SSL files & libraries.
1284 OPT_SSL=off
1285 dnl Default to no CA bundle
1286 ca="no"
1287 AC_ARG_WITH(ssl,dnl
1288 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])
1289 AC_HELP_STRING([--without-ssl], [disable OpenSSL]),
1290   OPT_SSL=$withval)
1291
1292 if test X"$OPT_SSL" != Xno; then
1293   dnl backup the pre-ssl variables
1294   CLEANLDFLAGS="$LDFLAGS"
1295   CLEANCPPFLAGS="$CPPFLAGS"
1296   CLEANLIBS="$LIBS"
1297
1298   case "$OPT_SSL" in
1299   yes)
1300     dnl --with-ssl (without path) used
1301     if test x$cross_compiling != xyes; then
1302       dnl only do pkg-config magic when not cross-compiling
1303       PKGTEST="yes"
1304     fi
1305     PREFIX_OPENSSL=/usr/local/ssl
1306     LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
1307     ;;
1308   off)
1309     dnl no --with-ssl option given, just check default places
1310     if test x$cross_compiling != xyes; then
1311       dnl only do pkg-config magic when not cross-compiling
1312       PKGTEST="yes"
1313     fi
1314     PREFIX_OPENSSL=
1315     ;;
1316   *)
1317     dnl check the given --with-ssl spot
1318     PKGTEST="no"
1319     PREFIX_OPENSSL=$OPT_SSL
1320     LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
1321     LDFLAGS="$LDFLAGS -L$LIB_OPENSSL"
1322     CPPFLAGS="$CPPFLAGS -I$PREFIX_OPENSSL/include/openssl -I$PREFIX_OPENSSL/include"
1323     ;;
1324   esac
1325
1326   if test "$PKGTEST" = "yes"; then
1327
1328     dnl Detect the pkg-config tool, as it may have extra info about the
1329     dnl openssl installation we can use. I *believe* this is what we are
1330     dnl expected to do on really recent Redhat Linux hosts.
1331
1332     AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
1333     if test "$PKGCONFIG" != "no" ; then
1334       AC_MSG_CHECKING([OpenSSL options with pkg-config])
1335
1336       $PKGCONFIG --exists openssl
1337       SSL_EXISTS=$?
1338
1339       if test "$SSL_EXISTS" -eq "0"; then
1340         SSL_LIBS=`$PKGCONFIG --libs-only-l openssl 2>/dev/null`
1341         SSL_LDFLAGS=`$PKGCONFIG --libs-only-L openssl 2>/dev/null`
1342         SSL_CPPFLAGS=`$PKGCONFIG --cflags-only-I openssl 2>/dev/null`
1343
1344         LIB_OPENSSL=`echo $SSL_LDFLAGS | sed -e 's/-L//g'`
1345
1346         dnl use the values pkg-config reported
1347         LIBS="$LIBS $SSL_LIBS"
1348         CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
1349         LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
1350         AC_MSG_RESULT([found])
1351       else
1352         AC_MSG_RESULT([no])
1353       fi
1354     fi
1355   fi
1356
1357   dnl This is for Msys/Mingw
1358   case $host in
1359     *-*-msys* | *-*-mingw*)
1360       AC_MSG_CHECKING([for gdi32])
1361       my_ac_save_LIBS=$LIBS
1362       LIBS="-lgdi32 $LIBS"
1363       AC_TRY_LINK([#include <windef.h>
1364                    #include <wingdi.h>],
1365                    [GdiFlush();],
1366                    [ dnl worked!
1367                    AC_MSG_RESULT([yes])],
1368                    [ dnl failed, restore LIBS
1369                    LIBS=$my_ac_save_LIBS
1370                    AC_MSG_RESULT(no)]
1371                   )
1372       ;;
1373   esac
1374
1375   AC_CHECK_LIB(crypto, CRYPTO_lock,[
1376      HAVECRYPTO="yes"
1377      LIBS="-lcrypto $LIBS"
1378      ],[
1379      LDFLAGS="$CLEANLDFLAGS -L$LIB_OPENSSL"
1380      CPPFLAGS="$CLEANCPPFLAGS -I$PREFIX_OPENSSL/include/openssl -I$PREFIX_OPENSSL/include"
1381      AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
1382        HAVECRYPTO="yes"
1383        LIBS="-lcrypto $LIBS"], [
1384        LDFLAGS="$CLEANLDFLAGS"
1385        CPPFLAGS="$CLEANCPPFLAGS"
1386        LIBS="$CLEANLIBS"
1387        ])
1388     ])
1389
1390
1391   if test X"$HAVECRYPTO" = X"yes"; then
1392     dnl This is only reasonable to do if crypto actually is there: check for
1393     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
1394
1395     AC_CHECK_LIB(ssl, SSL_connect)
1396
1397     if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
1398         dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
1399         AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
1400         OLIBS=$LIBS
1401         LIBS="$LIBS -lRSAglue -lrsaref"
1402         AC_CHECK_LIB(ssl, SSL_connect)
1403         if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
1404             dnl still no SSL_connect
1405             AC_MSG_RESULT(no)
1406             LIBS=$OLIBS
1407         else
1408             AC_MSG_RESULT(yes)
1409         fi
1410
1411     else
1412
1413       dnl Have the libraries--check for SSLeay/OpenSSL headers
1414       AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
1415                        openssl/pem.h openssl/ssl.h openssl/err.h,
1416         curl_ssl_msg="enabled (OpenSSL)"
1417         OPENSSL_ENABLED=1
1418         AC_DEFINE(USE_OPENSSL, 1, [if OpenSSL is in use]))
1419
1420       if test $ac_cv_header_openssl_x509_h = no; then
1421         dnl we don't use the "action" part of the AC_CHECK_HEADERS macro
1422         dnl since 'err.h' might in fact find a krb4 header with the same
1423         dnl name
1424         AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h)
1425
1426         if test $ac_cv_header_x509_h = yes &&
1427            test $ac_cv_header_crypto_h = yes &&
1428            test $ac_cv_header_ssl_h = yes; then
1429           dnl three matches
1430           curl_ssl_msg="enabled (OpenSSL)"
1431           OPENSSL_ENABLED=1
1432         fi
1433       fi
1434     fi
1435
1436     if test X"$OPENSSL_ENABLED" = X"1"; then
1437        AC_DEFINE(USE_SSLEAY, 1, [if SSL is enabled])
1438
1439        dnl is there a pkcs12.h header present?
1440        AC_CHECK_HEADERS(openssl/pkcs12.h)
1441     else
1442        LIBS="$CLEANLIBS"
1443     fi
1444     dnl USE_SSLEAY is the historical name for what configure calls
1445     dnl OPENSSL_ENABLED; the names should really be unified
1446     USE_SSLEAY="$OPENSSL_ENABLED"
1447     AC_SUBST(USE_SSLEAY)
1448
1449     if test X"$OPT_SSL" != Xoff &&
1450        test "$OPENSSL_ENABLED" != "1"; then
1451       AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
1452     fi
1453   fi
1454
1455   if test X"$OPENSSL_ENABLED" = X"1"; then
1456     dnl If the ENGINE library seems to be around, check for the OpenSSL engine
1457     dnl stuff, it is kind of "separated" from the main SSL check
1458     AC_CHECK_FUNC(ENGINE_init,
1459               [
1460                 AC_CHECK_HEADERS(openssl/engine.h)
1461                 AC_CHECK_FUNCS( ENGINE_load_builtin_engines )
1462               ])
1463
1464     dnl these can only exist if openssl exists
1465     dnl yassl doesn't have SSL_get_shutdown
1466
1467     AC_CHECK_FUNCS( RAND_status \
1468                     RAND_screen \
1469                     RAND_egd \
1470                     CRYPTO_cleanup_all_ex_data \
1471                     SSL_get_shutdown )
1472
1473     dnl Make an attempt to detect if this is actually yassl's headers and
1474     dnl OpenSSL emulation layer. We still leave everything else believing
1475     dnl and acting like OpenSSL.
1476
1477     AC_MSG_CHECKING([for yaSSL using OpenSSL compatibility mode])
1478     AC_COMPILE_IFELSE([
1479       AC_LANG_PROGRAM([[
1480 #include <openssl/ssl.h>
1481       ]],[[
1482 #if defined(YASSL_VERSION) && defined(OPENSSL_VERSION_NUMBER)
1483         int dummy = SSL_ERROR_NONE;
1484 #else
1485         Not the yaSSL OpenSSL compatibility header.
1486 #endif
1487       ]])
1488     ],[
1489       AC_MSG_RESULT([yes])
1490       AC_DEFINE_UNQUOTED(USE_YASSLEMUL, 1,
1491         [Define to 1 if using yaSSL in OpenSSL compatibility mode.])
1492       curl_ssl_msg="enabled (OpenSSL emulation by yaSSL)"
1493     ],[
1494       AC_MSG_RESULT([no])
1495     ])
1496   fi
1497
1498   if test "$OPENSSL_ENABLED" = "1"; then
1499     if test -n "$LIB_OPENSSL"; then
1500        dnl when the ssl shared libs were found in a path that the run-time
1501        dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
1502        dnl to prevent further configure tests to fail due to this
1503
1504        LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIB_OPENSSL"
1505        export LD_LIBRARY_PATH
1506        AC_MSG_NOTICE([Added $LIB_OPENSSL to LD_LIBRARY_PATH])
1507     fi
1508   fi
1509
1510 fi
1511
1512 dnl **********************************************************************
1513 dnl Check for the presence of ZLIB libraries and headers
1514 dnl **********************************************************************
1515
1516 dnl Check for & handle argument to --with-zlib.
1517
1518 _cppflags=$CPPFLAGS
1519 _ldflags=$LDFLAGS
1520 AC_ARG_WITH(zlib,
1521 AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH])
1522 AC_HELP_STRING([--without-zlib],[disable use of zlib]),
1523                [OPT_ZLIB="$withval"])
1524
1525 if test "$OPT_ZLIB" = "no" ; then
1526     AC_MSG_WARN([zlib disabled])
1527 else
1528   if test "$OPT_ZLIB" = "yes" ; then
1529      OPT_ZLIB=""
1530   fi
1531
1532   if test -z "$OPT_ZLIB" ; then
1533     dnl check for the lib first without setting any new path, since many
1534     dnl people have it in the default path
1535
1536     AC_CHECK_LIB(z, inflateEnd,
1537                    dnl libz found, set the variable
1538                    [HAVE_LIBZ="1"],
1539                    dnl if no lib found, try /usr/local
1540                    [OPT_ZLIB="/usr/local"])
1541
1542   fi
1543
1544   dnl Add a nonempty path to the compiler flags
1545   if test -n "$OPT_ZLIB"; then
1546      CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
1547      LDFLAGS="$LDFLAGS -L$OPT_ZLIB/lib$libsuff"
1548   fi
1549
1550   AC_CHECK_HEADER(zlib.h,
1551     [
1552     dnl zlib.h was found
1553     HAVE_ZLIB_H="1"
1554     dnl if the lib wasn't found already, try again with the new paths
1555     if test "$HAVE_LIBZ" != "1"; then
1556       AC_CHECK_LIB(z, gzread,
1557                    [
1558                    dnl the lib was found!
1559                    HAVE_LIBZ="1"
1560                    ],
1561                    [ CPPFLAGS=$_cppflags
1562                    LDFLAGS=$_ldflags])
1563     fi
1564     ],
1565     [
1566       dnl zlib.h was not found, restore the flags
1567       CPPFLAGS=$_cppflags
1568       LDFLAGS=$_ldflags]
1569     )
1570
1571   if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
1572   then
1573     AC_MSG_WARN([configure found only the libz lib, not the header file!])
1574     HAVE_LIBZ=""
1575   elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
1576   then
1577     AC_MSG_WARN([configure found only the libz header file, not the lib!])
1578   elif test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" = "1"
1579   then
1580     dnl both header and lib were found!
1581     AC_SUBST(HAVE_LIBZ)
1582     AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
1583     AC_DEFINE(HAVE_LIBZ, 1, [if zlib is available])
1584
1585     CURL_LIBS="$CURL_LIBS -lz"
1586     LIBS="$LIBS -lz"
1587
1588     dnl replace 'HAVE_LIBZ' in the automake makefile.ams
1589     AMFIXLIB="1"
1590     AC_MSG_NOTICE([found both libz and libz.h header])
1591     curl_zlib_msg="enabled"
1592   fi
1593 fi
1594
1595 dnl set variable for use in automakefile(s)
1596 AM_CONDITIONAL(HAVE_LIBZ, test x"$AMFIXLIB" = x1)
1597
1598 dnl **********************************************************************
1599 dnl Check for the presence of LIBSSH2 libraries and headers
1600 dnl **********************************************************************
1601
1602 dnl Default to compiler & linker defaults for LIBSSH2 files & libraries.
1603 OPT_LIBSSH2=off
1604 AC_ARG_WITH(libssh2,dnl
1605 AC_HELP_STRING([--with-libssh2=PATH],[Where to look for libssh2, PATH points to the LIBSSH2 installation (default: /usr/local/lib); when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
1606 AC_HELP_STRING([--without-libssh2], [disable LIBSSH2]),
1607   OPT_LIBSSH2=$withval)
1608
1609 if test X"$OPT_LIBSSH2" != Xno; then
1610   dnl backup the pre-libssh2 variables
1611   CLEANLDFLAGS="$LDFLAGS"
1612   CLEANCPPFLAGS="$CPPFLAGS"
1613   CLEANLIBS="$LIBS"
1614
1615   case "$OPT_LIBSSH2" in
1616   yes)
1617     dnl --with-libssh2 (without path) used
1618     PREFIX_LIBSSH2=/usr/local/lib
1619     LIB_LIBSSH2="$PREFIX_LIBSSH2$libsuff"
1620     ;;
1621   off)
1622     dnl no --with-libssh2 option given, just check default places
1623     PREFIX_LIBSSH2=
1624     ;;
1625   *)
1626     dnl use the given --with-libssh2 spot
1627     PREFIX_LIBSSH2=$OPT_LIBSSH2
1628     LIB_LIBSSH2="$PREFIX_LIBSSH2/lib$libsuff"
1629     LDFLAGS="$LDFLAGS -L$LIB_LIBSSH2"
1630     CPPFLAGS="$CPPFLAGS -I$PREFIX_LIBSSH2/include"
1631     ;;
1632   esac
1633
1634   AC_CHECK_LIB(ssh2, libssh2_channel_open_ex)
1635
1636   AC_CHECK_HEADERS(libssh2.h,
1637     curl_ssh_msg="enabled (libSSH2)"
1638     LIBSSH2_ENABLED=1
1639     AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use])
1640     AC_SUBST(USE_LIBSSH2, [1])
1641   )
1642
1643   if test X"$OPT_LIBSSH2" != Xoff &&
1644      test "$LIBSSH2_ENABLED" != "1"; then
1645     AC_MSG_ERROR([libSSH2 libs and/or directories were not found where specified!])
1646   fi
1647
1648   if test "$LIBSSH2_ENABLED" = "1"; then
1649     if test -n "$LIB_LIBSSH2"; then
1650        dnl when the libssh2 shared libs were found in a path that the run-time
1651        dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
1652        dnl to prevent further configure tests to fail due to this
1653
1654        LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIB_LIBSSH2"
1655        export LD_LIBRARY_PATH
1656        AC_MSG_NOTICE([Added $LIB_LIBSSH2 to LD_LIBRARY_PATH])
1657     fi
1658   fi
1659 fi
1660
1661 dnl **********************************************************************
1662 dnl Check for the random seed preferences
1663 dnl **********************************************************************
1664
1665 if test X"$OPENSSL_ENABLED" = X"1"; then
1666   AC_ARG_WITH(egd-socket,
1667   AC_HELP_STRING([--with-egd-socket=FILE],
1668                  [Entropy Gathering Daemon socket pathname]),
1669       [ EGD_SOCKET="$withval" ]
1670   )
1671   if test -n "$EGD_SOCKET" ; then
1672           AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET",
1673           [your Entropy Gathering Daemon socket pathname] )
1674   fi
1675
1676   dnl Check for user-specified random device
1677   AC_ARG_WITH(random,
1678   AC_HELP_STRING([--with-random=FILE],
1679                  [read randomness from FILE (default=/dev/urandom)]),
1680       [ RANDOM_FILE="$withval" ],
1681       [
1682           dnl Check for random device
1683           AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
1684       ]
1685   )
1686   if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
1687           AC_SUBST(RANDOM_FILE)
1688           AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
1689           [a suitable file to read random data from])
1690   fi
1691 fi
1692
1693 dnl ----------------------------------------------------
1694 dnl FIX: only check for GnuTLS if OpenSSL is not enabled
1695 dnl ----------------------------------------------------
1696
1697 dnl Default to compiler & linker defaults for GnuTLS files & libraries.
1698 OPT_GNUTLS=no
1699
1700 AC_ARG_WITH(gnutls,dnl
1701 AC_HELP_STRING([--with-gnutls=PATH],[where to look for GnuTLS, PATH points to the installation root (default: /usr/local/)])
1702 AC_HELP_STRING([--without-gnutls], [disable GnuTLS detection]),
1703   OPT_GNUTLS=$withval)
1704
1705 if test "$OPENSSL_ENABLED" != "1"; then
1706
1707   if test X"$OPT_GNUTLS" != Xno; then
1708     if test "x$OPT_GNUTLS" = "xyes"; then
1709      check=`libgnutls-config --version 2>/dev/null`
1710      if test -n "$check"; then
1711        addlib=`libgnutls-config --libs`
1712        addcflags=`libgnutls-config --cflags`
1713        version=`libgnutls-config --version`
1714        gtlsprefix=`libgnutls-config --prefix`
1715      fi
1716     else
1717       addlib=`$OPT_GNUTLS/bin/libgnutls-config --libs`
1718       addcflags=`$OPT_GNUTLS/bin/libgnutls-config --cflags`
1719       version=`$OPT_GNUTLS/bin/libgnutls-config --version 2>/dev/null`
1720       gtlsprefix=$OPT_GNUTLS
1721       if test -z "$version"; then
1722         version="unknown"
1723       fi
1724     fi
1725     if test -n "$addlib"; then
1726
1727       CLEANLIBS="$LIBS"
1728       CLEANCPPFLAGS="$CPPFLAGS"
1729
1730       LIBS="$LIBS $addlib"
1731       if test "$addcflags" != "-I/usr/include"; then
1732          CPPFLAGS="$CPPFLAGS $addcflags"
1733       fi
1734
1735       AC_CHECK_LIB(gnutls, gnutls_check_version,
1736        [
1737        AC_DEFINE(USE_GNUTLS, 1, [if GnuTLS is enabled])
1738        AC_SUBST(USE_GNUTLS, [1])
1739        GNUTLS_ENABLED=1
1740        USE_GNUTLS="yes"
1741        curl_ssl_msg="enabled (GnuTLS)"
1742        ],
1743        [
1744          LIBS="$CLEANLIBS"
1745          CPPFLAGS="$CLEANCPPFLAGS"
1746        ])
1747
1748       if test "x$USE_GNUTLS" = "xyes"; then
1749         AC_MSG_NOTICE([detected GnuTLS version $version])
1750
1751         dnl when shared libs were found in a path that the run-time
1752         dnl linker doesn't search through, we need to add it to
1753         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
1754         dnl due to this
1755
1756         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$gtlsprefix/lib$libsuff"
1757         export LD_LIBRARY_PATH
1758         AC_MSG_NOTICE([Added $gtlsprefix/lib$libsuff to LD_LIBRARY_PATH])
1759       fi
1760
1761     fi
1762
1763   fi dnl GNUTLS not disabled
1764
1765 fi dnl OPENSSL != 1
1766
1767 dnl ----------------------------------------------------
1768 dnl NSS. Only check if GnuTLS and OpenSSL are not enabled
1769 dnl ----------------------------------------------------
1770
1771 dnl Default to compiler & linker defaults for NSS files & libraries.
1772 OPT_NSS=no
1773
1774 AC_ARG_WITH(nss,dnl
1775 AC_HELP_STRING([--with-nss=PATH],[where to look for NSS, PATH points to the installation root (default: /usr/local/)])
1776 AC_HELP_STRING([--without-nss], [disable NSS detection]),
1777   OPT_NSS=$withval)
1778
1779 if test "$OPENSSL_ENABLED" != "1" -a "$GNUTLS_ENABLED" != "1"; then
1780
1781   if test X"$OPT_NSS" != Xno; then
1782     if test "x$OPT_NSS" = "xyes"; then
1783      check=`pkg-config --version 2>/dev/null`
1784      if test -n "$check"; then
1785        addlib=`pkg-config --libs nss`
1786        addcflags=`pkg-config --cflags nss`
1787        version=`pkg-config --modversion nss`
1788        nssprefix=`pkg-config --variable=prefix nss`
1789      fi
1790     else
1791       # Without pkg-config, we'll kludge in some defaults
1792       addlib="-lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl"
1793       addcflags="-I$OPT_NSS/include"
1794       version="unknown"
1795       gtlsprefix=$OPT_GNUTLS
1796     fi
1797
1798     dnl Check for functionPK11_CreateGenericObject
1799     dnl this is needed for using the PEM PKCS#11 module
1800     AC_CHECK_LIB(nss3, PK11_CreateGenericObject,
1801      [
1802      AC_DEFINE(HAVE_PK11_CREATEGENERICOBJECT, 1, [if you have the function PK11_CreateGenericObject])
1803      AC_SUBST(HAVE_PK11_CREATEGENERICOBJECT, [1])
1804      ])
1805     if test -n "$addlib"; then
1806
1807       CLEANLIBS="$LIBS"
1808       CLEANCPPFLAGS="$CPPFLAGS"
1809
1810       LIBS="$LIBS $addlib"
1811       if test "$addcflags" != "-I/usr/include"; then
1812          CPPFLAGS="$CPPFLAGS $addcflags"
1813       fi
1814
1815       AC_CHECK_LIB(nss3, NSS_Initialize,
1816        [
1817        AC_DEFINE(USE_NSS, 1, [if NSS is enabled])
1818        AC_SUBST(USE_NSS, [1])
1819        USE_NSS="yes"
1820        NSS_ENABLED=1
1821        curl_ssl_msg="enabled (NSS)"
1822        ],
1823        [
1824          LIBS="$CLEANLIBS"
1825          CPPFLAGS="$CLEANCPPFLAGS"
1826        ])
1827
1828       if test "x$USE_NSS" = "xyes"; then
1829         AC_MSG_NOTICE([detected NSS version $version])
1830
1831         dnl when shared libs were found in a path that the run-time
1832         dnl linker doesn't search through, we need to add it to
1833         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
1834         dnl due to this
1835
1836         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$nssprefix/lib$libsuff"
1837         export LD_LIBRARY_PATH
1838         AC_MSG_NOTICE([Added $nssprefix/lib$libsuff to LD_LIBRARY_PATH])
1839       fi
1840
1841     fi
1842
1843   fi dnl NSS not disabled
1844
1845 fi dnl OPENSSL != 1 -a GNUTLS_ENABLED != 1
1846
1847 if test "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED" = "x"; then
1848   AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
1849   AC_MSG_WARN([Use --with-ssl, --with-gnutls or --with-nss to address this.])
1850 else
1851   # SSL is enabled, genericly
1852   AC_SUBST(SSL_ENABLED)
1853   SSL_ENABLED="1"
1854 fi
1855
1856 dnl **********************************************************************
1857 dnl Check for the CA bundle
1858 dnl **********************************************************************
1859
1860 CURL_CHECK_CA_BUNDLE
1861
1862 dnl **********************************************************************
1863 dnl Check for the presence of IDN libraries and headers
1864 dnl **********************************************************************
1865
1866 AC_MSG_CHECKING([whether to build with libidn])
1867 AC_ARG_WITH(libidn,
1868 AC_HELP_STRING([--with-libidn=PATH],[Enable libidn usage])
1869 AC_HELP_STRING([--without-libidn],[Disable libidn usage]),
1870   [LIBIDN="$withval"])
1871
1872 case "$LIBIDN" in
1873   no)
1874        AC_MSG_RESULT(no)
1875        ;;
1876   *)   AC_MSG_RESULT(yes)
1877
1878        idn=""
1879        dnl if there is a given path, check that FIRST
1880        if test -n "$LIBIDN"; then
1881          if test "x$LIBIDN" != "xyes"; then
1882             oldLDFLAGS=$LDFLAGS
1883             oldCPPFLAGS=$CPPFLAGS
1884             LDFLAGS="$LDFLAGS -L$LIBIDN/lib"
1885             CPPFLAGS="$CPPFLAGS -I$LIBIDN/include"
1886             idn="yes"
1887             AC_CHECK_LIB(idn, idna_to_ascii_4i, ,
1888                          idn=""
1889                          LDFLAGS=$oldLDFLAGS
1890                          CPPFLAGS=$oldCPPFLAGS)
1891          fi
1892        fi
1893
1894        if test "x$idn" != "xyes"; then
1895           dnl check with default paths
1896           idn="yes"
1897           AC_CHECK_LIB(idn, idna_to_ascii_lz, ,
1898                        idn="")
1899        fi
1900
1901        if test "x$idn" = "xyes"; then
1902          curl_idn_msg="enabled"
1903          AC_SUBST(IDN_ENABLED, [1])
1904          dnl different versions of libidn have different setups of these:
1905          AC_CHECK_FUNCS( idn_free idna_strerror tld_strerror)
1906          AC_CHECK_HEADERS( idn-free.h tld.h )
1907        fi
1908
1909        ;;
1910 esac
1911
1912 dnl Default is to try the thread-safe versions of a few functions
1913 OPT_THREAD=on
1914
1915 dnl detect AIX 4.3 or later
1916 dnl see full docs on this reasoning in the lib/hostip.c source file
1917 AC_MSG_CHECKING([AIX 4.3 or later])
1918 AC_PREPROC_IFELSE([
1919 #if defined(_AIX) && defined(_AIX43)
1920 printf("just fine");
1921 #else
1922 #error "this is not AIX 4.3 or later"
1923 #endif
1924 ],
1925  [ AC_MSG_RESULT([yes])
1926    RECENTAIX=yes
1927    OPT_THREAD=off ],
1928  [ AC_MSG_RESULT([no]) ]
1929 )
1930
1931 AC_ARG_ENABLE(thread,dnl
1932 AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
1933 AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
1934 [ case "$enableval" in
1935   no)
1936     OPT_THREAD=off
1937     AC_MSG_WARN(libcurl will not get built using thread-safe functions)
1938     ;;
1939   *)
1940     ;;
1941   esac
1942 ]
1943 )
1944
1945 if test X"$OPT_THREAD" = Xoff
1946 then
1947   AC_DEFINE(DISABLED_THREADSAFE, 1,
1948     [Set to explicitly specify we don't want to use thread-safe functions])
1949 else
1950   dnl if test "$ipv6" != "yes"; then
1951     dnl dig around for gethostbyname_r()
1952     dnl the old gethostbyname_r check was done here
1953
1954     dnl dig around for gethostbyaddr_r()
1955     dnl the old gethostbyaddr_r check was here BUT COMMENTED OUT
1956   dnl fi
1957
1958   dnl poke around for inet_ntoa_r()
1959   dnl the old inet_ntoa_r check was done here
1960
1961   dnl is there a localtime_r()
1962   dnl the old localtime_r check was done here
1963
1964   dnl is there a strerror_r()
1965   dnl the old strerror_r check was done here
1966
1967   checkfor_gmtime_r="yes"
1968 fi
1969
1970 dnl for recent AIX versions, we skip all the thread-safe checks above since
1971 dnl they claim a thread-safe libc using the standard API. But there are
1972 dnl some functions still not thread-safe. Check for these!
1973
1974 dnl Let's hope this split URL remains working:
1975 dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
1976 dnl genprogc/thread_quick_ref.htm
1977
1978 if test "x$RECENTAIX" = "xyes"; then
1979
1980   AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
1981
1982   dnl is there a localtime_r()
1983   dnl the old localtime_r check was done here
1984
1985   dnl is there a strerror_r()
1986   dnl the old strerror_r check was done here
1987
1988   checkfor_gmtime_r="yes"
1989 fi
1990
1991
1992 dnl **********************************************************************
1993 dnl Back to "normal" configuring
1994 dnl **********************************************************************
1995
1996 dnl Checks for header files.
1997 AC_HEADER_STDC
1998
1999 CURL_CHECK_HEADER_MALLOC
2000
2001 dnl Now check for the very most basic headers. Then we can use these
2002 dnl ones as default-headers when checking for the rest!
2003 AC_CHECK_HEADERS(
2004         sys/types.h \
2005         sys/time.h \
2006         sys/select.h \
2007         sys/socket.h \
2008         sys/ioctl.h \
2009         sys/uio.h \
2010         assert.h \
2011         unistd.h \
2012         stdlib.h \
2013         limits.h \
2014         arpa/inet.h \
2015         net/if.h \
2016         netinet/in.h \
2017         sys/un.h \
2018         netinet/tcp.h \
2019         netdb.h \
2020         sys/sockio.h \
2021         sys/stat.h \
2022         sys/param.h \
2023         termios.h \
2024         termio.h \
2025         sgtty.h \
2026         fcntl.h \
2027         alloca.h \
2028         time.h \
2029         io.h \
2030         pwd.h \
2031         utime.h \
2032         sys/utime.h \
2033         sys/poll.h \
2034         poll.h \
2035         sys/resource.h \
2036         libgen.h \
2037         locale.h \
2038         errno.h \
2039         stdbool.h \
2040         arpa/tftp.h \
2041         sys/filio.h \
2042         setjmp.h,
2043 dnl to do if not found
2044 [],
2045 dnl to do if found
2046 [],
2047 dnl default includes
2048 [
2049 #ifdef HAVE_SYS_TYPES_H
2050 #include <sys/types.h>
2051 #endif
2052 #ifdef HAVE_SYS_TIME_H
2053 #include <sys/time.h>
2054 #endif
2055 #ifdef HAVE_SYS_SELECT_H
2056 #include <sys/select.h>
2057 #endif
2058 #ifdef HAVE_SYS_SOCKET_H
2059 #include <sys/socket.h>
2060 #endif
2061 #ifdef HAVE_NETINET_IN_H
2062 #include <netinet/in.h>
2063 #endif
2064 #ifdef HAVE_SYS_UN_H
2065 #include <sys/un.h>
2066 #endif
2067 ]
2068 )
2069
2070 dnl Checks for typedefs, structures, and compiler characteristics.
2071 AC_C_CONST
2072 CURL_CHECK_VARIADIC_MACROS
2073 AC_TYPE_SIZE_T
2074 AC_HEADER_TIME
2075 CURL_CHECK_STRUCT_TIMEVAL
2076 CURL_VERIFY_RUNTIMELIBS
2077
2078 AC_CHECK_SIZEOF(size_t)
2079 AC_CHECK_SIZEOF(int)
2080 AC_CHECK_SIZEOF(long)
2081 CURL_CONFIGURE_LONG
2082 AC_CHECK_SIZEOF(time_t)
2083 AC_CHECK_SIZEOF(off_t)
2084
2085 soname_bump=no
2086 if test x"$ac_cv_native_windows" != "xyes" &&
2087    test $ac_cv_sizeof_off_t -ne $curl_sizeof_curl_off_t; then
2088   AC_MSG_WARN([This libcurl built is probably not ABI compatible with previous])
2089   AC_MSG_WARN([builds! You MUST read lib/README.curl_off_t to figure it out.])
2090   soname_bump=yes
2091 fi
2092
2093
2094 AC_CHECK_TYPE(long long,
2095    [AC_DEFINE(HAVE_LONGLONG, 1,
2096       [Define to 1 if the compiler supports the 'long long' data type.])]
2097    longlong="yes"
2098 )
2099
2100 if test "xyes" = "x$longlong"; then
2101   AC_MSG_CHECKING([if numberLL works])
2102   AC_COMPILE_IFELSE([long long val = 1000LL;],
2103    [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
2104    AC_MSG_RESULT(yes),
2105    AC_MSG_RESULT(no)
2106   )
2107 fi
2108
2109
2110 # check for ssize_t
2111 AC_CHECK_TYPE(ssize_t, ,
2112    AC_DEFINE(ssize_t, int, [the signed version of size_t]))
2113
2114 # check for bool type
2115 AC_CHECK_TYPE([bool],[
2116   AC_DEFINE(HAVE_BOOL_T, 1,
2117     [Define to 1 if bool is an available type.])
2118 ], ,[
2119 #ifdef HAVE_SYS_TYPES_H
2120 #include <sys/types.h>
2121 #endif
2122 #ifdef HAVE_STDBOOL_H
2123 #include <stdbool.h>
2124 #endif
2125 ])
2126
2127 # Check for socklen_t or equivalent
2128 CURL_CHECK_TYPE_SOCKLEN_T
2129
2130 TYPE_IN_ADDR_T
2131
2132 TYPE_SOCKADDR_STORAGE
2133
2134 TYPE_SIG_ATOMIC_T
2135
2136 AC_TYPE_SIGNAL
2137
2138 CURL_CHECK_FUNC_SELECT
2139
2140 CURL_CHECK_FUNC_RECV
2141 CURL_CHECK_FUNC_RECVFROM
2142 CURL_CHECK_FUNC_SEND
2143 CURL_CHECK_MSG_NOSIGNAL
2144
2145 CURL_CHECK_FUNC_ALARM
2146 CURL_CHECK_FUNC_FDOPEN
2147 CURL_CHECK_FUNC_FTRUNCATE
2148 CURL_CHECK_FUNC_GETHOSTBYADDR_R
2149 CURL_CHECK_FUNC_GETHOSTBYNAME_R
2150 CURL_CHECK_FUNC_GETHOSTNAME
2151 CURL_CHECK_FUNC_GETSERVBYPORT_R
2152 CURL_CHECK_FUNC_GMTIME_R
2153 CURL_CHECK_FUNC_INET_NTOA_R
2154 CURL_CHECK_FUNC_INET_NTOP
2155 CURL_CHECK_FUNC_INET_PTON
2156 CURL_CHECK_FUNC_LOCALTIME_R
2157 CURL_CHECK_FUNC_SIGACTION
2158 CURL_CHECK_FUNC_SIGINTERRUPT
2159 CURL_CHECK_FUNC_SIGNAL
2160 CURL_CHECK_FUNC_SIGSETJMP
2161 CURL_CHECK_FUNC_STRCASECMP
2162 CURL_CHECK_FUNC_STRCASESTR
2163 CURL_CHECK_FUNC_STRCMPI
2164 CURL_CHECK_FUNC_STRDUP
2165 CURL_CHECK_FUNC_STRERROR_R
2166 CURL_CHECK_FUNC_STRICMP
2167 CURL_CHECK_FUNC_STRLCAT
2168 CURL_CHECK_FUNC_STRNCASECMP
2169 CURL_CHECK_FUNC_STRNCMPI
2170 CURL_CHECK_FUNC_STRNICMP
2171 CURL_CHECK_FUNC_STRSTR
2172 CURL_CHECK_FUNC_STRTOK_R
2173 CURL_CHECK_FUNC_STRTOLL
2174 CURL_CHECK_FUNC_WRITEV
2175
2176 dnl Checks for library functions.
2177 dnl AC_PROG_GCC_TRADITIONAL
2178
2179 dnl AC_FUNC_VPRINTF
2180 case $host in
2181   *msdosdjgpp)
2182      ac_cv_func_pipe=no
2183      skipcheck_pipe=yes
2184      AC_MSG_NOTICE([skip check for pipe on msdosdjgpp])
2185     ;;
2186 esac
2187
2188 AC_CHECK_FUNCS([basename \
2189   closesocket \
2190   fork \
2191   geteuid \
2192   gethostbyaddr \
2193   getpass_r \
2194   getppid \
2195   getprotobyname \
2196   getpwuid \
2197   getrlimit \
2198   gettimeofday \
2199   inet_addr \
2200   perror \
2201   pipe \
2202   poll \
2203   setlocale \
2204   setmode \
2205   setrlimit \
2206   socket \
2207   uname \
2208   utime
2209 ],[
2210 ],[
2211   func="$ac_func"
2212   eval skipcheck=\$skipcheck_$func
2213   if test "x$skipcheck" != "xyes"; then
2214     AC_MSG_CHECKING([deeper for $func])
2215     AC_LINK_IFELSE([
2216       AC_LANG_PROGRAM([[
2217       ]],[[
2218         $func ();
2219       ]])
2220     ],[
2221       AC_MSG_RESULT([yes])
2222       eval "ac_cv_func_$func=yes"
2223       AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$func])], [1],
2224         [Define to 1 if you have the $func function.])
2225     ],[
2226       AC_MSG_RESULT([but still no])
2227     ])
2228   fi
2229 ])
2230
2231
2232 AC_CHECK_DECL(basename, ,
2233               AC_DEFINE(NEED_BASENAME_PROTO, 1, [If you lack a fine basename() prototype]),
2234 #ifdef HAVE_STRING_H
2235 #include <string.h>
2236 #endif
2237 #ifdef HAVE_LIBGEN_H
2238 #include <libgen.h>
2239 #endif
2240 #ifdef HAVE_UNISTD_H
2241 #include <unistd.h>
2242 #endif
2243 )
2244
2245
2246 dnl Check if the getnameinfo function is available
2247 dnl and get the types of five of its arguments.
2248 CURL_CHECK_FUNC_GETNAMEINFO
2249
2250 if test "$ipv6" = "yes"; then
2251   CURL_CHECK_WORKING_GETADDRINFO
2252   CURL_CHECK_NI_WITHSCOPEID
2253 fi
2254
2255 AC_MSG_CHECKING([if we are Mac OS X (to disable poll)])
2256 disable_poll=no
2257 case $host in
2258   *-*-darwin*)
2259     disable_poll="yes";
2260     ;;
2261   *)
2262     ;;
2263 esac
2264 AC_MSG_RESULT($disable_poll)
2265
2266 if test "$disable_poll" = "no"; then
2267
2268   dnl poll() might be badly emulated, as in Mac OS X 10.3 (and other BSDs?) and
2269   dnl to find out we make an extra check here!
2270   if test "$ac_cv_func_poll" = "yes"; then
2271     AC_MSG_CHECKING([if poll works with NULL inputs])
2272     AC_RUN_IFELSE([
2273 #ifdef HAVE_SYS_POLL_H
2274 #include <sys/poll.h>
2275 #elif defined(HAVE_POLL_H)
2276 #include <poll.h>
2277 #endif
2278
2279   int main(void)
2280   {
2281     /* make this return 0 == timeout since there's nothing to read from */
2282     return poll((void *)0, 0, 10 /*ms*/);
2283   }
2284 ],
2285     AC_MSG_RESULT(yes)
2286     AC_DEFINE(HAVE_POLL_FINE, 1, [If you have a fine poll]),
2287     AC_MSG_RESULT(no),
2288     AC_MSG_RESULT(cross-compiling assumes yes)
2289     AC_DEFINE(HAVE_POLL_FINE, 1, [If you have a fine poll])
2290     ) dnl end of AC_RUN_IFELSE
2291   fi dnl poll() was found
2292 fi dnl poll()-check is not disabled
2293
2294
2295 AC_PATH_PROG( PERL, perl, ,
2296   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
2297 AC_SUBST(PERL)
2298
2299 AC_PATH_PROGS( NROFF, gnroff nroff, ,
2300   $PATH:/usr/bin/:/usr/local/bin )
2301 AC_SUBST(NROFF)
2302
2303 if test -n "$NROFF"; then
2304   dnl only check for nroff options if an nroff command was found
2305
2306   AC_MSG_CHECKING([how to use *nroff to get plain text from man pages])
2307   MANOPT="-man"
2308   mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
2309   if test -z "$mancheck"; then
2310     MANOPT="-mandoc"
2311    mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
2312     if test -z "$mancheck"; then
2313       MANOPT=""
2314       AC_MSG_RESULT([failed])
2315       AC_MSG_WARN([found no *nroff option to get plaintext from man pages])
2316     else
2317       AC_MSG_RESULT([$MANOPT])
2318     fi
2319   else
2320     AC_MSG_RESULT([$MANOPT])
2321   fi
2322   AC_SUBST(MANOPT)
2323 fi
2324
2325 if test -z "$MANOPT"
2326 then
2327   dnl if no nroff tool was found, or no option that could convert man pages
2328   dnl was found, then disable the built-in manual stuff
2329   AC_MSG_WARN([disabling built-in manual])
2330   USE_MANUAL="no";
2331 fi
2332
2333 dnl *************************************************************************
2334 dnl If the manual variable still is set, then we go with providing a built-in
2335 dnl manual
2336
2337 if test "$USE_MANUAL" = "1"; then
2338   AC_DEFINE(USE_MANUAL, 1, [If you want to build curl with the built-in manual])
2339   curl_manual_msg="enabled"
2340 fi
2341
2342 dnl set variable for use in automakefile(s)
2343 AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1)
2344
2345 AC_MSG_CHECKING([whether to enable c-ares])
2346 AC_ARG_ENABLE(ares,
2347 AC_HELP_STRING([--enable-ares=PATH],[Enable c-ares for name lookups])
2348 AC_HELP_STRING([--disable-ares],[Disable c-ares for name lookups]),
2349 [ case "$enableval" in
2350   no)
2351        AC_MSG_RESULT(no)
2352        ;;
2353   *)   AC_MSG_RESULT(yes)
2354
2355        if test "x$IPV6_ENABLED" = "x1"; then
2356          AC_MSG_NOTICE([c-ares may not work properly with ipv6])
2357        fi
2358
2359        AC_DEFINE(USE_ARES, 1, [Define if you want to enable c-ares support])
2360        dnl substitute HAVE_ARES for curl-config and similar
2361        HAVE_ARES="1"
2362        AC_SUBST(HAVE_ARES)
2363        curl_ares_msg="enabled"
2364
2365        LIBS="-lcares $LIBS"
2366
2367        dnl For backwards compatibility default to includes/lib in srcdir/ares
2368        dnl If a value is specified it is assumed that the libs are in $val/lib
2369        dnl and the includes are in $val/include. This is the default setup for
2370        dnl ares so it should not be a problem.
2371        if test "x$enableval" = "xyes" ; then
2372          if test -d "$srcdir/ares"; then
2373             aresembedded="yes"
2374             AC_CONFIG_SUBDIRS(ares)
2375             aresinc=`cd $srcdir/ares && pwd`
2376             CPPFLAGS="$CPPFLAGS -I$aresinc"
2377
2378             dnl the pwd= below cannot 'cd' into the ares dir to get the full
2379             dnl path to it, since it may not exist yet if we build outside of
2380             dnl the source tree
2381             pwd=`pwd`
2382             LDFLAGS="$LDFLAGS -L$pwd/ares"
2383          fi
2384        else
2385          CPPFLAGS="$CPPFLAGS -I$enableval/include"
2386          LDFLAGS="$LDFLAGS -L$enableval/lib"
2387        fi
2388
2389        if test -z "$aresembedded"; then
2390          dnl verify that a sufficient c-ares is here if we have pointed one
2391          dnl out and don't use the "embedded" ares dir (in which case we don't
2392          dnl check it because it might not have been built yet)
2393          AC_MSG_CHECKING([that c-ares is good and recent enough])
2394          AC_LINK_IFELSE([
2395            AC_LANG_PROGRAM([[
2396 #include <ares.h>
2397              /* set of dummy functions in case c-ares was built with debug */
2398              void curl_dofree() { }
2399              void curl_sclose() { }
2400              void curl_domalloc() { }
2401              void curl_docalloc() { }
2402              void curl_socket() { }
2403            ]],[[
2404              ares_channel channel;
2405              ares_cancel(channel); /* added in 1.2.0 */
2406              ares_process_fd(channel, 0, 0); /* added in 1.4.0 */
2407            ]])
2408          ],[
2409            AC_MSG_RESULT([yes])
2410          ],[
2411            AC_MSG_RESULT([no])
2412            AC_MSG_ERROR([c-ares library defective or too old])
2413          ])
2414        fi
2415        ;;
2416   esac ],
2417        AC_MSG_RESULT(no)
2418 )
2419
2420 dnl ************************************************************
2421 dnl disable verbose text strings
2422 dnl
2423 AC_MSG_CHECKING([whether to enable verbose strings])
2424 AC_ARG_ENABLE(verbose,
2425 AC_HELP_STRING([--enable-verbose],[Enable verbose strings])
2426 AC_HELP_STRING([--disable-verbose],[Disable verbose strings]),
2427 [ case "$enableval" in
2428   no)
2429        AC_MSG_RESULT(no)
2430        AC_DEFINE(CURL_DISABLE_VERBOSE_STRINGS, 1, [to disable verbose strings])
2431        curl_verbose_msg="no"
2432        ;;
2433   *)   AC_MSG_RESULT(yes)
2434        ;;
2435   esac ],
2436        AC_MSG_RESULT(yes)
2437 )
2438
2439 dnl ************************************************************
2440 dnl enable SSPI support
2441 dnl
2442 AC_MSG_CHECKING([whether to enable SSPI support (Windows native builds only)])
2443 AC_ARG_ENABLE(sspi,
2444 AC_HELP_STRING([--enable-sspi],[Enable SSPI])
2445 AC_HELP_STRING([--disable-sspi],[Disable SSPI]),
2446 [ case "$enableval" in
2447   yes)
2448        if test "$ac_cv_native_windows" = "yes"; then
2449          AC_MSG_RESULT(yes)
2450          AC_DEFINE(USE_WINDOWS_SSPI, 1, [to enable SSPI support])
2451          AC_SUBST(USE_WINDOWS_SSPI, [1])
2452          curl_sspi_msg="yes"
2453        else
2454          AC_MSG_RESULT(no)
2455          AC_MSG_WARN([--enable-sspi Ignored. Only supported on native Windows builds.])
2456        fi
2457        ;;
2458   *)
2459        AC_MSG_RESULT(no)
2460        ;;
2461   esac ],
2462        AC_MSG_RESULT(no)
2463 )
2464
2465 dnl ************************************************************
2466 dnl lame option to switch on debug options
2467 dnl
2468 AC_MSG_CHECKING([whether to enable debug options])
2469 AC_ARG_ENABLE(debug,
2470 AC_HELP_STRING([--enable-debug],[Enable pedantic debug options])
2471 AC_HELP_STRING([--disable-debug],[Disable debug options]),
2472 [ case "$enableval" in
2473   no)
2474        AC_MSG_RESULT(no)
2475        ;;
2476   *)   AC_MSG_RESULT(yes)
2477
2478     CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
2479     CFLAGS="$CFLAGS -g"
2480
2481     dnl set compiler "debug" options to become more picky, and remove
2482     dnl optimize options from CFLAGS
2483     CURL_CC_DEBUG_OPTS
2484        ;;
2485   esac
2486  ],
2487        AC_MSG_RESULT(no)
2488 )
2489
2490 dnl ************************************************************
2491 dnl disable cryptographic authentication
2492 dnl
2493 AC_MSG_CHECKING([whether to enable cryptographic authentication methods])
2494 AC_ARG_ENABLE(crypto-auth,
2495 AC_HELP_STRING([--enable-crypto-auth],[Enable cryptographic authentication])
2496 AC_HELP_STRING([--disable-crypto-auth],[Disable cryptographic authentication]),
2497 [ case "$enableval" in
2498   no)
2499        AC_MSG_RESULT(no)
2500        AC_DEFINE(CURL_DISABLE_CRYPTO_AUTH, 1, [to disable cryptographic authentication])
2501        ;;
2502   *)   AC_MSG_RESULT(yes)
2503        ;;
2504   esac ],
2505        AC_MSG_RESULT(yes)
2506 )
2507
2508 dnl ************************************************************
2509 dnl disable cookies support
2510 dnl
2511 AC_MSG_CHECKING([whether to enable support for cookies])
2512 AC_ARG_ENABLE(cookies,
2513 AC_HELP_STRING([--enable-cookies],[Enable cookies support])
2514 AC_HELP_STRING([--disable-cookies],[Disable cookies support]),
2515 [ case "$enableval" in
2516   no)
2517        AC_MSG_RESULT(no)
2518        AC_DEFINE(CURL_DISABLE_COOKIES, 1, [to disable cookies support])
2519        ;;
2520   *)   AC_MSG_RESULT(yes)
2521        ;;
2522   esac ],
2523        AC_MSG_RESULT(yes)
2524 )
2525
2526 dnl ************************************************************
2527 dnl Enable hiding of internal symbols in library to reduce its size and
2528 dnl speed dynamic linking of applications.  This currently is only supported
2529 dnl on gcc >= 4.0 and SunPro C.
2530 dnl
2531 AC_MSG_CHECKING([whether to enable hidden symbols in the library])
2532 AC_ARG_ENABLE(hidden-symbols,
2533 AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library])
2534 AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]),
2535 [ case "$enableval" in
2536   no)
2537        AC_MSG_RESULT(no)
2538        ;;
2539   *)
2540        AC_MSG_CHECKING([whether $CC supports it])
2541        if test "$GCC" = yes ; then
2542          if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
2543            AC_MSG_RESULT(yes)
2544            AC_DEFINE(CURL_HIDDEN_SYMBOLS, 1, [to enable hidden symbols])
2545            AC_DEFINE(CURL_EXTERN_SYMBOL, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
2546            CFLAGS="$CFLAGS -fvisibility=hidden"
2547          else
2548             AC_MSG_RESULT(no)
2549           fi
2550
2551        else
2552          dnl Test for SunPro cc
2553          if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
2554            AC_MSG_RESULT(yes)
2555            AC_DEFINE(CURL_HIDDEN_SYMBOLS, 1, [to enable hidden symbols])
2556            AC_DEFINE(CURL_EXTERN_SYMBOL, [__global], [to make a symbol visible])
2557            CFLAGS="$CFLAGS -xldscope=hidden"
2558          else
2559            AC_MSG_RESULT(no)
2560          fi
2561        fi
2562        ;;
2563   esac ],
2564        AC_MSG_RESULT(no)
2565 )
2566
2567 dnl ************************************************************
2568 dnl enforce SONAME bump
2569 dnl 
2570
2571 AC_MSG_CHECKING([whether to enforce SONAME bump])
2572 AC_ARG_ENABLE(soname-bump,
2573 AC_HELP_STRING([--enable-soname-bump],[Enable enforced SONAME bump])
2574 AC_HELP_STRING([--disable-soname-bump],[Disable enforced SONAME bump]),
2575 [ case "$enableval" in
2576   yes)   AC_MSG_RESULT(yes)
2577          soname_bump=yes
2578          ;;
2579   *)
2580          AC_MSG_RESULT(no)
2581          ;;
2582   esac ],
2583         AC_MSG_RESULT($soname_bump)
2584 )
2585 AM_CONDITIONAL(SONAME_BUMP, test x$soname_bump = xyes)
2586
2587
2588 dnl ************************************************************
2589 if test ! -z "$winsock_LIB"; then
2590
2591   dnl If ws2_32 is wanted, make sure it is the _last_ lib in LIBS (makes
2592   dnl things work when built with c-ares). But we can't just move it last
2593   dnl since then other stuff (SSL) won't build. So we simply append it to the
2594   dnl end.
2595
2596   LIBS="$LIBS $winsock_LIB"
2597   TEST_SERVER_LIBS="$TEST_SERVER_LIBS $winsock_LIB"
2598
2599 fi
2600
2601 dnl
2602 dnl All the library dependencies put into $LIB apply to libcurl only.
2603 dnl Those in $CURL_LIBS apply to the curl command-line client only.
2604 dnl Those in $TEST_SERVER_LIBS apply to test servers only.
2605 dnl Those in $ALL_LIBS apply to all targets, including test targets.
2606 dnl
2607 LIBCURL_LIBS=$LIBS
2608
2609 AC_SUBST(LIBCURL_LIBS)
2610 AC_SUBST(CURL_LIBS)
2611 AC_SUBST(TEST_SERVER_LIBS)
2612 LIBS=$ALL_LIBS  dnl LIBS is a magic variable that's used for every link
2613
2614 AM_CONDITIONAL(CROSSCOMPILING, test x$cross_compiling = xyes)
2615
2616 dnl
2617 dnl For keeping supported features and protocols also in pkg-config file
2618 dnl since it is more cross-compile frient than curl-config
2619 dnl
2620
2621 if test "x$USE_SSLEAY" = "x1"; then
2622   SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
2623 elif test -n "$SSL_ENABLED"; then
2624   SUPPORT_FEATURES="$SUPPORT_FEATURES SSL"
2625 fi
2626 if test "@KRB4_ENABLED@" = "x1"; then
2627   SUPPORT_FEATURES="$SUPPORT_FEATURES KRB4"
2628 fi
2629 if test "x$IPV6_ENABLED" = "x1"; then
2630   SUPPORT_FEATURES="$SUPPORT_FEATURES IPv6"
2631 fi
2632 if test "x$HAVE_LIBZ" = "x1"; then
2633   SUPPORT_FEATURES="$SUPPORT_FEATURES libz"
2634 fi
2635 if test "x$HAVE_ARES" = "x1"; then
2636   SUPPORT_FEATURES="$SUPPORT_FEATURES AsynchDNS"
2637 fi
2638 if test "x$IDN_ENABLED" = "x1"; then
2639   SUPPORT_FEATURES="$SUPPORT_FEATURES IDN"
2640 fi
2641 if test "x$USE_WINDOWS_SSPI" = "x1"; then
2642   SUPPORT_FEATURES="$SUPPORT_FEATURES SSPI"
2643 fi
2644 if test "x$USE_SSLEAY" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1"; then
2645   SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM"
2646 fi
2647
2648 AC_SUBST(SUPPORT_FEATURES)
2649
2650 dnl For supported protocols in pkg-config file
2651 if test "x$CURL_DISABLE_HTTP" != "x1"; then
2652   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTP"
2653   if test "x$SSL_ENABLED" = "x1"; then
2654     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTPS"
2655   fi
2656 fi
2657 if test "x$CURL_DISABLE_FTP" != "x1"; then
2658   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTP"
2659   if test "x$SSL_ENABLED" = "x1"; then
2660     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTPS"
2661   fi
2662 fi
2663 if test "x$CURL_DISABLE_FILE" != "x1"; then
2664   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FILE"
2665 fi
2666 if test "x$CURL_DISABLE_TELNET" != "x1"; then
2667   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TELNET"
2668 fi
2669 if test "x$CURL_DISABLE_LDAP" != "x1"; then
2670   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAP"
2671 fi
2672 if test "x$CURL_DISABLE_LDAPS" != "x1"; then
2673   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAPS"
2674 fi
2675 if test "x$CURL_DISABLE_DICT" != "x1"; then
2676   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS DICT"
2677 fi
2678 if test "x$CURL_DISABLE_TFTP" != "x1"; then
2679   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TFTP"
2680 fi
2681 if test "x$USE_LIBSSH2" = "x1"; then
2682   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
2683   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
2684 fi
2685
2686 AC_SUBST(SUPPORT_PROTOCOLS)
2687
2688 AC_CONFIG_FILES([Makefile \
2689            docs/Makefile \
2690            docs/examples/Makefile \
2691            docs/libcurl/Makefile \
2692            include/Makefile \
2693            include/curl/Makefile \
2694            src/Makefile \
2695            lib/Makefile \
2696            tests/Makefile \
2697            tests/data/Makefile \
2698            tests/server/Makefile \
2699            tests/libtest/Makefile \
2700            packages/Makefile \
2701            packages/Win32/Makefile \
2702            packages/Win32/cygwin/Makefile \
2703            packages/Linux/Makefile \
2704            packages/Linux/RPM/Makefile \
2705            packages/Linux/RPM/curl.spec \
2706            packages/Linux/RPM/curl-ssl.spec \
2707            packages/Solaris/Makefile \
2708            packages/DOS/Makefile \
2709            packages/EPM/curl.list \
2710            packages/EPM/Makefile \
2711            packages/vms/Makefile \
2712            packages/AIX/Makefile \
2713            packages/AIX/RPM/Makefile \
2714            packages/AIX/RPM/curl.spec \
2715            curl-config \
2716            libcurl.pc
2717 ])
2718 AC_OUTPUT
2719
2720 AC_MSG_NOTICE([Configured to build curl/libcurl:
2721
2722   curl version:    ${VERSION}
2723   Host setup:      ${host}
2724   Install prefix:  ${prefix}
2725   Compiler:        ${CC}
2726   SSL support:     ${curl_ssl_msg}
2727   SSH support:     ${curl_ssh_msg}
2728   zlib support:    ${curl_zlib_msg}
2729   krb4 support:    ${curl_krb4_msg}
2730   GSSAPI support:  ${curl_gss_msg}
2731   SPNEGO support:  ${curl_spnego_msg}
2732   c-ares support:  ${curl_ares_msg}
2733   ipv6 support:    ${curl_ipv6_msg}
2734   IDN support:     ${curl_idn_msg}
2735   Build libcurl:   Shared=${enable_shared}, Static=${enable_static}
2736   Built-in manual: ${curl_manual_msg}
2737   Verbose errors:  ${curl_verbose_msg}
2738   SSPI support:    ${curl_sspi_msg}
2739   ca cert bundle:  ${ca}
2740   ca cert path:    ${capath}
2741   LDAP support:    ${curl_ldap_msg}
2742   LDAPS support:   ${curl_ldaps_msg} 
2743 ])
2744
2745 if test "x$soname_bump" = "xyes"; then
2746
2747 cat <<EOM
2748   SONAME bump:     yes - WARNING: this library will be built with the SONAME
2749                    number bumped due to (a detected) ABI breakage.
2750                    See lib/README.curl_off_t for details on this.
2751 EOM
2752
2753 fi
2754