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)
526 dnl **********************************************************************
527 dnl Check for the presence of SSL libraries and headers
528 dnl **********************************************************************
530 dnl Default to compiler & linker defaults for SSL files & libraries.
533 [ --with-ssl[=DIR] where to look for SSL [compiler/linker default paths]
534 DIR points to the SSL installation [/usr/local/ssl]],
538 if test X"$OPT_SSL" = Xno
540 AC_MSG_WARN(SSL/https support disabled)
543 dnl Check for and handle argument to --with-ssl.
548 EXTRA_SSL=/usr/local/ssl ;;
550 EXTRA_SSL=$OPT_SSL ;;
553 AC_CHECK_LIB(crypto, CRYPTO_lock,[
556 OLDLDFLAGS="$LDFLAGS"
557 OLDCPPFLAGS="$CPPFLAGS"
558 LDFLAGS="$LDFLAGS -L$EXTRA_SSL/lib"
559 CPPFLAGS="$CPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
560 AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
561 HAVECRYPTO="yes" ], [
562 LDFLAGS="$OLDLDFLAGS"
563 CPPFLAGS="$OLDCPPFLAGS"
568 if test "$HAVECRYPTO" = "yes"; then
569 dnl This is only reasonable to do if crypto actually is there: check for
570 dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
572 LIBS="$LIBS -lcrypto"
574 AC_CHECK_LIB(ssl, SSL_connect)
576 if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
577 dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
578 AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
580 LIBS="$LIBS -lRSAglue -lrsaref"
581 AC_CHECK_LIB(ssl, SSL_connect)
582 if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
583 dnl still no SSL_connect
592 dnl Check for SSLeay headers
593 AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
594 openssl/pem.h openssl/ssl.h openssl/err.h,
597 if test $ac_cv_header_openssl_x509_h = no; then
598 AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h,
602 AC_SUBST(OPENSSL_ENABLED)
606 if test X"$OPT_SSL" != Xoff &&
607 test "$OPENSSL_ENABLED" != "1"; then
608 AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
612 dnl these can only exist if openssl exists
614 AC_CHECK_FUNCS( RAND_status \
620 dnl **********************************************************************
621 dnl Check for the presence of ZLIB libraries and headers
622 dnl **********************************************************************
624 dnl Default to compiler & linker defaults for files & libraries.
626 dnl AC_ARG_WITH(zlib,dnl
627 dnl [ --with-zlib[=DIR] where to look for ZLIB [compiler/linker default paths]
628 dnl DIR points to the ZLIB installation prefix [/usr/local]],
629 dnl OPT_ZLIB=$withval,
632 dnl Check for & handle argument to --with-zlib.
634 dnl NOTE: We *always* look for ZLIB headers & libraries, all this option
635 dnl does is change where we look (by adjusting LIBS and CPPFLAGS.)
638 dnl AC_MSG_CHECKING(where to look for ZLIB)
639 dnl if test X"$OPT_ZLIB" = Xno
641 dnl AC_MSG_RESULT([defaults (or given in environment)])
643 dnl test X"$OPT_ZLIB" = Xyes && OPT_ZLIB=/usr/local
644 dnl LIBS="$LIBS -L$OPT_ZLIB/lib"
645 dnl CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
646 dnl AC_MSG_RESULT([$OPT_ZLIB])
650 dnl AC_CHECK_FUNC(gzread, , AC_CHECK_LIB(z, gzread))
653 dnl Default is to try the thread-safe versions of a few functions
655 AC_ARG_ENABLE(thread,dnl
656 [ --disable-thread tell configure to not look for thread-safe functions],
660 if test X"$OPT_THREAD" = Xoff
662 AC_MSG_WARN(libcurl will not get built using thread-safe functions)
663 AC_DEFINE(DISABLED_THREADSAFE, 1, \
664 Set to explicitly specify we don't want to use thread-safe functions)
667 dnl dig around for gethostbyname_r()
668 CURL_CHECK_GETHOSTBYNAME_R()
670 dnl dig around for gethostbyaddr_r()
671 CURL_CHECK_GETHOSTBYADDR_R()
673 dnl poke around for inet_ntoa_r()
674 CURL_CHECK_INET_NTOA_R()
676 dnl is there a localtime_r()
677 CURL_CHECK_LOCALTIME_R()
681 dnl **********************************************************************
682 dnl Back to "normal" configuring
683 dnl **********************************************************************
685 dnl Checks for header files.
716 dnl Check for libz header
717 dnl AC_CHECK_HEADERS(zlib.h)
719 dnl Checks for typedefs, structures, and compiler characteristics.
726 # check for 'long double'
727 AC_CHECK_SIZEOF(long double, 8)
728 # check for 'long long'
729 AC_CHECK_SIZEOF(long long, 4)
732 AC_CHECK_TYPE(ssize_t, int)
735 dnl We can't just AC_CHECK_TYPE() for socklen_t since it doesn't appear
736 dnl in the standard headers. We egrep for it in the socket headers and
737 dnl if it is used there we assume we have the type defined, otherwise
738 dnl we search for it with AC_CHECK_TYPE() the "normal" way
741 if test "$ac_cv_header_sys_socket_h" = "yes"; then
742 AC_MSG_CHECKING(for socklen_t in sys/socket.h)
743 AC_EGREP_HEADER(socklen_t,
750 if test "$socklen_t" != "yes"; then
751 # check for socklen_t the standard way if it wasn't found before
752 AC_CHECK_TYPE(socklen_t, int)
756 dnl Get system canonical name
758 AC_DEFINE_UNQUOTED(OS, "${host}")
760 dnl Checks for library functions.
761 dnl AC_PROG_GCC_TRADITIONAL
764 AC_CHECK_FUNCS( socket \
792 dnl removed 'getpass' check on October 26, 2000
794 if test "$ac_cv_func_select" != "yes"; then
795 AC_MSG_ERROR(Can't work without an existing select() function)
797 if test "$ac_cv_func_socket" != "yes"; then
798 AC_MSG_ERROR(Can't work without an existing socket() function)
801 AC_PATH_PROG( PERL, perl, ,
802 $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
805 AC_PATH_PROGS( NROFF, gnroff nroff, ,
806 $PATH:/usr/bin/:/usr/local/bin )
811 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib,
812 dnl $PATH:/usr/bin/:/usr/local/bin )
815 AC_OUTPUT( Makefile \
817 docs/examples/Makefile \
819 include/curl/Makefile \
823 tests/data/Makefile \
825 packages/Win32/Makefile \
826 packages/Linux/Makefile \
827 packages/Linux/RPM/Makefile \
828 packages/Linux/RPM/curl.spec \
829 packages/Linux/RPM/curl-ssl.spec \
831 perl/Curl_easy/Makefile \
833 php/examples/Makefile \