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