2 dnl Process this file with autoconf to produce a configure script.
4 AM_CONFIG_HEADER(config.h src/config.h)
6 VERSION=`sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curl.h`
7 AM_INIT_AUTOMAKE(curl,$VERSION)
11 dnl Detect the canonical host and target build environment
16 dnl Checks for programs.
19 dnl Check for AIX weirdos
22 dnl check for how to do large files
25 dnl The install stuff has already been taken care of by the automake stuff
29 dnl ************************************************************
30 dnl lame option to switch on debug options
32 AC_MSG_CHECKING([whether to enable debug options])
34 [ --enable-debug Enable pedantic debug options
35 --disable-debug Disable debug options],
36 [ case "$enableval" in
42 CPPFLAGS="$CPPFLAGS -DMALLOCDEBUG"
43 CFLAGS="-Wall -pedantic -g"
51 dnl check for working getaddrinfo()
53 AC_DEFUN(CURL_CHECK_WORKING_GETADDRINFO,[
54 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
57 #include <sys/types.h>
58 #include <sys/socket.h>
61 struct addrinfo hints, *ai;
64 memset(&hints, 0, sizeof(hints));
65 hints.ai_family = AF_UNSPEC;
66 hints.ai_socktype = SOCK_STREAM;
67 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
76 ac_cv_working_getaddrinfo="yes"
78 ac_cv_working_getaddrinfo="no"
80 ac_cv_working_getaddrinfo="yes"
82 if test "$ac_cv_working_getaddrinfo" = "yes"; then
83 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
84 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
89 AC_DEFUN(CURL_CHECK_LOCALTIME_R,
91 dnl check for a few thread-safe functions
92 AC_CHECK_FUNCS(localtime_r,[
93 AC_MSG_CHECKING(whether localtime_r is declared)
94 AC_EGREP_CPP(localtime_r,[
98 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
99 AC_EGREP_CPP(localtime_r,[
102 AC_DEFINE(NEED_REENTRANT)
104 AC_MSG_RESULT(no))])])
107 AC_DEFUN(CURL_CHECK_INET_NTOA_R,
109 dnl determine if function definition for inet_ntoa_r exists.
110 AC_CHECK_FUNCS(inet_ntoa_r,[
111 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
112 AC_EGREP_CPP(inet_ntoa_r,[
113 #include <arpa/inet.h>],[
114 AC_DEFINE(HAVE_INET_NTOA_R_DECL)
115 AC_MSG_RESULT(yes)],[
117 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
118 AC_EGREP_CPP(inet_ntoa_r,[
120 #include <arpa/inet.h>],[
121 AC_DEFINE(HAVE_INET_NTOA_R_DECL)
122 AC_DEFINE(NEED_REENTRANT)
124 AC_MSG_RESULT(no))])])
128 AC_DEFUN(CURL_CHECK_GETHOSTBYADDR_R,
130 dnl check for number of arguments to gethostbyaddr_r. it might take
131 dnl either 5, 7, or 8 arguments.
132 AC_CHECK_FUNCS(gethostbyaddr_r,[
133 AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
135 #include <sys/types.h>
136 #include <netdb.h>],[
141 struct hostent_data hdata;
143 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
145 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
146 ac_cv_gethostbyaddr_args=5],[
148 AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
151 #include <sys/types.h>
152 #include <netdb.h>],[
157 struct hostent_data hdata;
159 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
161 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
162 AC_DEFINE(NEED_REENTRANT)
163 ac_cv_gethostbyaddr_args=5],[
165 AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
167 #include <sys/types.h>
168 #include <netdb.h>],[
177 hp = gethostbyaddr_r(address, length, type, &h,
178 buffer, 8192, &h_errnop);],[
180 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
181 ac_cv_gethostbyaddr_args=7],[
183 AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
185 #include <sys/types.h>
186 #include <netdb.h>],[
196 rc = gethostbyaddr_r(address, length, type, &h,
197 buffer, 8192, &hp, &h_errnop);],[
199 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
200 ac_cv_gethostbyaddr_args=8],[
202 have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
207 AC_DEFUN(CURL_CHECK_GETHOSTBYNAME_R,
209 dnl check for number of arguments to gethostbyname_r. it might take
210 dnl either 3, 5, or 6 arguments.
211 AC_CHECK_FUNCS(gethostbyname_r,[
212 AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments)
215 #include <sys/types.h>
221 struct hostent_data hdata;
222 char *name = "localhost";
224 memset(&h, 0, sizeof(struct hostent));
225 memset(&hdata, 0, sizeof(struct hostent_data));
226 rc = gethostbyname_r(name, &h, &hdata);
227 exit (rc != 0 ? 1 : 0); }],[
229 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
230 ac_cv_gethostbyname_args=3],[
232 AC_MSG_CHECKING(if gethostbyname_r with -D_REENTRANT takes 3 arguments)
237 #include <sys/types.h>
243 struct hostent_data hdata;
244 char *name = "localhost";
246 memset(&h, 0, sizeof(struct hostent));
247 memset(&hdata, 0, sizeof(struct hostent_data));
248 rc = gethostbyname_r(name, &h, &hdata);
249 exit (rc != 0 ? 1 : 0); }],[
251 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
252 AC_DEFINE(NEED_REENTRANT)
253 ac_cv_gethostbyname_args=3],[
255 AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments)
257 #include <sys/types.h>
264 char *name = "localhost";
267 hp = gethostbyname_r(name, &h, buffer, 8192, &h_errno);
268 exit (hp == NULL ? 1 : 0); }],[
270 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
271 ac_cv_gethostbyname_args=5],[
273 AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments)
275 #include <sys/types.h>
282 char *name = "localhost";
286 rc = gethostbyname_r(name, &h, buf, 8192, &hp, &h_errno);
287 exit (rc != 0 ? 1 : 0); }],[
289 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
290 ac_cv_gethostbyname_args=6],[
292 have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
293 [ac_cv_gethostbyname_args=0])],
294 [ac_cv_gethostbyname_args=0])],
295 [ac_cv_gethostbyname_args=0])],
296 [ac_cv_gethostbyname_args=0])])
300 dnl **********************************************************************
302 dnl **********************************************************************
304 AC_MSG_CHECKING([whether to enable ipv6])
306 [ --enable-ipv6 Enable ipv6 (with ipv4) support
307 --disable-ipv6 Disable ipv6 support],
308 [ case "$enableval" in
313 *) AC_MSG_RESULT(yes)
318 AC_TRY_RUN([ /* is AF_INET6 available? */
319 #include <sys/types.h>
320 #include <sys/socket.h>
323 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
337 if test "$ipv6" = "yes"; then
338 CURL_CHECK_WORKING_GETADDRINFO
342 dnl **********************************************************************
343 dnl Checks for libraries.
344 dnl **********************************************************************
346 dnl gethostbyname in the nsl lib?
347 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
349 if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then
350 dnl gethostbyname in the socket lib?
351 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(socket, gethostbyname))
354 dnl At least one system has been identified to require BOTH nsl and
355 dnl socket libs to link properly.
356 if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname"; then
357 AC_MSG_CHECKING([trying both nsl and socket libs])
358 my_ac_save_LIBS=$LIBS
359 LIBS="-lnsl -lsocket $LIBS"
362 my_ac_link_result=success,
363 my_ac_link_result=failure )
365 if test "$my_ac_link_result" = "failure"; then
367 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
369 LIBS=$my_ac_save_LIBS
376 AC_CHECK_FUNC(strcasecmp, , AC_CHECK_LIB(resolve, strcasecmp))
378 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
379 AC_CHECK_LIB(resolve, strcasecmp,
380 [LIBS="-lresolve $LIBS"],
386 AC_CHECK_FUNC(connect, , AC_CHECK_LIB(socket, connect))
389 AC_CHECK_FUNC(gethostname, , AC_CHECK_LIB(ucb, gethostname))
392 AC_CHECK_FUNC(dlopen, , AC_CHECK_LIB(dl, dlopen))
394 dnl **********************************************************************
395 dnl Check for the random seed preferences
396 dnl **********************************************************************
398 AC_ARG_WITH(egd-socket,
399 [ --with-egd-socket=FILE Entropy Gathering Daemon socket pathname],
400 [ EGD_SOCKET="$withval" ]
402 if test -n "$EGD_SOCKET" ; then
403 AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET")
406 dnl Check for user-specified random device
408 [ --with-random=FILE read randomness from FILE (default=/dev/urandom)],
409 [ RANDOM_FILE="$withval" ],
411 dnl Check for random device
412 AC_CHECK_FILE("/dev/urandom",
414 RANDOM_FILE="/dev/urandom";
419 if test -n "$RANDOM_FILE" ; then
420 AC_SUBST(RANDOM_FILE)
421 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE")
424 dnl **********************************************************************
425 dnl Check for the presence of Kerberos4 libraries and headers
426 dnl **********************************************************************
428 AC_ARG_WITH(krb4-includes,
429 [ --with-krb4-includes[=DIR] Specify location of kerberos4 headers],[
430 CPPFLAGS="$CPPFLAGS -I$withval"
435 AC_ARG_WITH(krb4-libs,
436 [ --with-krb4-libs[=DIR] Specify location of kerberos4 libs],[
437 LDFLAGS="$LDFLAGS -L$withval"
445 [ --with-krb4[=DIR] where to look for Kerberos4],[
447 if test X"$OPT_KRB4" != Xyes
449 LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib"
450 KRB4LIB="$OPT_KRB4/lib"
451 CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
452 KRB4INC="$OPT_KRB4/include"
457 AC_MSG_CHECKING([if Kerberos4 support is requested])
459 if test "$want_krb4" = yes
461 if test "$ipv6" = "yes"; then
462 echo krb4 is not compatible with IPv6
467 dnl Check for & handle argument to --with-krb4
469 AC_MSG_CHECKING(where to look for Kerberos4)
470 if test X"$OPT_KRB4" = Xyes
472 AC_MSG_RESULT([defaults])
474 AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
477 dnl Check for DES library
478 AC_CHECK_LIB(des, des_pcbc_encrypt,
480 AC_CHECK_HEADERS(des.h)
483 AC_CHECK_FUNC(res_search, , AC_CHECK_LIB(resolv, res_search))
485 dnl Check for the Kerberos4 library
486 AC_CHECK_LIB(krb, krb_net_read,
488 dnl Check for header files
489 AC_CHECK_HEADERS(krb.h)
491 dnl we found the required libraries, add to LIBS
492 LIBS="-lkrb -ldes $LIBS"
494 dnl Check for function krb_get_our_ip_for_realm
495 dnl this is needed for NAT networks
496 AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
501 dnl the krb4 stuff needs a strlcpy()
502 AC_CHECK_FUNCS(strlcpy)
510 dnl **********************************************************************
511 dnl Check for the presence of SSL libraries and headers
512 dnl **********************************************************************
514 dnl Default to compiler & linker defaults for SSL files & libraries.
517 [ --with-ssl[=DIR] where to look for SSL [compiler/linker default paths]
518 DIR points to the SSL installation [/usr/local/ssl]],
522 if test X"$OPT_SSL" = Xno
524 AC_MSG_WARN(SSL/https support disabled)
527 dnl Check for & handle argument to --with-ssl.
529 AC_MSG_CHECKING(where to look for SSL)
530 if test X"$OPT_SSL" = Xoff
532 AC_MSG_RESULT([defaults (or given in environment)])
534 test X"$OPT_SSL" = Xyes && OPT_SSL=/usr/local/ssl
535 dnl LIBS="$LIBS -L$OPT_SSL/lib"
536 LDFLAGS="$LDFLAGS -L$OPT_SSL/lib"
537 CPPFLAGS="$CPPFLAGS -I$OPT_SSL/include/openssl -I$OPT_SSL/include"
538 AC_MSG_RESULT([$OPT_SSL])
541 dnl check for crypto libs (part of SSLeay)
542 AC_CHECK_LIB(crypto, CRYPTO_lock)
544 if test $ac_cv_lib_crypto_CRYPTO_lock = yes; then
545 dnl This is only reasonable to do if crypto actually is there: check for
546 dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
547 AC_CHECK_LIB(ssl, SSL_connect)
549 if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
550 dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
551 AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
553 LIBS="$LIBS -lRSAglue -lrsaref"
554 AC_CHECK_LIB(ssl, SSL_connect)
555 if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
556 dnl still no SSL_connect
566 dnl Check for SSLeay headers
567 AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h openssl/pem.h openssl/ssl.h openssl/err.h)
569 if test $ac_cv_header_openssl_x509_h = no; then
570 AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h)
575 dnl these can only exist if openssl exists
577 AC_CHECK_FUNCS( RAND_status \
583 dnl **********************************************************************
584 dnl Check for the presence of ZLIB libraries and headers
585 dnl **********************************************************************
587 dnl Default to compiler & linker defaults for files & libraries.
589 dnl AC_ARG_WITH(zlib,dnl
590 dnl [ --with-zlib[=DIR] where to look for ZLIB [compiler/linker default paths]
591 dnl DIR points to the ZLIB installation prefix [/usr/local]],
592 dnl OPT_ZLIB=$withval,
595 dnl Check for & handle argument to --with-zlib.
597 dnl NOTE: We *always* look for ZLIB headers & libraries, all this option
598 dnl does is change where we look (by adjusting LIBS and CPPFLAGS.)
601 dnl AC_MSG_CHECKING(where to look for ZLIB)
602 dnl if test X"$OPT_ZLIB" = Xno
604 dnl AC_MSG_RESULT([defaults (or given in environment)])
606 dnl test X"$OPT_ZLIB" = Xyes && OPT_ZLIB=/usr/local
607 dnl LIBS="$LIBS -L$OPT_ZLIB/lib"
608 dnl CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
609 dnl AC_MSG_RESULT([$OPT_ZLIB])
613 dnl AC_CHECK_FUNC(gzread, , AC_CHECK_LIB(z, gzread))
616 dnl Default is to try the thread-safe versions of a few functions
618 AC_ARG_ENABLE(thread,dnl
619 [ --disable-thread tell configure to not look for thread-safe functions],
623 if test X"$OPT_THREAD" = Xoff
625 AC_MSG_WARN(libcurl will not get built using thread-safe functions)
626 AC_DEFINE(DISABLED_THREADSAFE, 1, \
627 Set to explicitly specify we don't want to use thread-safe functions)
630 dnl dig around for gethostbyname_r()
631 CURL_CHECK_GETHOSTBYNAME_R()
633 dnl dig around for gethostbyaddr_r()
634 CURL_CHECK_GETHOSTBYADDR_R()
636 dnl poke around for inet_ntoa_r()
637 CURL_CHECK_INET_NTOA_R()
639 dnl is there a localtime_r()
640 CURL_CHECK_LOCALTIME_R()
644 dnl **********************************************************************
645 dnl Back to "normal" configuring
646 dnl **********************************************************************
648 dnl Checks for header files.
679 dnl Check for libz header
680 dnl AC_CHECK_HEADERS(zlib.h)
682 dnl Checks for typedefs, structures, and compiler characteristics.
689 # check for 'long double'
690 AC_CHECK_SIZEOF(long double, 8)
691 # check for 'long long'
692 AC_CHECK_SIZEOF(long long, 4)
695 AC_CHECK_TYPE(ssize_t, int)
698 dnl We can't just AC_CHECK_TYPE() for socklen_t since it doesn't appear
699 dnl in the standard headers. We egrep for it in the socket headers and
700 dnl if it is used there we assume we have the type defined, otherwise
701 dnl we search for it with AC_CHECK_TYPE() the "normal" way
704 if test "$ac_cv_header_sys_socket_h" = "yes"; then
705 AC_MSG_CHECKING(for socklen_t in sys/socket.h)
706 AC_EGREP_HEADER(socklen_t,
713 if test "$socklen_t" != "yes"; then
714 # check for socklen_t the standard way if it wasn't found before
715 AC_CHECK_TYPE(socklen_t, int)
719 dnl Get system canonical name
721 AC_DEFINE_UNQUOTED(OS, "${host}")
723 dnl Checks for library functions.
724 dnl AC_PROG_GCC_TRADITIONAL
727 AC_CHECK_FUNCS( socket \
755 dnl removed 'getpass' check on October 26, 2000
757 if test "$ac_cv_func_select" != "yes"; then
758 AC_MSG_ERROR(Can't work without an existing select() function)
760 if test "$ac_cv_func_socket" != "yes"; then
761 AC_MSG_ERROR(Can't work without an existing socket() function)
764 AC_PATH_PROG( PERL, perl, ,
765 $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
768 AC_PATH_PROGS( NROFF, gnroff nroff, ,
769 $PATH:/usr/bin/:/usr/local/bin )
774 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib,
775 dnl $PATH:/usr/bin/:/usr/local/bin )
778 AC_OUTPUT( Makefile \
780 docs/examples/Makefile \
782 include/curl/Makefile \
786 tests/data/Makefile \
788 packages/Win32/Makefile \
789 packages/Linux/Makefile \
790 packages/Linux/RPM/Makefile \
791 packages/Linux/RPM/curl.spec \
792 packages/Linux/RPM/curl-ssl.spec )