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