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