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