AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
HAVE_WINDOWS_H shall not be defined.
int dummy=2*WINVER;
])
],[
ac_cv_header_windows_h="yes"
],[
ac_cv_header_windows_h="no"
])
])
case "$ac_cv_header_windows_h" in
yes)
AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
[Define to 1 if you have the windows.h header file.])
AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
[Define to avoid automatic inclusion of winsock.h])
;;
esac
])
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS]) AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
HAVE_WINSOCK_H shall not be defined.
int dummy=WSACleanup();
])
],[
ac_cv_header_winsock_h="yes"
],[
ac_cv_header_winsock_h="no"
])
])
case "$ac_cv_header_winsock_h" in
yes)
AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
[Define to 1 if you have the winsock.h header file.])
;;
esac
])
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS]) AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
HAVE_WINSOCK2_H shall not be defined.
int dummy=2*IPPROTO_ESP;
])
],[
ac_cv_header_winsock2_h="yes"
],[
ac_cv_header_winsock2_h="no"
])
])
case "$ac_cv_header_winsock2_h" in
yes)
AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
[Define to 1 if you have the winsock2.h header file.])
;;
esac
])
AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2]) AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
HAVE_WS2TCPIP_H shall not be defined.
int dummy=2*IP_PKTINFO;
])
],[
ac_cv_header_ws2tcpip_h="yes"
],[
ac_cv_header_ws2tcpip_h="no"
])
])
case "$ac_cv_header_ws2tcpip_h" in
yes)
AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
[Define to 1 if you have the ws2tcpip.h header file.])
;;
esac
])
AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
void *p = malloc(10);
void *q = calloc(10,10);
free(p);
free(q);
])
],[
ac_cv_header_malloc_h="yes"
],[
ac_cv_header_malloc_h="no"
])
])
if test "$ac_cv_header_malloc_h" = "yes"; then
AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
[Define to 1 if you have the malloc.h header file.])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
void *p = malloc(10);
void *q = calloc(10,10);
free(p);
free(q);
])
],[
curl_cv_need_header_malloc_h="no"
],[
curl_cv_need_header_malloc_h="yes"
])
case "$curl_cv_need_header_malloc_h" in
yes)
AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
[Define to 1 if you need the malloc.h header file even with stdlib.h])
;;
esac
fi
])
AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP]) AC_CHECK_TYPE([socklen_t], ,[
AC_CACHE_CHECK([for socklen_t equivalent],
[curl_cv_socklen_t_equiv], [
curl_cv_socklen_t_equiv="unknown"
for arg2 in "struct sockaddr" void; do
for t in int size_t unsigned long "unsigned long"; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
int getpeername (int, $arg2 *, $t *);
],[
$t len=0;
getpeername(0,0,&len);
])
],[
curl_cv_socklen_t_equiv="$t"
break 2
])
done
done
])
case "$curl_cv_socklen_t_equiv" in
unknown)
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
;;
*)
AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
[type to use in place of socklen_t if not defined])
;;
esac
],[
])
])
AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP]) AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T]) AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
AC_MSG_CHECKING([for getnameinfo])
AC_LINK_IFELSE([
AC_LANG_FUNC_LINK_TRY([getnameinfo])
],[
AC_MSG_RESULT([yes])
curl_cv_getnameinfo="yes"
],[
AC_MSG_RESULT([no])
curl_cv_getnameinfo="no"
])
if test "$curl_cv_getnameinfo" != "yes"; then
AC_MSG_CHECKING([deeper for getnameinfo])
AC_TRY_LINK([
],[
getnameinfo();
],[
AC_MSG_RESULT([yes])
curl_cv_getnameinfo="yes"
],[
AC_MSG_RESULT([but still no])
curl_cv_getnameinfo="no"
])
fi
if test "$curl_cv_getnameinfo" != "yes"; then
AC_MSG_CHECKING([deeper and deeper for getnameinfo])
AC_TRY_LINK([
],[
getnameinfo(0, 0, 0, 0, 0, 0, 0);
],[
AC_MSG_RESULT([yes])
curl_cv_getnameinfo="yes"
],[
AC_MSG_RESULT([but still no])
curl_cv_getnameinfo="no"
])
fi
if test "$curl_cv_getnameinfo" = "yes"; then
AC_CACHE_CHECK([types of arguments for getnameinfo],
[curl_cv_func_getnameinfo_args], [
curl_cv_func_getnameinfo_args="unknown"
for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
for gni_arg7 in 'int' 'unsigned int'; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
char *, $gni_arg46,
char *, $gni_arg46,
$gni_arg7);
],[
$gni_arg2 salen=0;
$gni_arg46 hostlen=0;
$gni_arg46 servlen=0;
$gni_arg7 flags=0;
int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
])
],[
curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
break 4
])
done
done
done
done
]) if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
else
gni_prev_IFS=$IFS; IFS=','
set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
IFS=$gni_prev_IFS
shift
gni_qual_type_arg1=$[1]
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
[Define to the type of arg 2 for getnameinfo.])
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
[Define to the type of args 4 and 6 for getnameinfo.])
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
[Define to the type of arg 7 for getnameinfo.])
prev_sh_opts=$-
case $prev_sh_opts in
*f*)
;;
*)
set -f
;;
esac
case "$gni_qual_type_arg1" in
const*)
gni_qual_arg1=const
gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
;;
*)
gni_qual_arg1=
gni_type_arg1=$gni_qual_type_arg1
;;
esac
AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
[Define to the type qualifier of arg 1 for getnameinfo.])
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
[Define to the type of arg 1 for getnameinfo.])
case $prev_sh_opts in
*f*)
;;
*)
set +f
;;
esac
AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
[Define to 1 if you have the getnameinfo function.])
ac_cv_func_getnameinfo="yes"
fi
fi
])
AC_DEFUN([TYPE_SOCKADDR_STORAGE],
[
AC_CHECK_TYPE([struct sockaddr_storage],
AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
[if struct sockaddr_storage is defined]), ,
[
])
])
AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO]) AC_REQUIRE([TYPE_SOCKADDR_STORAGE]) AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
netdb.h netinet/in.h arpa/inet.h)
AC_CACHE_CHECK([for working NI_WITHSCOPEID],
[ac_cv_working_ni_withscopeid], [
AC_RUN_IFELSE([
AC_LANG_PROGRAM([
],[
struct sockaddr_storage sa;
unsigned char sa[256];
char hostbuf[NI_MAXHOST];
int rc;
GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
int fd = socket(AF_INET6, SOCK_STREAM, 0);
if(fd < 0) {
perror("socket()");
return 1; /* Error creating socket */
}
rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
if(rc) {
perror("getsockname()");
return 2; /* Error retrieving socket name */
}
rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
if(rc) {
printf("rc = %s\n", gai_strerror(rc));
return 3; /* Error translating socket address */
}
return 0; /* Ok, NI_WITHSCOPEID works */
return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
]) ],[
ac_cv_working_ni_withscopeid="yes"
],[
ac_cv_working_ni_withscopeid="no"
],[
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
])
],[
ac_cv_working_ni_withscopeid="yes"
],[
ac_cv_working_ni_withscopeid="no"
]) ]) ]) case "$ac_cv_working_ni_withscopeid" in
yes)
AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
[Define to 1 if NI_WITHSCOPEID exists and works.])
;;
esac
])
AC_DEFUN([CURL_CHECK_FUNC_RECV], [
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK]) AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2]) AC_CHECK_HEADERS(sys/types.h sys/socket.h)
AC_MSG_CHECKING([for recv])
AC_TRY_LINK([
],[
recv(0, 0, 0, 0);
],[
AC_MSG_RESULT([yes])
curl_cv_recv="yes"
],[
AC_MSG_RESULT([no])
curl_cv_recv="no"
])
if test "$curl_cv_recv" = "yes"; then
AC_CACHE_CHECK([types of args and return type for recv],
[curl_cv_func_recv_args], [
curl_cv_func_recv_args="unknown"
for recv_retv in 'int' 'ssize_t'; do
for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
for recv_arg2 in 'char *' 'void *'; do
for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
for recv_arg4 in 'int' 'unsigned int'; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
],[
$recv_arg1 s=0;
$recv_arg2 buf=0;
$recv_arg3 len=0;
$recv_arg4 flags=0;
$recv_retv res = recv(s, buf, len, flags);
])
],[
curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
break 5
])
done
done
done
done
done
]) if test "$curl_cv_func_recv_args" = "unknown"; then
AC_MSG_ERROR([Cannot find proper types to use for recv args])
else
recv_prev_IFS=$IFS; IFS=','
set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
IFS=$recv_prev_IFS
shift
AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
[Define to the type of arg 1 for recv.])
AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
[Define to the type of arg 2 for recv.])
AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
[Define to the type of arg 3 for recv.])
AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
[Define to the type of arg 4 for recv.])
AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
[Define to the function return type for recv.])
AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
[Define to 1 if you have the recv function.])
ac_cv_func_recv="yes"
fi
else
AC_MSG_ERROR([Unable to link function recv])
fi
]) # AC_DEFUN
dnl CURL_CHECK_FUNC_SEND
dnl -------------------------------------------------
dnl Test if the socket send() function is available,
dnl and check its return type and the types of its
dnl arguments. If the function succeeds HAVE_SEND
dnl will be defined, defining the types of the arguments
dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
dnl and SEND_TYPE_ARG4, defining the type of the function
dnl return value in SEND_TYPE_RETV, and also defining the
dnl type qualifier of second argument in SEND_QUAL_ARG2.
AC_DEFUN([CURL_CHECK_FUNC_SEND], [
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
AC_CHECK_HEADERS(sys/types.h sys/socket.h)
#
AC_MSG_CHECKING([for send])
AC_TRY_LINK([
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#else
#ifdef HAVE_WINSOCK_H
#include <winsock.h>
#endif
#endif
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#endif
],[
send(0, 0, 0, 0);
],[
AC_MSG_RESULT([yes])
curl_cv_send="yes"
],[
AC_MSG_RESULT([no])
curl_cv_send="no"
])
#
if test "$curl_cv_send" = "yes"; then
AC_CACHE_CHECK([types of args and return type for send],
[curl_cv_func_send_args], [
curl_cv_func_send_args="unknown"
for send_retv in 'int' 'ssize_t'; do
for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
for send_arg4 in 'int' 'unsigned int'; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
],[
$send_arg1 s=0;
$send_arg3 len=0;
$send_arg4 flags=0;
$send_retv res = send(s, 0, len, flags);
])
],[
curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
break 5
])
done
done
done
done
done
]) if test "$curl_cv_func_send_args" = "unknown"; then
AC_MSG_ERROR([Cannot find proper types to use for send args])
else
send_prev_IFS=$IFS; IFS=','
set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
IFS=$send_prev_IFS
shift
send_qual_type_arg2=$[2]
AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
[Define to the type of arg 1 for send.])
AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
[Define to the type of arg 3 for send.])
AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
[Define to the type of arg 4 for send.])
AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
[Define to the function return type for send.])
prev_sh_opts=$-
case $prev_sh_opts in
*f*)
;;
*)
set -f
;;
esac
case "$send_qual_type_arg2" in
const*)
send_qual_arg2=const
send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
;;
*)
send_qual_arg2=
send_type_arg2=$send_qual_type_arg2
;;
esac
AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
[Define to the type qualifier of arg 2 for send.])
AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
[Define to the type of arg 2 for send.])
case $prev_sh_opts in
*f*)
;;
*)
set +f
;;
esac
AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
[Define to 1 if you have the send function.])
ac_cv_func_send="yes"
fi
else
AC_MSG_ERROR([Unable to link function send])
fi
])
AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
AC_CHECK_HEADERS(sys/types.h sys/socket.h)
AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
int flag=MSG_NOSIGNAL;
])
],[
ac_cv_msg_nosignal="yes"
],[
ac_cv_msg_nosignal="no"
])
])
case "$ac_cv_msg_nosignal" in
yes)
AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
[Define to 1 if you have the MSG_NOSIGNAL flag.])
;;
esac
])
AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
AC_REQUIRE([AC_HEADER_TIME]) AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK]) AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2]) AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
struct timeval ts;
ts.tv_sec = 0;
ts.tv_usec = 0;
])
],[
ac_cv_struct_timeval="yes"
],[
ac_cv_struct_timeval="no"
])
])
case "$ac_cv_struct_timeval" in
yes)
AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
[Define to 1 if you have the timeval struct.])
;;
esac
])
AC_DEFUN([TYPE_SIG_ATOMIC_T], [
AC_CHECK_HEADERS(signal.h)
AC_CHECK_TYPE([sig_atomic_t],[
AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
[Define to 1 if sig_atomic_t is an available typedef.])
], ,[
])
case "$ac_cv_type_sig_atomic_t" in
yes)
AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
AC_TRY_LINK([
],[
static volatile sig_atomic_t dummy = 0;
],[
AC_MSG_RESULT([no])
ac_cv_sig_atomic_t_volatile="no"
],[
AC_MSG_RESULT([yes])
ac_cv_sig_atomic_t_volatile="yes"
])
if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
[Define to 1 if sig_atomic_t is already defined as volatile.])
fi
;;
esac
])
AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
[
AC_MSG_CHECKING([non-blocking sockets style])
AC_TRY_COMPILE([
/* headers for O_NONBLOCK test */
],[
/* try to compile O_NONBLOCK */
int socket;
int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
],[
nonblock="O_NONBLOCK"
AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
],[
AC_TRY_COMPILE([
/* headers for FIONBIO test */
],[
/* FIONBIO source test (old-style unix) */
int socket;
int flags = ioctl(socket, FIONBIO, &flags);
],[
nonblock="FIONBIO"
AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
],[
AC_TRY_COMPILE([
/* headers for ioctlsocket test (Windows) */
],[
/* ioctlsocket source code */
SOCKET sd;
unsigned long flags = 0;
sd = socket(0, 0, 0);
ioctlsocket(sd, FIONBIO, &flags);
],[
nonblock="ioctlsocket"
AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
],[
AC_TRY_LINK([
/* headers for IoctlSocket test (Amiga?) */
],[
/* IoctlSocket source code */
int socket;
int flags = IoctlSocket(socket, FIONBIO, (long)1);
],[
nonblock="IoctlSocket"
AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
],[
AC_TRY_COMPILE([
/* headers for SO_NONBLOCK test (BeOS) */
],[
/* SO_NONBLOCK source code */
long b = 1;
int socket;
int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
],[
nonblock="SO_NONBLOCK"
AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
],[
nonblock="nada"
AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
])
])
])
])
])
AC_MSG_RESULT($nonblock)
if test "$nonblock" = "nada"; then
AC_MSG_WARN([non-block sockets disabled])
fi
])
AC_DEFUN([TYPE_IN_ADDR_T],
[
AC_CHECK_TYPE([in_addr_t], ,[
AC_MSG_CHECKING([for in_addr_t equivalent])
AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
[
curl_cv_in_addr_t_equiv=
for t in "unsigned long" int size_t unsigned long; do
AC_TRY_COMPILE([
],[
$t data = inet_addr ("1.2.3.4");
],[
curl_cv_in_addr_t_equiv="$t"
break
])
done
if test "x$curl_cv_in_addr_t_equiv" = x; then
AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
fi
])
AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
[type to use in place of in_addr_t if not defined])],
[
]) ])
AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
AC_MSG_CHECKING([if "localhost" resolves])
AC_TRY_RUN([
int
main () {
struct hostent *h;
h = gethostbyname("localhost");
exit (h == NULL ? 1 : 0); }],[
AC_MSG_RESULT(yes)],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
]
)
])
AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
AC_TRY_RUN( [
int main(void)
{
struct addrinfo hints, *ai;
int error;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_NUMERICHOST;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
if (error) {
return 1;
}
return 0;
}
],[
ac_cv_working_getaddrinfo="yes"
],[
ac_cv_working_getaddrinfo="no"
],[
ac_cv_working_getaddrinfo="yes"
])])
if test "$ac_cv_working_getaddrinfo" = "yes"; then
AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
IPV6_ENABLED=1
AC_SUBST(IPV6_ENABLED)
fi
])
AC_DEFUN([CURL_CHECK_LOCALTIME_R],
[
AC_CHECK_FUNCS(localtime_r,[
AC_MSG_CHECKING(whether localtime_r is declared)
AC_EGREP_CPP(localtime_r,[
AC_MSG_RESULT(yes)],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
AC_EGREP_CPP(localtime_r,[
AC_DEFINE(NEED_REENTRANT)
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))])])
])
AC_DEFUN([CURL_CHECK_STRERROR_R],
[
AC_CHECK_FUNCS(strerror_r)
if test "x$ac_cv_func_strerror_r" = "xyes"; then
AC_MSG_CHECKING(whether strerror_r is declared)
AC_EGREP_CPP(strerror_r,[
AC_MSG_RESULT(yes)],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
AC_EGREP_CPP(strerror_r,[
CPPFLAGS="-D_REENTRANT $CPPFLAGS"
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no)
AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
) ])
AC_MSG_CHECKING([for a glibc strerror_r API])
AC_TRY_RUN([
int
main () {
char buffer[1024]; /* big enough to play with */
char *string =
strerror_r(EACCES, buffer, sizeof(buffer));
/* this should've returned a string */
if(!string || !string[0])
return 99;
return 0;
}
],
GLIBC_STRERROR_R="1"
AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]),
AC_EGREP_CPP(yes, [
yes
],
GLIBC_STRERROR_R="1"
AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
AC_MSG_RESULT([yes]),
AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
) )
if test -z "$GLIBC_STRERROR_R"; then
AC_MSG_CHECKING([for a POSIX strerror_r API])
AC_TRY_RUN([
int
main () {
char buffer[1024]; /* big enough to play with */
int error =
strerror_r(EACCES, buffer, sizeof(buffer));
/* This should've returned zero, and written an error string in the
buffer.*/
if(!buffer[0] || error)
return 99;
return 0;
}
],
AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]) ,
AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
)
fi
fi
])
AC_DEFUN([CURL_CHECK_INET_NTOA_R],
[
AC_CHECK_FUNCS(inet_ntoa_r,[
AC_MSG_CHECKING(whether inet_ntoa_r is declared)
AC_EGREP_CPP(inet_ntoa_r,[
AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
AC_MSG_RESULT(yes)],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
AC_EGREP_CPP(inet_ntoa_r,[
AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))])])
])
AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R],
[
AC_CHECK_FUNCS(gethostbyaddr_r,[
AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
AC_TRY_COMPILE([
char * address;
int length;
int type;
struct hostent h;
struct hostent_data hdata;
int rc;
rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
ac_cv_gethostbyaddr_args=5],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
AC_TRY_COMPILE([
char * address;
int length;
int type;
struct hostent h;
struct hostent_data hdata;
int rc;
rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
ac_cv_gethostbyaddr_args=5],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netdb.h>],[
char * address;
int length;
int type;
struct hostent h;
char buffer[8192];
int h_errnop;
struct hostent * hp;
hp = gethostbyaddr_r(address, length, type, &h,
buffer, 8192, &h_errnop);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args] )
ac_cv_gethostbyaddr_args=7],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netdb.h>],[
char * address;
int length;
int type;
struct hostent h;
char buffer[8192];
int h_errnop;
struct hostent * hp;
int rc;
rc = gethostbyaddr_r(address, length, type, &h,
buffer, 8192, &hp, &h_errnop);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
ac_cv_gethostbyaddr_args=8],[
AC_MSG_RESULT(no)
have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
])
AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R],
[
dnl check for number of arguments to gethostbyname_r. it might take
dnl either 3, 5, or 6 arguments.
AC_CHECK_FUNCS(gethostbyname_r,[
AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
AC_TRY_COMPILE([
#include <string.h>
#include <sys/types.h>
#include <netdb.h>
#undef NULL
#define NULL (void *)0
int
gethostbyname_r(const char *, struct hostent *, struct hostent_data *);],[
struct hostent_data data;
gethostbyname_r(NULL, NULL, NULL);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
ac_cv_gethostbyname_args=3],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
AC_TRY_COMPILE([
#define _REENTRANT
#include <string.h>
#include <sys/types.h>
#include <netdb.h>
#undef NULL
#define NULL (void *)0
int
gethostbyname_r(const char *,struct hostent *, struct hostent_data *);],[
struct hostent_data data;
gethostbyname_r(NULL, NULL, NULL);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
AC_DEFINE(NEED_REENTRANT, 1, [needs REENTRANT])
ac_cv_gethostbyname_args=3],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netdb.h>
#undef NULL
#define NULL (void *)0
struct hostent *
gethostbyname_r(const char *, struct hostent *, char *, int, int *);],[
gethostbyname_r(NULL, NULL, NULL, 0, NULL);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
ac_cv_gethostbyname_args=5],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netdb.h>
#undef NULL
#define NULL (void *)0
int
gethostbyname_r(const char *, struct hostent *, char *, size_t,
struct hostent **, int *);],[
gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
ac_cv_gethostbyname_args=6],[
AC_MSG_RESULT(no)
have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
[ac_cv_gethostbyname_args=0])],
[ac_cv_gethostbyname_args=0])],
[ac_cv_gethostbyname_args=0])],
[ac_cv_gethostbyname_args=0])])
if test "$ac_cv_func_gethostbyname_r" = "yes"; then
if test "$ac_cv_gethostbyname_args" = "0"; then
dnl there's a gethostbyname_r() function, but we don't know how
AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
fi
fi
])
AC_DEFUN([CURL_DETECT_ICC],
[
ICC="no"
AC_MSG_CHECKING([for icc in use])
if test "$GCC" = "yes"; then
AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
ICC="no",
ICC="yes"
AC_MSG_RESULT([yes])
[$1]
)
fi
if test "$ICC" = "no"; then
AC_MSG_RESULT([no])
fi
])
AC_DEFUN([CURL_CC_DEBUG_OPTS],
[
if test "z$ICC" = "z"; then
CURL_DETECT_ICC
fi
if test "$GCC" = "yes"; then
AC_MSG_CHECKING([gcc version])
gccver=`$CC -dumpversion`
num1=`echo $gccver | cut -d . -f1`
num2=`echo $gccver | cut -d . -f2`
gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
AC_MSG_RESULT($gccver)
if test "$ICC" = "yes"; then
WARN="-wd279,269,981,1418,1419"
if test "$gccnum" -gt "600"; then
WARN="-Wall $WARN"
fi
else WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
if test "$gccnum" -ge "207"; then
WARN="$WARN -Wmissing-declarations"
fi
if test "$gccnum" -gt "295"; then
WARN="$WARN -Wundef -Wno-long-long -Wsign-compare"
fi
if test "$gccnum" -ge "296"; then
WARN="$WARN -Wfloat-equal"
fi
if test "$gccnum" -gt "296"; then
WARN="$WARN -Wno-format-nonliteral"
fi
if test "$gccnum" -ge "303"; then
WARN="$WARN -Wendif-labels -Wstrict-prototypes"
fi
if test "$gccnum" -ge "304"; then
WARN="$WARN -Wdeclaration-after-statement"
fi
for flag in $CPPFLAGS; do
case "$flag" in
-I*)
add=`echo $flag | sed 's/^-I/-isystem /g'`
WARN="$WARN $add"
;;
esac
done
fi
CFLAGS="$CFLAGS $WARN"
AC_MSG_NOTICE([Added this set of compiler options: $WARN])
else
AC_MSG_NOTICE([Added no extra compiler options])
fi
NEWFLAGS=""
for flag in $CFLAGS; do
case "$flag" in
-O*)
;;
*)
NEWFLAGS="$NEWFLAGS $flag"
;;
esac
done
CFLAGS=$NEWFLAGS
])
AC_DEFUN([CURL_DLLIB_NAME],
[
AC_MSG_CHECKING([name of dynamic library $2])
test -z "$shared_ext" && eval shared_ext=\"$shrext_cmds\"
test -z "$shared_ext" && shared_ext="$std_shrext"
test -z "$shared_ext" && shared_ext="$shrext"
test -z "$shared_ext" && shared_ext=".so"
LIBNAME_LINK_SPEC=`echo "$library_names_spec" | $SED 's/^.* //'`
DLGUESSLIB=`name=$2 eval echo "$libname_spec"`
DLGUESSFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$LIBNAME_LINK_SPEC"`
test -z "$DLGUESSFILE" && DLGUESSFILE="$DLGUESSLIB$shared_ext"
SO_NAME_SPEC="$soname_spec"
test -z "$SO_NAME_SPEC" && SO_NAME_SPEC=`echo "$library_names_spec" | $SED 's/ .*$//'`
DLGUESSSOFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$SO_NAME_SPEC"`
test -z "$DLGUESSSOFILE" && DLGUESSSOFILE="$DLGUESSFILE"
if test "$cross_compiling" = yes; then
AC_DEFINE_UNQUOTED($1, "$DLGUESSSOFILE", [$2 dynamic library file])
AC_MSG_RESULT([$DLGUESSSOFILE (guess while cross-compiling)])
else
DLFOUNDFILE=""
if test "$sys_lib_dlsearch_path_spec" ; then
for direc in $sys_lib_dlsearch_path_spec ; do
DLTRYFILE="$direc/$DLGUESSFILE"
changequote(<<, >>) <<
DLFOUNDFILE=`${PERL:-perl} -e 'use File::Basename; (basename(readlink($ARGV[0])) =~ /^(.*[^\d]\.\d+)[\d\.]*$/ && print ${1}) || exit 1;' "$DLTRYFILE" 2>&5`
>>
changequote([, ]) if test "$?" -eq "0"; then
break
fi
done
fi
if test -z "$DLFOUNDFILE" ; then
DLFOUNDFILE="$DLGUESSSOFILE"
fi
AC_DEFINE_UNQUOTED($1, "$DLFOUNDFILE", [$2 dynamic library file])
AC_MSG_RESULT($DLFOUNDFILE)
fi
])
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
fi
])
AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
if test "x$cross_compiling" != xyes; then
AC_MSG_CHECKING([run-time libs availability])
AC_TRY_RUN([
main()
{
return 0;
}
],
AC_MSG_RESULT([fine]),
AC_MSG_RESULT([failed])
AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
)
fi
])
AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
[curl_cv_variadic_macros_c99], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
int fun3(int arg1, int arg2, int arg3);
int fun2(int arg1, int arg2);
int fun3(int arg1, int arg2, int arg3)
{ return arg1 + arg2 + arg3; }
int fun2(int arg1, int arg2)
{ return arg1 + arg2; }
],[
int res3 = c99_vmacro3(1, 2, 3);
int res2 = c99_vmacro2(1, 2);
])
],[
curl_cv_variadic_macros_c99="yes"
],[
curl_cv_variadic_macros_c99="no"
])
])
case "$curl_cv_variadic_macros_c99" in
yes)
AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
[Define to 1 if compiler supports C99 variadic macro style.])
;;
esac
AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
[curl_cv_variadic_macros_gcc], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
int fun3(int arg1, int arg2, int arg3);
int fun2(int arg1, int arg2);
int fun3(int arg1, int arg2, int arg3)
{ return arg1 + arg2 + arg3; }
int fun2(int arg1, int arg2)
{ return arg1 + arg2; }
],[
int res3 = gcc_vmacro3(1, 2, 3);
int res2 = gcc_vmacro2(1, 2);
])
],[
curl_cv_variadic_macros_gcc="yes"
],[
curl_cv_variadic_macros_gcc="no"
])
])
case "$curl_cv_variadic_macros_gcc" in
yes)
AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
[Define to 1 if compiler supports old gcc variadic macro style.])
;;
esac
])
AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS]) AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
if test "$ac_cv_header_windows_h" = "no"; then
ac_cv_native_windows="no"
else
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
],[
int dummy=1;
Not a native Windows build target.
])
],[
ac_cv_native_windows="yes"
],[
ac_cv_native_windows="no"
])
fi
])
case "$ac_cv_native_windows" in
yes)
AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
[Define to 1 if you are building a native Windows target.])
;;
esac
])