2 dnl Process this file with autoconf to produce a configure script.
4 AC_CONFIG_SRCDIR([lib/urldata.h])
5 AM_CONFIG_HEADER(config.h src/config.h)
7 VERSION=`sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curl.h`
8 AM_INIT_AUTOMAKE(curl,$VERSION)
11 dnl Detect the canonical host and target build environment
15 dnl Get system canonical name
16 AC_DEFINE_UNQUOTED(OS, "${host}")
18 dnl Check for AIX weirdos
21 dnl Checks for programs.
24 dnl check for how to do large files
29 dnl The install stuff has already been taken care of by the automake stuff
33 dnl ************************************************************
34 dnl lame option to switch on debug options
36 AC_MSG_CHECKING([whether to enable debug options])
38 [ --enable-debug Enable pedantic debug options
39 --disable-debug Disable debug options],
40 [ case "$enableval" in
46 CPPFLAGS="$CPPFLAGS -DMALLOCDEBUG"
47 CFLAGS="-Wall -pedantic -g"
55 dnl check for working getaddrinfo()
57 AC_DEFUN(CURL_CHECK_WORKING_GETADDRINFO,[
58 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
61 #include <sys/types.h>
62 #include <sys/socket.h>
65 struct addrinfo hints, *ai;
68 memset(&hints, 0, sizeof(hints));
69 hints.ai_family = AF_UNSPEC;
70 hints.ai_socktype = SOCK_STREAM;
71 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
80 ac_cv_working_getaddrinfo="yes"
82 ac_cv_working_getaddrinfo="no"
84 ac_cv_working_getaddrinfo="yes"
86 if test "$ac_cv_working_getaddrinfo" = "yes"; then
87 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
88 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
91 AC_SUBST(IPV6_ENABLED)
96 AC_DEFUN(CURL_CHECK_LOCALTIME_R,
98 dnl check for a few thread-safe functions
99 AC_CHECK_FUNCS(localtime_r,[
100 AC_MSG_CHECKING(whether localtime_r is declared)
101 AC_EGREP_CPP(localtime_r,[
103 AC_MSG_RESULT(yes)],[
105 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
106 AC_EGREP_CPP(localtime_r,[
109 AC_DEFINE(NEED_REENTRANT)
111 AC_MSG_RESULT(no))])])
114 AC_DEFUN(CURL_CHECK_INET_NTOA_R,
116 dnl determine if function definition for inet_ntoa_r exists.
117 AC_CHECK_FUNCS(inet_ntoa_r,[
118 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
119 AC_EGREP_CPP(inet_ntoa_r,[
120 #include <arpa/inet.h>],[
121 AC_DEFINE(HAVE_INET_NTOA_R_DECL)
122 AC_MSG_RESULT(yes)],[
124 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
125 AC_EGREP_CPP(inet_ntoa_r,[
127 #include <arpa/inet.h>],[
128 AC_DEFINE(HAVE_INET_NTOA_R_DECL)
129 AC_DEFINE(NEED_REENTRANT)
131 AC_MSG_RESULT(no))])])
135 AC_DEFUN(CURL_CHECK_GETHOSTBYADDR_R,
137 dnl check for number of arguments to gethostbyaddr_r. it might take
138 dnl either 5, 7, or 8 arguments.
139 AC_CHECK_FUNCS(gethostbyaddr_r,[
140 AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
142 #include <sys/types.h>
143 #include <netdb.h>],[
148 struct hostent_data hdata;
150 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
152 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
153 ac_cv_gethostbyaddr_args=5],[
155 AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
158 #include <sys/types.h>
159 #include <netdb.h>],[
164 struct hostent_data hdata;
166 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
168 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
169 AC_DEFINE(NEED_REENTRANT)
170 ac_cv_gethostbyaddr_args=5],[
172 AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
174 #include <sys/types.h>
175 #include <netdb.h>],[
184 hp = gethostbyaddr_r(address, length, type, &h,
185 buffer, 8192, &h_errnop);],[
187 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
188 ac_cv_gethostbyaddr_args=7],[
190 AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
192 #include <sys/types.h>
193 #include <netdb.h>],[
203 rc = gethostbyaddr_r(address, length, type, &h,
204 buffer, 8192, &hp, &h_errnop);],[
206 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
207 ac_cv_gethostbyaddr_args=8],[
209 have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
214 AC_DEFUN(CURL_CHECK_GETHOSTBYNAME_R,
216 dnl check for number of arguments to gethostbyname_r. it might take
217 dnl either 3, 5, or 6 arguments.
218 AC_CHECK_FUNCS(gethostbyname_r,[
219 AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments)
222 #include <sys/types.h>
228 struct hostent_data hdata;
229 char *name = "localhost";
231 memset(&h, 0, sizeof(struct hostent));
232 memset(&hdata, 0, sizeof(struct hostent_data));
233 rc = gethostbyname_r(name, &h, &hdata);
234 exit (rc != 0 ? 1 : 0); }],[
236 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
237 ac_cv_gethostbyname_args=3],[
239 AC_MSG_CHECKING(if gethostbyname_r with -D_REENTRANT takes 3 arguments)
244 #include <sys/types.h>
250 struct hostent_data hdata;
251 char *name = "localhost";
253 memset(&h, 0, sizeof(struct hostent));
254 memset(&hdata, 0, sizeof(struct hostent_data));
255 rc = gethostbyname_r(name, &h, &hdata);
256 exit (rc != 0 ? 1 : 0); }],[
258 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
259 AC_DEFINE(NEED_REENTRANT)
260 ac_cv_gethostbyname_args=3],[
262 AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments)
264 #include <sys/types.h>
271 char *name = "localhost";
274 hp = gethostbyname_r(name, &h, buffer, 8192, &h_errno);
275 exit (hp == NULL ? 1 : 0); }],[
277 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
278 ac_cv_gethostbyname_args=5],[
280 AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments)
282 #include <sys/types.h>
289 char *name = "localhost";
293 rc = gethostbyname_r(name, &h, buf, 8192, &hp, &h_errno);
294 exit (rc != 0 ? 1 : 0); }],[
296 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
297 ac_cv_gethostbyname_args=6],[
299 have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
300 [ac_cv_gethostbyname_args=0])],
301 [ac_cv_gethostbyname_args=0])],
302 [ac_cv_gethostbyname_args=0])],
303 [ac_cv_gethostbyname_args=0])])
305 if test "$ac_cv_func_gethostbyname_r" = "yes"; then
306 if test "$ac_cv_gethostbyname_args" = "0"; then
307 dnl there's a gethostbyname_r() function, but we don't know how
308 dnl many arguments it wants!
309 AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
315 dnl **********************************************************************
317 dnl **********************************************************************
319 AC_MSG_CHECKING([whether to enable ipv6])
321 [ --enable-ipv6 Enable ipv6 (with ipv4) support
322 --disable-ipv6 Disable ipv6 support],
323 [ case "$enableval" in
328 *) AC_MSG_RESULT(yes)
333 AC_TRY_RUN([ /* is AF_INET6 available? */
334 #include <sys/types.h>
335 #include <sys/socket.h>
338 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
352 if test "$ipv6" = "yes"; then
353 CURL_CHECK_WORKING_GETADDRINFO
357 dnl **********************************************************************
358 dnl Checks for libraries.
359 dnl **********************************************************************
361 dnl gethostbyname in the nsl lib?
362 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
364 if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then
365 dnl gethostbyname in the socket lib?
366 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(socket, gethostbyname))
369 dnl At least one system has been identified to require BOTH nsl and
370 dnl socket libs to link properly.
371 if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname"; then
372 AC_MSG_CHECKING([trying both nsl and socket libs])
373 my_ac_save_LIBS=$LIBS
374 LIBS="-lnsl -lsocket $LIBS"
377 my_ac_link_result=success,
378 my_ac_link_result=failure )
380 if test "$my_ac_link_result" = "failure"; then
382 AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
384 LIBS=$my_ac_save_LIBS
391 AC_CHECK_FUNC(strcasecmp, , AC_CHECK_LIB(resolve, strcasecmp))
393 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
394 AC_CHECK_LIB(resolve, strcasecmp,
395 [LIBS="-lresolve $LIBS"],
401 AC_CHECK_FUNC(connect, , AC_CHECK_LIB(socket, connect))
404 AC_CHECK_FUNC(gethostname, , AC_CHECK_LIB(ucb, gethostname))
407 AC_CHECK_FUNC(dlopen, , AC_CHECK_LIB(dl, dlopen))
409 dnl **********************************************************************
410 dnl Check for the random seed preferences
411 dnl **********************************************************************
413 AC_ARG_WITH(egd-socket,
414 [ --with-egd-socket=FILE Entropy Gathering Daemon socket pathname],
415 [ EGD_SOCKET="$withval" ]
417 if test -n "$EGD_SOCKET" ; then
418 AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET")
421 dnl Check for user-specified random device
423 [ --with-random=FILE read randomness from FILE (default=/dev/urandom)],
424 [ RANDOM_FILE="$withval" ],
426 dnl Check for random device
427 AC_CHECK_FILE("/dev/urandom",
429 RANDOM_FILE="/dev/urandom";
434 if test -n "$RANDOM_FILE" ; then
435 AC_SUBST(RANDOM_FILE)
436 AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE")
439 dnl **********************************************************************
440 dnl Check for the presence of Kerberos4 libraries and headers
441 dnl **********************************************************************
443 AC_ARG_WITH(krb4-includes,
444 [ --with-krb4-includes[=DIR] Specify location of kerberos4 headers],[
445 CPPFLAGS="$CPPFLAGS -I$withval"
450 AC_ARG_WITH(krb4-libs,
451 [ --with-krb4-libs[=DIR] Specify location of kerberos4 libs],[
452 LDFLAGS="$LDFLAGS -L$withval"
460 [ --with-krb4[=DIR] where to look for Kerberos4],[
462 if test X"$OPT_KRB4" != Xyes
464 LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib"
465 KRB4LIB="$OPT_KRB4/lib"
466 CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
467 KRB4INC="$OPT_KRB4/include"
472 AC_MSG_CHECKING([if Kerberos4 support is requested])
474 if test "$want_krb4" = yes
476 if test "$ipv6" = "yes"; then
477 echo krb4 is not compatible with IPv6
482 dnl Check for & handle argument to --with-krb4
484 AC_MSG_CHECKING(where to look for Kerberos4)
485 if test X"$OPT_KRB4" = Xyes
487 AC_MSG_RESULT([defaults])
489 AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
492 dnl Check for DES library
493 AC_CHECK_LIB(des, des_pcbc_encrypt,
495 AC_CHECK_HEADERS(des.h)
498 AC_CHECK_FUNC(res_search, , AC_CHECK_LIB(resolv, res_search))
500 dnl Check for the Kerberos4 library
501 AC_CHECK_LIB(krb, krb_net_read,
503 dnl Check for header files
504 AC_CHECK_HEADERS(krb.h)
506 dnl we found the required libraries, add to LIBS
507 LIBS="-lkrb -ldes $LIBS"
509 dnl Check for function krb_get_our_ip_for_realm
510 dnl this is needed for NAT networks
511 AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
516 dnl substitute it too!
518 AC_SUBST(KRB4_ENABLED)
520 dnl the krb4 stuff needs a strlcpy()
521 AC_CHECK_FUNCS(strlcpy)
530 dnl **********************************************************************
531 dnl Check for the presence of SSL libraries and headers
532 dnl **********************************************************************
534 dnl Default to compiler & linker defaults for SSL files & libraries.
537 [ --with-ssl[=DIR] where to look for SSL [compiler/linker default paths]
538 DIR points to the SSL installation [/usr/local/ssl]],
542 if test X"$OPT_SSL" = Xno
544 AC_MSG_WARN(SSL/https support disabled)
547 dnl Check for and handle argument to --with-ssl.
552 EXTRA_SSL=/usr/local/ssl ;;
554 EXTRA_SSL=$OPT_SSL ;;
557 AC_CHECK_LIB(crypto, CRYPTO_lock,[
560 OLDLDFLAGS="$LDFLAGS"
561 OLDCPPFLAGS="$CPPFLAGS"
562 LDFLAGS="$LDFLAGS -L$EXTRA_SSL/lib"
563 CPPFLAGS="$CPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
564 AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
565 HAVECRYPTO="yes" ], [
566 LDFLAGS="$OLDLDFLAGS"
567 CPPFLAGS="$OLDCPPFLAGS"
572 if test "$HAVECRYPTO" = "yes"; then
573 dnl This is only reasonable to do if crypto actually is there: check for
574 dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
576 AC_CHECK_LIB(crypto, CRYPTO_add_lock)
577 AC_CHECK_LIB(ssl, SSL_connect)
579 if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
580 dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
581 AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
583 LIBS="$LIBS -lRSAglue -lrsaref"
584 AC_CHECK_LIB(ssl, SSL_connect)
585 if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
586 dnl still no SSL_connect
595 dnl Check for SSLeay headers
596 AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
597 openssl/pem.h openssl/ssl.h openssl/err.h,
600 if test $ac_cv_header_openssl_x509_h = no; then
601 AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h,
605 AC_SUBST(OPENSSL_ENABLED)
609 if test X"$OPT_SSL" != Xoff &&
610 test "$OPENSSL_ENABLED" != "1"; then
611 AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
615 dnl these can only exist if openssl exists
617 AC_CHECK_FUNCS( RAND_status \
623 dnl **********************************************************************
624 dnl Check for the presence of ZLIB libraries and headers
625 dnl **********************************************************************
627 dnl Default to compiler & linker defaults for files & libraries.
629 dnl AC_ARG_WITH(zlib,dnl
630 dnl [ --with-zlib[=DIR] where to look for ZLIB [compiler/linker default paths]
631 dnl DIR points to the ZLIB installation prefix [/usr/local]],
632 dnl OPT_ZLIB=$withval,
635 dnl Check for & handle argument to --with-zlib.
637 dnl NOTE: We *always* look for ZLIB headers & libraries, all this option
638 dnl does is change where we look (by adjusting LIBS and CPPFLAGS.)
641 dnl AC_MSG_CHECKING(where to look for ZLIB)
642 dnl if test X"$OPT_ZLIB" = Xno
644 dnl AC_MSG_RESULT([defaults (or given in environment)])
646 dnl test X"$OPT_ZLIB" = Xyes && OPT_ZLIB=/usr/local
647 dnl LIBS="$LIBS -L$OPT_ZLIB/lib"
648 dnl CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
649 dnl AC_MSG_RESULT([$OPT_ZLIB])
653 dnl AC_CHECK_FUNC(gzread, , AC_CHECK_LIB(z, gzread))
656 dnl Default is to try the thread-safe versions of a few functions
658 AC_ARG_ENABLE(thread,dnl
659 [ --disable-thread tell configure to not look for thread-safe functions],
663 if test X"$OPT_THREAD" = Xoff
665 AC_MSG_WARN(libcurl will not get built using thread-safe functions)
666 AC_DEFINE(DISABLED_THREADSAFE, 1, \
667 Set to explicitly specify we don't want to use thread-safe functions)
670 dnl dig around for gethostbyname_r()
671 CURL_CHECK_GETHOSTBYNAME_R()
673 dnl dig around for gethostbyaddr_r()
674 CURL_CHECK_GETHOSTBYADDR_R()
676 dnl poke around for inet_ntoa_r()
677 CURL_CHECK_INET_NTOA_R()
679 dnl is there a localtime_r()
680 CURL_CHECK_LOCALTIME_R()
684 dnl **********************************************************************
685 dnl Back to "normal" configuring
686 dnl **********************************************************************
688 dnl Checks for header files.
719 dnl Check for libz header
720 dnl AC_CHECK_HEADERS(zlib.h)
722 dnl Checks for typedefs, structures, and compiler characteristics.
729 # check for 'long double'
730 AC_CHECK_SIZEOF(long double, 8)
731 # check for 'long long'
732 AC_CHECK_SIZEOF(long long, 4)
735 AC_CHECK_TYPE(ssize_t, int)
738 dnl We can't just AC_CHECK_TYPE() for socklen_t since it doesn't appear
739 dnl in the standard headers. We egrep for it in the socket headers and
740 dnl if it is used there we assume we have the type defined, otherwise
741 dnl we search for it with AC_CHECK_TYPE() the "normal" way
744 if test "$ac_cv_header_sys_socket_h" = "yes"; then
745 AC_MSG_CHECKING(for socklen_t in sys/socket.h)
746 AC_EGREP_HEADER(socklen_t,
753 if test "$socklen_t" != "yes"; then
754 # check for socklen_t the standard way if it wasn't found before
755 AC_CHECK_TYPE(socklen_t, int)
758 dnl Checks for library functions.
759 dnl AC_PROG_GCC_TRADITIONAL
762 AC_CHECK_FUNCS( socket \
790 dnl removed 'getpass' check on October 26, 2000
792 if test "$ac_cv_func_select" != "yes"; then
793 AC_MSG_ERROR(Can't work without an existing select() function)
795 if test "$ac_cv_func_socket" != "yes"; then
796 AC_MSG_ERROR(Can't work without an existing socket() function)
799 AC_PATH_PROG( PERL, perl, ,
800 $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
803 AC_PATH_PROGS( NROFF, gnroff nroff, ,
804 $PATH:/usr/bin/:/usr/local/bin )
809 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib,
810 dnl $PATH:/usr/bin/:/usr/local/bin )
813 AC_CONFIG_FILES([Makefile \
815 docs/examples/Makefile \
817 include/curl/Makefile \
821 tests/data/Makefile \
823 packages/Win32/Makefile \
824 packages/Linux/Makefile \
825 packages/Linux/RPM/Makefile \
826 packages/Linux/RPM/curl.spec \
827 packages/Linux/RPM/curl-ssl.spec \
829 perl/Curl_easy/Makefile \
831 php/examples/Makefile \