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])
87 AC_SUBST(IPV6_ENABLED)
92 AC_DEFUN(CURL_CHECK_LOCALTIME_R,
94 dnl check for a few thread-safe functions
95 AC_CHECK_FUNCS(localtime_r,[
96 AC_MSG_CHECKING(whether localtime_r is declared)
97 AC_EGREP_CPP(localtime_r,[
101 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
102 AC_EGREP_CPP(localtime_r,[
105 AC_DEFINE(NEED_REENTRANT)
107 AC_MSG_RESULT(no))])])
110 AC_DEFUN(CURL_CHECK_INET_NTOA_R,
112 dnl determine if function definition for inet_ntoa_r exists.
113 AC_CHECK_FUNCS(inet_ntoa_r,[
114 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
115 AC_EGREP_CPP(inet_ntoa_r,[
116 #include <arpa/inet.h>],[
117 AC_DEFINE(HAVE_INET_NTOA_R_DECL)
118 AC_MSG_RESULT(yes)],[
120 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
121 AC_EGREP_CPP(inet_ntoa_r,[
123 #include <arpa/inet.h>],[
124 AC_DEFINE(HAVE_INET_NTOA_R_DECL)
125 AC_DEFINE(NEED_REENTRANT)
127 AC_MSG_RESULT(no))])])
131 AC_DEFUN(CURL_CHECK_GETHOSTBYADDR_R,
133 dnl check for number of arguments to gethostbyaddr_r. it might take
134 dnl either 5, 7, or 8 arguments.
135 AC_CHECK_FUNCS(gethostbyaddr_r,[
136 AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
138 #include <sys/types.h>
139 #include <netdb.h>],[
144 struct hostent_data hdata;
146 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
148 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
149 ac_cv_gethostbyaddr_args=5],[
151 AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
154 #include <sys/types.h>
155 #include <netdb.h>],[
160 struct hostent_data hdata;
162 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
164 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
165 AC_DEFINE(NEED_REENTRANT)
166 ac_cv_gethostbyaddr_args=5],[
168 AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
170 #include <sys/types.h>
171 #include <netdb.h>],[
180 hp = gethostbyaddr_r(address, length, type, &h,
181 buffer, 8192, &h_errnop);],[
183 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
184 ac_cv_gethostbyaddr_args=7],[
186 AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
188 #include <sys/types.h>
189 #include <netdb.h>],[
199 rc = gethostbyaddr_r(address, length, type, &h,
200 buffer, 8192, &hp, &h_errnop);],[
202 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
203 ac_cv_gethostbyaddr_args=8],[
205 have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
210 AC_DEFUN(CURL_CHECK_GETHOSTBYNAME_R,
212 dnl check for number of arguments to gethostbyname_r. it might take
213 dnl either 3, 5, or 6 arguments.
214 AC_CHECK_FUNCS(gethostbyname_r,[
215 AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments)
218 #include <sys/types.h>
224 struct hostent_data hdata;
225 char *name = "localhost";
227 memset(&h, 0, sizeof(struct hostent));
228 memset(&hdata, 0, sizeof(struct hostent_data));
229 rc = gethostbyname_r(name, &h, &hdata);
230 exit (rc != 0 ? 1 : 0); }],[
232 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
233 ac_cv_gethostbyname_args=3],[
235 AC_MSG_CHECKING(if gethostbyname_r with -D_REENTRANT takes 3 arguments)
240 #include <sys/types.h>
246 struct hostent_data hdata;
247 char *name = "localhost";
249 memset(&h, 0, sizeof(struct hostent));
250 memset(&hdata, 0, sizeof(struct hostent_data));
251 rc = gethostbyname_r(name, &h, &hdata);
252 exit (rc != 0 ? 1 : 0); }],[
254 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
255 AC_DEFINE(NEED_REENTRANT)
256 ac_cv_gethostbyname_args=3],[
258 AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments)
260 #include <sys/types.h>
267 char *name = "localhost";
270 hp = gethostbyname_r(name, &h, buffer, 8192, &h_errno);
271 exit (hp == NULL ? 1 : 0); }],[
273 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
274 ac_cv_gethostbyname_args=5],[
276 AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments)
278 #include <sys/types.h>
285 char *name = "localhost";
289 rc = gethostbyname_r(name, &h, buf, 8192, &hp, &h_errno);
290 exit (rc != 0 ? 1 : 0); }],[
292 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
293 ac_cv_gethostbyname_args=6],[
295 have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
296 [ac_cv_gethostbyname_args=0])],
297 [ac_cv_gethostbyname_args=0])],
298 [ac_cv_gethostbyname_args=0])],
299 [ac_cv_gethostbyname_args=0])])
301 if test "$ac_cv_func_gethostbyname_r" = "yes"; then
302 if test "$ac_cv_gethostbyname_args" = "0"; then
303 dnl there's a gethostbyname_r() function, but we don't know how
304 dnl many arguments it wants!
305 AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
311 dnl **********************************************************************
313 dnl **********************************************************************
315 AC_MSG_CHECKING([whether to enable ipv6])
317 [ --enable-ipv6 Enable ipv6 (with ipv4) support
318 --disable-ipv6 Disable ipv6 support],
319 [ case "$enableval" in
324 *) AC_MSG_RESULT(yes)
329 AC_TRY_RUN([ /* is AF_INET6 available? */
330 #include <sys/types.h>
331 #include <sys/socket.h>
334 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
348 if test "$ipv6" = "yes"; then
349 CURL_CHECK_WORKING_GETADDRINFO
353 dnl **********************************************************************
354 dnl Checks for libraries.
355 dnl **********************************************************************
357 dnl gethostbyname in the nsl lib?
358 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
360 if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then
361 dnl gethostbyname in the socket lib?
362 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(socket, gethostbyname))
365 dnl At least one system has been identified to require BOTH nsl and
366 dnl socket libs to link properly.
367 if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname"; then
368 AC_MSG_CHECKING([trying both nsl and socket libs])
369 my_ac_save_LIBS=$LIBS
370 LIBS="-lnsl -lsocket $LIBS"
373 my_ac_link_result=success,
374 my_ac_link_result=failure )
376 if test "$my_ac_link_result" = "failure"; then
378 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
380 LIBS=$my_ac_save_LIBS
387 AC_CHECK_FUNC(strcasecmp, , AC_CHECK_LIB(resolve, strcasecmp))
389 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
390 AC_CHECK_LIB(resolve, strcasecmp,
391 [LIBS="-lresolve $LIBS"],
397 AC_CHECK_FUNC(connect, , AC_CHECK_LIB(socket, connect))
400 AC_CHECK_FUNC(gethostname, , AC_CHECK_LIB(ucb, gethostname))
403 AC_CHECK_FUNC(dlopen, , AC_CHECK_LIB(dl, dlopen))
405 dnl **********************************************************************
406 dnl Check for the random seed preferences
407 dnl **********************************************************************
409 AC_ARG_WITH(egd-socket,
410 [ --with-egd-socket=FILE Entropy Gathering Daemon socket pathname],
411 [ EGD_SOCKET="$withval" ]
413 if test -n "$EGD_SOCKET" ; then
414 AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET")
417 dnl Check for user-specified random device
419 [ --with-random=FILE read randomness from FILE (default=/dev/urandom)],
420 [ RANDOM_FILE="$withval" ],
422 dnl Check for random device
423 AC_CHECK_FILE("/dev/urandom",
425 RANDOM_FILE="/dev/urandom";
430 if test -n "$RANDOM_FILE" ; then
431 AC_SUBST(RANDOM_FILE)
432 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE")
435 dnl **********************************************************************
436 dnl Check for the presence of Kerberos4 libraries and headers
437 dnl **********************************************************************
439 AC_ARG_WITH(krb4-includes,
440 [ --with-krb4-includes[=DIR] Specify location of kerberos4 headers],[
441 CPPFLAGS="$CPPFLAGS -I$withval"
446 AC_ARG_WITH(krb4-libs,
447 [ --with-krb4-libs[=DIR] Specify location of kerberos4 libs],[
448 LDFLAGS="$LDFLAGS -L$withval"
456 [ --with-krb4[=DIR] where to look for Kerberos4],[
458 if test X"$OPT_KRB4" != Xyes
460 LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib"
461 KRB4LIB="$OPT_KRB4/lib"
462 CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
463 KRB4INC="$OPT_KRB4/include"
468 AC_MSG_CHECKING([if Kerberos4 support is requested])
470 if test "$want_krb4" = yes
472 if test "$ipv6" = "yes"; then
473 echo krb4 is not compatible with IPv6
478 dnl Check for & handle argument to --with-krb4
480 AC_MSG_CHECKING(where to look for Kerberos4)
481 if test X"$OPT_KRB4" = Xyes
483 AC_MSG_RESULT([defaults])
485 AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
488 dnl Check for DES library
489 AC_CHECK_LIB(des, des_pcbc_encrypt,
491 AC_CHECK_HEADERS(des.h)
494 AC_CHECK_FUNC(res_search, , AC_CHECK_LIB(resolv, res_search))
496 dnl Check for the Kerberos4 library
497 AC_CHECK_LIB(krb, krb_net_read,
499 dnl Check for header files
500 AC_CHECK_HEADERS(krb.h)
502 dnl we found the required libraries, add to LIBS
503 LIBS="-lkrb -ldes $LIBS"
505 dnl Check for function krb_get_our_ip_for_realm
506 dnl this is needed for NAT networks
507 AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
512 dnl substitute it too!
514 AC_SUBST(KRB4_ENABLED)
516 dnl the krb4 stuff needs a strlcpy()
517 AC_CHECK_FUNCS(strlcpy)
525 dnl **********************************************************************
526 dnl Check for the presence of SSL libraries and headers
527 dnl **********************************************************************
529 dnl Default to compiler & linker defaults for SSL files & libraries.
532 [ --with-ssl[=DIR] where to look for SSL [compiler/linker default paths]
533 DIR points to the SSL installation [/usr/local/ssl]],
537 if test X"$OPT_SSL" = Xno
539 AC_MSG_WARN(SSL/https support disabled)
542 dnl Check for & handle argument to --with-ssl.
544 AC_MSG_CHECKING(where to look for SSL)
545 if test X"$OPT_SSL" = Xoff
547 AC_MSG_RESULT([defaults (or given in environment)])
549 test X"$OPT_SSL" = Xyes && OPT_SSL=/usr/local/ssl
550 dnl LIBS="$LIBS -L$OPT_SSL/lib"
551 LDFLAGS="$LDFLAGS -L$OPT_SSL/lib"
552 CPPFLAGS="$CPPFLAGS -I$OPT_SSL/include/openssl -I$OPT_SSL/include"
553 AC_MSG_RESULT([$OPT_SSL])
556 dnl check for crypto libs (part of SSLeay)
557 AC_CHECK_LIB(crypto, CRYPTO_lock)
559 if test $ac_cv_lib_crypto_CRYPTO_lock = yes; then
560 dnl This is only reasonable to do if crypto actually is there: check for
561 dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
562 AC_CHECK_LIB(ssl, SSL_connect)
564 if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
565 dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
566 AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
568 LIBS="$LIBS -lRSAglue -lrsaref"
569 AC_CHECK_LIB(ssl, SSL_connect)
570 if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
571 dnl still no SSL_connect
581 dnl Check for SSLeay headers
582 AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
583 openssl/pem.h openssl/ssl.h openssl/err.h)
585 if test $ac_cv_header_openssl_x509_h = no; then
586 AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h)
590 dnl If all heades are present, we have enabled SSL!
591 if test "$ac_cv_header_openssl_x509_h" = "yes" &&
592 test "$ac_cv_header_openssl_rsa_h" = "yes" &&
593 test "$ac_cv_header_openssl_crypto_h" = "yes" &&
594 test "$ac_cv_header_openssl_pem_h" = "yes" &&
595 test "$ac_cv_header_openssl_ssl_h" = "yes" &&
596 test "$ac_cv_header_openssl_err_h" = "yes"; then
601 dnl Check the alternative headers too
602 if test "$ac_cv_header_x509_h" = "yes" &&
603 test "$ac_cv_header_rsa_h" = "yes" &&
604 test "$ac_cv_header_crypto_h" = "yes" &&
605 test "$ac_cv_header_pem_h" = "yes" &&
606 test "$ac_cv_header_ssl_h" = "yes" &&
607 test "$ac_cv_header_err_h" = "yes"; then
611 AC_SUBST(OPENSSL_ENABLED)
615 if test X"$OPT_SSL" != Xoff &&
616 test "$OPENSSL_ENABLED" != "1"; then
617 AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
621 dnl these can only exist if openssl exists
623 AC_CHECK_FUNCS( RAND_status \
629 dnl **********************************************************************
630 dnl Check for the presence of ZLIB libraries and headers
631 dnl **********************************************************************
633 dnl Default to compiler & linker defaults for files & libraries.
635 dnl AC_ARG_WITH(zlib,dnl
636 dnl [ --with-zlib[=DIR] where to look for ZLIB [compiler/linker default paths]
637 dnl DIR points to the ZLIB installation prefix [/usr/local]],
638 dnl OPT_ZLIB=$withval,
641 dnl Check for & handle argument to --with-zlib.
643 dnl NOTE: We *always* look for ZLIB headers & libraries, all this option
644 dnl does is change where we look (by adjusting LIBS and CPPFLAGS.)
647 dnl AC_MSG_CHECKING(where to look for ZLIB)
648 dnl if test X"$OPT_ZLIB" = Xno
650 dnl AC_MSG_RESULT([defaults (or given in environment)])
652 dnl test X"$OPT_ZLIB" = Xyes && OPT_ZLIB=/usr/local
653 dnl LIBS="$LIBS -L$OPT_ZLIB/lib"
654 dnl CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
655 dnl AC_MSG_RESULT([$OPT_ZLIB])
659 dnl AC_CHECK_FUNC(gzread, , AC_CHECK_LIB(z, gzread))
662 dnl Default is to try the thread-safe versions of a few functions
664 AC_ARG_ENABLE(thread,dnl
665 [ --disable-thread tell configure to not look for thread-safe functions],
669 if test X"$OPT_THREAD" = Xoff
671 AC_MSG_WARN(libcurl will not get built using thread-safe functions)
672 AC_DEFINE(DISABLED_THREADSAFE, 1, \
673 Set to explicitly specify we don't want to use thread-safe functions)
676 dnl dig around for gethostbyname_r()
677 CURL_CHECK_GETHOSTBYNAME_R()
679 dnl dig around for gethostbyaddr_r()
680 CURL_CHECK_GETHOSTBYADDR_R()
682 dnl poke around for inet_ntoa_r()
683 CURL_CHECK_INET_NTOA_R()
685 dnl is there a localtime_r()
686 CURL_CHECK_LOCALTIME_R()
690 dnl **********************************************************************
691 dnl Back to "normal" configuring
692 dnl **********************************************************************
694 dnl Checks for header files.
725 dnl Check for libz header
726 dnl AC_CHECK_HEADERS(zlib.h)
728 dnl Checks for typedefs, structures, and compiler characteristics.
735 # check for 'long double'
736 AC_CHECK_SIZEOF(long double, 8)
737 # check for 'long long'
738 AC_CHECK_SIZEOF(long long, 4)
741 AC_CHECK_TYPE(ssize_t, int)
744 dnl We can't just AC_CHECK_TYPE() for socklen_t since it doesn't appear
745 dnl in the standard headers. We egrep for it in the socket headers and
746 dnl if it is used there we assume we have the type defined, otherwise
747 dnl we search for it with AC_CHECK_TYPE() the "normal" way
750 if test "$ac_cv_header_sys_socket_h" = "yes"; then
751 AC_MSG_CHECKING(for socklen_t in sys/socket.h)
752 AC_EGREP_HEADER(socklen_t,
759 if test "$socklen_t" != "yes"; then
760 # check for socklen_t the standard way if it wasn't found before
761 AC_CHECK_TYPE(socklen_t, int)
765 dnl Get system canonical name
767 AC_DEFINE_UNQUOTED(OS, "${host}")
769 dnl Checks for library functions.
770 dnl AC_PROG_GCC_TRADITIONAL
773 AC_CHECK_FUNCS( socket \
801 dnl removed 'getpass' check on October 26, 2000
803 if test "$ac_cv_func_select" != "yes"; then
804 AC_MSG_ERROR(Can't work without an existing select() function)
806 if test "$ac_cv_func_socket" != "yes"; then
807 AC_MSG_ERROR(Can't work without an existing socket() function)
810 AC_PATH_PROG( PERL, perl, ,
811 $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
814 AC_PATH_PROGS( NROFF, gnroff nroff, ,
815 $PATH:/usr/bin/:/usr/local/bin )
820 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib,
821 dnl $PATH:/usr/bin/:/usr/local/bin )
824 AC_OUTPUT( Makefile \
826 docs/examples/Makefile \
828 include/curl/Makefile \
832 tests/data/Makefile \
834 packages/Win32/Makefile \
835 packages/Linux/Makefile \
836 packages/Linux/RPM/Makefile \
837 packages/Linux/RPM/curl.spec \
838 packages/Linux/RPM/curl-ssl.spec \
840 perl/Curl_easy/Makefile \
842 php/examples/Makefile \