X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=configure.in;h=c912e34f7b50623c134040332d99a29d983c898e;hb=9e83a47a9d9bd9a8020a80393e1f0e03bb34efe7;hp=cddb6a18c41478bf6819a2249b8d40a072c567f9;hpb=6eaf93053f43aa6d456475e56e7b50d4b13c6d2d;p=betaftpd diff --git a/configure.in b/configure.in index cddb6a1..c912e34 100644 --- a/configure.in +++ b/configure.in @@ -168,6 +168,7 @@ fi if test "$result" = "no"; then AC_CHECK_HEADER(linux/socket.h) + AC_CHECK_HEADER(linux/tcp.h) fi AC_CHECK_HEADERS(sys/poll.h) @@ -194,6 +195,9 @@ dnl dnl sendfile() is not standard -- we'll have to check the different dnl versions one by one :-) dnl +dnl Unfortunately, we'll have to run the program too -- this is a +dnl problem with newer libc's and not-so-new kernels :-) +dnl AC_CHECK_HEADERS(sys/sendfile.h,result=yes,result=no) if test "$result" = "yes"; then @@ -219,9 +223,14 @@ if test "$result" = "yes"; then #include #endif +#if HAVE_ERRNO_H +#include +#endif + #if HAVE_SYS_UIO_H #include -#endif],[ +#endif +],[ int out_fd = 1, in_fd = 0; off_t offset = 0; size_t size = 1024; @@ -231,7 +240,71 @@ if test "$result" = "yes"; then AC_MSG_RESULT($enableval) if test "$enableval" = "yes"; then - AC_DEFINE(HAVE_LINUX_SENDFILE, 1, [Define if you have sendfile() with the Linux semantics.]) + dnl + dnl If the compile fails now, we assume sendfile() exists (since this + dnl is by far the most common case) + dnl + AC_MSG_CHECKING([that sendfile() really is implemented]) + + AC_TRY_RUN([ +#if HAVE_SYS_SOCKET_H +#include +#endif + +#if HAVE_SYS_LIMITS_H +#include +#endif + +#if HAVE_UNISTD_H +#include +#endif + +#if HAVE_SYS_SENDFILE_H +#include +#endif + +#if HAVE_SYS_TYPES_H +#include +#endif + +#if HAVE_ERRNO_H +#include +#endif + +#if HAVE_SYS_UIO_H +#include +#endif + +int main() { + int out_fd = 1, in_fd = 0; + off_t offset = 0; + size_t size = 1024; + + errno = 0; + sendfile(out_fd, in_fd, &offset, size); + if (errno == ENOSYS) + return 0; + else + return 1; +}], + enableval=no,enableval=yes,[enableval="cross-compiling, not checked"]) + AC_MSG_RESULT($enableval) + + has_sendfile=$enableval + + dnl + dnl Force sendfile() `state' if the user tells us to + dnl + AC_ARG_WITH(linux-sendfile,[ --with-linux-sendfile Force sendfile() support],has_sendfile=$withval) + + if test $has_sendfile != "no"; then + AC_DEFINE(HAVE_LINUX_SENDFILE, 1, [Define if you have sendfile() with the Linux semantics.]) + has_sendfile=enabled + else + has_sendfile=disabled + fi + AC_MSG_CHECKING([final status of Linux sendfile() support]) + AC_MSG_RESULT($has_sendfile) fi fi