AC_DEFUN([ACX_ESCAPE_BACKSLASH], [$2="`echo $1 | sed -e 's/\\\\/\\\\\\\\/g'`"
])
AC_DEFUN([ACX_RSRC_VERSION],
[$1=[`echo $PACKAGE_VERSION | sed -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\).*$/\1,\2,\3,\4/' -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9]*$/\1,\2,\3,0/' `]
])
AC_DEFUN([ACX_CHECK_COMPILER_FLAG],
[
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether $CC supports -$1)
cache=`echo $1 | sed 'y%.=/+-%___p_%'`
AC_CACHE_VAL(cv_prog_cc_flag_$cache,
[
echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -$1 -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
eval "cv_prog_cc_flag_$cache=no"
fi
rm -f conftest conftest.o conftest.c
])
if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then
AC_MSG_RESULT(yes)
:
$2
else
AC_MSG_RESULT(no)
:
$3
fi
])
AC_DEFUN([ACX_CHECK_ERROR_FLAGS],
[
ACX_CHECK_COMPILER_FLAG(Werror, [ERRFLAG="-Werror"], [ERRFLAG="-errwarn"])
ACX_CHECK_COMPILER_FLAG(Wall, [ERRFLAG="$ERRFLAG -Wall"],
[ERRFLAG="$ERRFLAG -errfmt"])
])
AC_DEFUN([ACX_CHECK_COMPILER_FLAG_NEEDED],
[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([ACX_CHECK_ERROR_FLAGS])
AC_MSG_CHECKING(whether we need $1 as a flag for $CC)
cache=AS_TR_SH($1)
AC_CACHE_VAL(cv_prog_cc_flag_needed_$cache,
[
echo '$2' > conftest.c
echo 'void f(){}' >>conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_needed_$cache=no"
else
[
if test -z "`$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_needed_$cache=yes"
else
eval "cv_prog_cc_flag_needed_$cache=fail"
fi
]
fi
rm -f conftest conftest.c conftest.o
])
if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then
AC_MSG_RESULT(yes)
:
$3
else
if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then
AC_MSG_RESULT(no)
:
$4
else
AC_MSG_RESULT(failed)
:
$5
fi
fi
])
AC_DEFUN([ACX_DEPFLAG],
[
AC_MSG_CHECKING([$CC dependency flag])
echo 'void f(){}' >conftest.c
if test "`$CC -MM conftest.c 2>&1`" = "conftest.o: conftest.c"; then
DEPFLAG="-MM"
else
if test "`$CC -xM1 conftest.c 2>&1`" = "conftest.o: conftest.c"; then
DEPFLAG="-xM1"
else
DEPFLAG="-MM" fi
fi
AC_MSG_RESULT($DEPFLAG)
rm -f conftest.c
AC_SUBST(DEPFLAG)
])
AC_DEFUN([ACX_DETERMINE_EXT_FLAGS_UNBOUND],
[
ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE,
[
int test() {
int a;
char **opts = NULL;
struct timeval tv;
char *t;
time_t time = 0;
char *buf = NULL;
const char* str = NULL;
struct msghdr msg;
msg.msg_control = 0;
t = ctime_r(&time, buf);
tv.tv_usec = 10;
srandom(32);
a = getopt(2, opts, "a");
a = isascii(32);
str = gai_strerror(0);
if(str && t && tv.tv_usec && msg.msg_control)
a = 0;
return a;
}
], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE"])
ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE,
[
int test() {
int a;
char **opts = NULL;
struct timeval tv;
char *t;
time_t time = 0;
char *buf = NULL;
const char* str = NULL;
struct msghdr msg;
msg.msg_control = 0;
t = ctime_r(&time, buf);
tv.tv_usec = 10;
srandom(32);
a = getopt(2, opts, "a");
a = isascii(32);
str = gai_strerror(0);
if(str && t && tv.tv_usec && msg.msg_control)
a = 0;
return a;
}
], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE"])
ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG,
[
int test() {
int a = 0;
return a;
}
], [CFLAGS="$CFLAGS $C99FLAG"])
ACX_CHECK_COMPILER_FLAG_NEEDED(-D_BSD_SOURCE,
[
int test() {
int a;
a = isascii(32);
return a;
}
], [CFLAGS="$CFLAGS -D_BSD_SOURCE"])
ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE,
[
int test() {
struct in6_pktinfo inf;
int a = (int)sizeof(inf);
return a;
}
], [CFLAGS="$CFLAGS -D_GNU_SOURCE"])
ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE -D_FRSRESGID,
[
int test() {
int a = setresgid(0,0,0);
a = setresuid(0,0,0);
return a;
}
], [CFLAGS="$CFLAGS -D_GNU_SOURCE"])
ACX_CHECK_COMPILER_FLAG_NEEDED(-D_POSIX_C_SOURCE=200112,
[
int test() {
int a = 0;
char *t;
time_t time = 0;
char *buf = NULL;
const char* str = NULL;
t = ctime_r(&time, buf);
str = gai_strerror(0);
if(t && str)
a = 0;
return a;
}
], [CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112"])
ACX_CHECK_COMPILER_FLAG_NEEDED(-D__EXTENSIONS__,
[
int test() {
int a;
char **opts = NULL;
struct timeval tv;
tv.tv_usec = 10;
srandom(32);
a = getopt(2, opts, "a");
a = isascii(32);
if(tv.tv_usec)
a = 0;
return a;
}
], [CFLAGS="$CFLAGS -D__EXTENSIONS__"])
])
AC_DEFUN([ACX_CHECK_FLTO], [
AC_ARG_ENABLE([flto], AS_HELP_STRING([--disable-flto], [Disable link-time optimization (gcc specific option)]))
AS_IF([test "x$enable_flto" != "xno"], [
AC_MSG_CHECKING([if $CC supports -flto])
BAKCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -flto"
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [
if $CC $CFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then
CFLAGS="$BAKCFLAGS"
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
fi
rm -f conftest conftest.c conftest.o
], [CFLAGS="$BAKCFLAGS" ; AC_MSG_RESULT(no)])
])
])
AC_DEFUN([ACX_CHECK_FORMAT_ATTRIBUTE],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "format" attribute)
AC_CACHE_VAL(ac_cv_c_format_attribute,
[ac_cv_c_format_attribute=no
AC_TRY_COMPILE(
[void f (char *format, ...) __attribute__ ((format (printf, 1, 2)));
void (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2)));
], [
f ("%s", "str");
],
[ac_cv_c_format_attribute="yes"],
[ac_cv_c_format_attribute="no"])
])
AC_MSG_RESULT($ac_cv_c_format_attribute)
if test $ac_cv_c_format_attribute = yes; then
AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute])
fi
])
AC_DEFUN([AHX_CONFIG_FORMAT_ATTRIBUTE],
[
__attribute__ ((format (archetype, string_index, first_to_check)))
])
AC_DEFUN([ACX_CHECK_UNUSED_ATTRIBUTE],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "unused" attribute)
AC_CACHE_VAL(ac_cv_c_unused_attribute,
[ac_cv_c_unused_attribute=no
AC_TRY_COMPILE(
[void f (char *u __attribute__((unused)));
], [
f ("x");
],
[ac_cv_c_unused_attribute="yes"],
[ac_cv_c_unused_attribute="no"])
])
AC_DEFUN([AHX_CONFIG_UNUSED_ATTRIBUTE],
[
])
AC_MSG_RESULT($ac_cv_c_unused_attribute)
if test $ac_cv_c_unused_attribute = yes; then
AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute])
fi
])
AC_DEFUN([ACX_LIBTOOL_C_PRE], [
AC_DEFUN([AC_PROG_F77], [:])
AC_DEFUN([AC_PROG_FC], [:])
AC_DEFUN([AC_PROG_CXX], [:])
AC_DEFUN([AC_PROG_CXXCPP], [:])
AC_DEFUN([AC_PROG_OBJC], [:])
AC_DEFUN([AC_PROG_OBJCCPP], [:])
AC_DEFUN([AC_LIBTOOL_CXX], [:])
AC_DEFUN([AC_LIBTOOL_F77], [:])
if test -z "$libtool"; then
libtool="./libtool"
fi
AC_SUBST(libtool)
AC_CANONICAL_HOST
if echo "$host_os" | grep "sunos4" >/dev/null; then
lt_cv_sys_max_cmd_len=32750;
fi
AC_PATH_TOOL(AR, ar, [false])
if test $AR = false; then
AC_MSG_ERROR([Cannot find 'ar', please extend PATH to include it])
fi
])
AC_DEFUN([ACX_LIBTOOL_C_ONLY], [
AC_REQUIRE([ACX_LIBTOOL_C_PRE])
AC_PROG_LIBTOOL
])
AC_DEFUN([ACX_TYPE_U_CHAR],
[AC_CHECK_TYPE([u_char], ,
[AC_DEFINE([u_char], [unsigned char], [Define to 'unsigned char if not defined])], [
AC_INCLUDES_DEFAULT
]) ])
AC_DEFUN([ACX_TYPE_RLIM_T],
[AC_CHECK_TYPE(rlim_t, ,
[AC_DEFINE([rlim_t], [unsigned long], [Define to 'int' if not defined])], [
AC_INCLUDES_DEFAULT
]) ])
AC_DEFUN([ACX_TYPE_SOCKLEN_T],
[
AC_CHECK_TYPE(socklen_t, ,
[AC_DEFINE([socklen_t], [int], [Define to 'int' if not defined])], [
AC_INCLUDES_DEFAULT
]) ])
AC_DEFUN([ACX_TYPE_IN_ADDR_T],
[ AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
AC_INCLUDES_DEFAULT
]) ])
AC_DEFUN([ACX_TYPE_IN_PORT_T],
[ AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
AC_INCLUDES_DEFAULT
]) ])
AC_DEFUN([ACX_ARG_RPATH],
[
AC_ARG_ENABLE(rpath,
[ --disable-rpath disable hardcoded rpath (default=enabled)],
enable_rpath=$enableval, enable_rpath=yes)
if test "x$enable_rpath" = xno; then
AC_CONFIG_COMMANDS([disable-rpath], [
sed < libtool > libtool-2 \
's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/'
mv libtool-2 libtool
chmod 755 libtool
libtool="./libtool"
])
fi
])
AC_DEFUN([ACX_RUNTIME_PATH_ADD], [
if test "x$enable_rpath" = xyes; then
if echo "$1" | grep "^/" >/dev/null; then
RUNTIME_PATH="$RUNTIME_PATH -R$1"
fi
fi
])
AC_DEFUN([ACX_SSL_CHECKS], [
withval=$1
if test x_$withval != x_no; then
AC_MSG_CHECKING(for SSL)
if test x_$withval = x_ -o x_$withval = x_yes; then
withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr"
fi
for dir in $withval; do
ssldir="$dir"
if test -f "$dir/include/openssl/ssl.h"; then
found_ssl="yes"
AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.])
dnl assume /usr/include is already in the include-path.
if test "$ssldir" != "/usr"; then
CPPFLAGS="$CPPFLAGS -I$ssldir/include"
LIBSSL_CPPFLAGS="$LIBSSL_CPPFLAGS -I$ssldir/include"
fi
break;
fi
done
if test x_$found_ssl != x_yes; then
AC_MSG_ERROR(Cannot find the SSL libraries in $withval)
else
AC_MSG_RESULT(found in $ssldir)
HAVE_SSL=yes
dnl assume /usr is already in the lib and dynlib paths.
if test "$ssldir" != "/usr" -a "$ssldir" != ""; then
LDFLAGS="$LDFLAGS -L$ssldir/lib"
LIBSSL_LDFLAGS="$LIBSSL_LDFLAGS -L$ssldir/lib"
ACX_RUNTIME_PATH_ADD([$ssldir/lib])
fi
AC_MSG_CHECKING([for HMAC_CTX_init in -lcrypto])
LIBS="$LIBS -lcrypto"
LIBSSL_LIBS="$LIBSSL_LIBS -lcrypto"
AC_TRY_LINK(, [
int HMAC_CTX_init(void);
(void)HMAC_CTX_init();
], [
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
[If you have HMAC_CTX_init])
], [
AC_MSG_RESULT(no)
# check if -lwsock32 or -lgdi32 are needed.
BAKLIBS="$LIBS"
BAKSSLLIBS="$LIBSSL_LIBS"
LIBS="$LIBS -lgdi32"
LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32"
AC_MSG_CHECKING([if -lcrypto needs -lgdi32])
AC_TRY_LINK([], [
int HMAC_CTX_init(void);
(void)HMAC_CTX_init();
],[
AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
[If you have HMAC_CTX_init])
AC_MSG_RESULT(yes)
],[
AC_MSG_RESULT(no)
LIBS="$BAKLIBS"
LIBSSL_LIBS="$BAKSSLLIBS"
LIBS="$LIBS -ldl"
LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
AC_MSG_CHECKING([if -lcrypto needs -ldl])
AC_TRY_LINK([], [
int HMAC_CTX_init(void);
(void)HMAC_CTX_init();
],[
AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
[If you have HMAC_CTX_init])
AC_MSG_RESULT(yes)
],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required])
])
])
])
fi
AC_SUBST(HAVE_SSL)
AC_SUBST(RUNTIME_PATH)
# openssl engine functionality needs dlopen().
BAKLIBS="$LIBS"
AC_SEARCH_LIBS([dlopen], [dl])
if test "$LIBS" != "$BAKLIBS"; then
LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
fi
fi
AC_CHECK_HEADERS([openssl/ssl.h],,, [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS([openssl/err.h],,, [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS([openssl/rand.h],,, [AC_INCLUDES_DEFAULT])
])dnl End of ACX_SSL_CHECKS
dnl Check for SSL, where SSL is mandatory
dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
dnl Checks main header files of SSL.
dnl
AC_DEFUN([ACX_WITH_SSL],
[
AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
[enable SSL (will check /usr/local/ssl
/usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[
],[
withval="yes"
])
if test x_$withval = x_no; then
AC_MSG_ERROR([Need SSL library to do digital signature cryptography])
fi
ACX_SSL_CHECKS($withval)
])dnl End of ACX_WITH_SSL
dnl Check for SSL, where ssl is optional (--without-ssl is allowed)
dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
dnl Checks main header files of SSL.
dnl
AC_DEFUN([ACX_WITH_SSL_OPTIONAL],
[
AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
[enable SSL (will check /usr/local/ssl
/usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[
],[
withval="yes"
])
ACX_SSL_CHECKS($withval)
])dnl End of ACX_WITH_SSL_OPTIONAL
dnl Setup to use -lssl
dnl To use -lcrypto, use the ACX_WITH_SSL setup (before this one).
AC_DEFUN([ACX_LIB_SSL],
[
# check if libssl needs libdl
BAKLIBS="$LIBS"
LIBS="-lssl $LIBS"
AC_MSG_CHECKING([if libssl needs libdl])
AC_TRY_LINK_FUNC([SSL_CTX_new], [
AC_MSG_RESULT([no])
LIBS="$BAKLIBS"
] , [
AC_MSG_RESULT([yes])
LIBS="$BAKLIBS"
AC_SEARCH_LIBS([dlopen], [dl])
]) ])dnl End of ACX_LIB_SSL
dnl Setup to use very large files (>2Gb).
dnl setups fseeko and its own
AC_DEFUN([ACX_SYS_LARGEFILE],
[
AC_SYS_LARGEFILE
dnl try to see if an additional _LARGEFILE_SOURCE 1 is needed to get fseeko
ACX_CHECK_COMPILER_FLAG_NEEDED(-D_LARGEFILE_SOURCE=1,
[
#include <stdio.h>
int test() {
int a = fseeko(stdin, 0, 0);
return a;
}
], [CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE=1"])
])
dnl Check getaddrinfo.
dnl Works on linux, solaris, bsd and windows(links winsock).
dnl defines HAVE_GETADDRINFO, USE_WINSOCK.
AC_DEFUN([ACX_CHECK_GETADDRINFO_WITH_INCLUDES],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(for getaddrinfo)
ac_cv_func_getaddrinfo=no
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#ifdef __cplusplus
extern "C"
{
#endif
char* getaddrinfo();
char* (*f) () = getaddrinfo;
#ifdef __cplusplus
}
#endif
int main() {
;
return 0;
}
]])],
dnl this case on linux, solaris, bsd
[ac_cv_func_getaddrinfo="yes"
dnl see if on windows
if test "$ac_cv_header_windows_h" = "yes"; then
AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
USE_WINSOCK="1"
LIBS="$LIBS -lws2_32"
fi
],
dnl no quick getaddrinfo, try mingw32 and winsock2 library.
ORIGLIBS="$LIBS"
LIBS="$LIBS -lws2_32"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
],
[
(void)getaddrinfo(NULL, NULL, NULL, NULL);
]
)],
[
ac_cv_func_getaddrinfo="yes"
dnl already: LIBS="$LIBS -lws2_32"
AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
USE_WINSOCK="1"
],
[
ac_cv_func_getaddrinfo="no"
LIBS="$ORIGLIBS"
])
)
AC_MSG_RESULT($ac_cv_func_getaddrinfo)
if test $ac_cv_func_getaddrinfo = yes; then
AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether getaddrinfo is available])
fi
])dnl Endof AC_CHECK_GETADDRINFO_WITH_INCLUDES
dnl check if a function is deprecated. defines DEPRECATED_func in config.h.
dnl $1: function name
dnl $2: C-statement that calls the function.
dnl $3: includes for the program.
dnl $4: executes if yes
dnl $5: executes if no
AC_DEFUN([ACX_FUNC_DEPRECATED],
[
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(if $1 is deprecated)
cache=`echo $1 | sed 'y%.=/+-%___p_%'`
AC_CACHE_VAL(cv_cc_deprecated_$cache,
[
echo '$3' >conftest.c
echo 'void f(){ $2 }' >>conftest.c
if test -z "`$CC -c conftest.c 2>&1 | grep deprecated`"; then
eval "cv_cc_deprecated_$cache=no"
else
eval "cv_cc_deprecated_$cache=yes"
fi
rm -f conftest conftest.o conftest.c
])
if eval "test \"`echo '$cv_cc_deprecated_'$cache`\" = yes"; then
AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED(AS_TR_CPP([DEPRECATED_$1]), 1, [Whether $1 is deprecated])
:
$4
else
AC_MSG_RESULT(no)
:
$5
fi
])
AC_DEFUN([ACX_CHECK_NONBLOCKING_BROKEN],
[
AC_MSG_CHECKING([if nonblocking sockets work])
if echo $target | grep mingw32 >/dev/null; then
AC_MSG_RESULT([no (windows)])
AC_DEFINE([NONBLOCKING_IS_BROKEN], 1, [Define if the network stack does not fully support nonblocking io (causes lower performance).])
else
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
int main(void)
{
int port;
int sfd, cfd;
int num = 10;
int i, p;
struct sockaddr_in a;
/* test if select and nonblocking reads work well together */
/* open port.
fork child to send 10 messages.
select to read.
then try to nonblocking read the 10 messages
then, nonblocking read must give EAGAIN
*/
port = 12345 + (time(0)%32);
sfd = socket(PF_INET, SOCK_DGRAM, 0);
if(sfd == -1) {
perror("socket");
return 1;
}
memset(&a, 0, sizeof(a));
a.sin_family = AF_INET;
a.sin_port = htons(port);
a.sin_addr.s_addr = inet_addr("127.0.0.1");
if(bind(sfd, (struct sockaddr*)&a, sizeof(a)) < 0) {
perror("bind");
return 1;
}
if(fcntl(sfd, F_SETFL, O_NONBLOCK) == -1) {
perror("fcntl");
return 1;
}
cfd = socket(PF_INET, SOCK_DGRAM, 0);
if(cfd == -1) {
perror("client socket");
return 1;
}
a.sin_port = 0;
if(bind(cfd, (struct sockaddr*)&a, sizeof(a)) < 0) {
perror("client bind");
return 1;
}
a.sin_port = htons(port);
/* no handler, causes exit in 10 seconds */
alarm(10);
/* send and receive on the socket */
if((p=fork()) == 0) {
for(i=0; i<num; i++) {
if(sendto(cfd, &i, sizeof(i), 0,
(struct sockaddr*)&a, sizeof(a)) < 0) {
perror("sendto");
return 1;
}
}
} else {
/* parent */
fd_set rset;
int x;
if(p == -1) {
perror("fork");
return 1;
}
FD_ZERO(&rset);
FD_SET(sfd, &rset);
if(select(sfd+1, &rset, NULL, NULL, NULL) < 1) {
perror("select");
return 1;
}
i = 0;
while(i < num) {
if(recv(sfd, &x, sizeof(x), 0) != sizeof(x)) {
if(errno == EAGAIN)
continue;
perror("recv");
return 1;
}
i++;
}
/* now we want to get EAGAIN: nonblocking goodness */
errno = 0;
recv(sfd, &x, sizeof(x), 0);
if(errno != EAGAIN) {
perror("trying to recv again");
return 1;
}
/* EAGAIN encountered */
}
close(sfd);
close(cfd);
return 0;
}
]])], [
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
AC_DEFINE([NONBLOCKING_IS_BROKEN], 1, [Define if the network stack does not fully support nonblocking io (causes lower performance).])
], [
AC_MSG_RESULT([crosscompile(yes)])
])
fi
])
AC_DEFUN([ACX_MKDIR_ONE_ARG],
[
AC_MSG_CHECKING([whether mkdir has one arg])
AC_TRY_COMPILE([
], [
(void)mkdir("directory");
],
AC_MSG_RESULT(yes)
AC_DEFINE(MKDIR_HAS_ONE_ARG, 1, [Define if mkdir has one argument.])
,
AC_MSG_RESULT(no)
)
])
AC_DEFUN([ACX_FUNC_IOCTLSOCKET],
[
AC_MSG_CHECKING(for ioctlsocket)
AC_LINK_IFELSE([AC_LANG_PROGRAM([
], [
(void)ioctlsocket(0, 0, NULL);
])], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_IOCTLSOCKET, 1, [if the function 'ioctlsocket' is available])
],[AC_MSG_RESULT(no)])
])
AC_DEFUN([ACX_FUNC_MALLOC],
[
AC_MSG_CHECKING([for GNU libc compatible malloc])
AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[char *malloc ();
]], [ if(malloc(0) != 0) return 1;])
],
[AC_MSG_RESULT([no])
AC_LIBOBJ(malloc)
AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] ,
[AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_MALLOC], 1, [If have GNU libc compatible malloc])],
[AC_MSG_RESULT([no (crosscompile)])
AC_LIBOBJ(malloc)
AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] )
])
AC_DEFUN([AHX_CONFIG_FSEEKO],
[
])
AC_DEFUN([AHX_CONFIG_RAND_MAX],
[
])
AC_DEFUN([AHX_CONFIG_MAXHOSTNAMELEN],
[
])
AC_DEFUN([AHX_CONFIG_IPV6_MIN_MTU],
[
])
AC_DEFUN([AHX_CONFIG_SNPRINTF],
[
int snprintf (char *str, size_t count, const char *fmt, ...);
int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
])
AC_DEFUN([AHX_CONFIG_INET_PTON],
[
int inet_pton(int af, const char* src, void* dst);
])
AC_DEFUN([AHX_CONFIG_INET_NTOP],
[
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
])
AC_DEFUN([AHX_CONFIG_INET_ATON],
[
int inet_aton(const char *cp, struct in_addr *addr);
])
AC_DEFUN([AHX_CONFIG_MEMMOVE],
[
void *memmove(void *dest, const void *src, size_t n);
])
AC_DEFUN([AHX_CONFIG_STRLCAT],
[
size_t strlcat(char *dst, const char *src, size_t siz);
])
AC_DEFUN([AHX_CONFIG_STRLCPY],
[
size_t strlcpy(char *dst, const char *src, size_t siz);
])
AC_DEFUN([AHX_CONFIG_GMTIME_R],
[
struct tm *gmtime_r(const time_t *timep, struct tm *result);
])
AC_DEFUN([AHX_CONFIG_W32_SLEEP],
[
])
AC_DEFUN([AHX_CONFIG_W32_USLEEP],
[
])
AC_DEFUN([AHX_CONFIG_W32_RANDOM],
[
])
AC_DEFUN([AHX_CONFIG_W32_SRANDOM],
[
])
AC_DEFUN([AHX_CONFIG_W32_FD_SET_T],
[
/* detect if we need to cast to unsigned int for FD_SET to avoid warnings */
])
AC_DEFUN([ACX_CFLAGS_STRIP],
[
if echo $CFLAGS | grep " $1" >/dev/null 2>&1; then
CFLAGS="`echo $CFLAGS | sed -e 's/ $1//g'`"
AC_DEFINE(m4_bpatsubst(OMITTED_$1,[[-=]],_), 1, Put $1 define in config.h)
fi
])
AC_DEFUN([ACX_STRIP_EXT_FLAGS],
[
AC_MSG_NOTICE([Stripping extension flags...])
ACX_CFLAGS_STRIP(-D_GNU_SOURCE)
ACX_CFLAGS_STRIP(-D_BSD_SOURCE)
ACX_CFLAGS_STRIP(-D__EXTENSIONS__)
ACX_CFLAGS_STRIP(-D_POSIX_C_SOURCE=200112)
ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE=600)
ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE_EXTENDED=1)
ACX_CFLAGS_STRIP(-D_ALL_SOURCE)
ACX_CFLAGS_STRIP(-D_LARGEFILE_SOURCE=1)
])
AC_DEFUN([AHX_CONFIG_FLAG_OMITTED],
[[
AC_DEFUN([AHX_CONFIG_FLAG_EXT],
[AHX_CONFIG_FLAG_OMITTED(m4_bpatsubst(OMITTED_$1,[[-=]],_),m4_bpatsubst(m4_bpatsubst($1,-D,),=.*$,),m4_if(m4_bregexp($1,=),-1,1,m4_bpatsubst($1,^.*=,)))
])
AC_DEFUN([AHX_CONFIG_EXT_FLAGS],
[AHX_CONFIG_FLAG_EXT(-D_GNU_SOURCE)
AHX_CONFIG_FLAG_EXT(-D_BSD_SOURCE)
AHX_CONFIG_FLAG_EXT(-D__EXTENSIONS__)
AHX_CONFIG_FLAG_EXT(-D_POSIX_C_SOURCE=200112)
AHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE=600)
AHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE_EXTENDED=1)
AHX_CONFIG_FLAG_EXT(-D_ALL_SOURCE)
AHX_CONFIG_FLAG_EXT(-D_LARGEFILE_SOURCE=1)
])
AC_DEFUN([ACX_CHECK_MEMCMP_SIGNED],
[AC_MSG_CHECKING([if memcmp compares unsigned])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
int main(void)
{
char a = 255, b = 0;
if(memcmp(&a, &b, 1) < 0)
return 1;
return 0;
}
]])], [AC_MSG_RESULT([yes]) ],
[ AC_MSG_RESULT([no])
AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes])
AC_LIBOBJ([memcmp])
], [ AC_MSG_RESULT([cross-compile no])
AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes])
AC_LIBOBJ([memcmp])
]) ])
AC_DEFUN([AHX_MEMCMP_BROKEN], [
int memcmp(const void *x, const void *y, size_t n);
])
AC_DEFUN([ACX_CHECK_SS_FAMILY],
[AC_CHECK_MEMBER([struct sockaddr_storage.ss_family], [], [
AC_CHECK_MEMBER([struct sockaddr_storage.__ss_family], [
AC_DEFINE([ss_family], [__ss_family], [Fallback member name for socket family in struct sockaddr_storage])
],, [AC_INCLUDES_DEFAULT
])
], [AC_INCLUDES_DEFAULT
]) ])