+ 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 <sys/socket.h>
+#endif
+
+#if HAVE_SYS_LIMITS_H
+#include <sys/limits.h>
+#endif
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_SYS_SENDFILE_H
+#include <sys/sendfile.h>
+#endif
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#if HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#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)