* [gentoo-commits] proj/portage-utils:master commit in: autotools/m4/, /
@ 2021-12-13 8:39 Fabian Groffen
0 siblings, 0 replies; only message in thread
From: Fabian Groffen @ 2021-12-13 8:39 UTC (permalink / raw
To: gentoo-commits
commit: c955d333bbffd02cb6f439489865ac3c37c9ff3b
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 13 07:15:01 2021 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Dec 13 07:15:01 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c955d333
configure: add check for existence of sendfile()
This is based on https://gist.github.com/bmanojlovic/6529848, but
adapted to make the Solaris case a little bit less of a guess.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
autotools/m4/ac_check_sendfile.m4 | 63 +++++++++++++++++++++++++++++++++++++++
configure.ac | 2 ++
2 files changed, 65 insertions(+)
diff --git a/autotools/m4/ac_check_sendfile.m4 b/autotools/m4/ac_check_sendfile.m4
new file mode 100644
index 0000000..5ec428d
--- /dev/null
+++ b/autotools/m4/ac_check_sendfile.m4
@@ -0,0 +1,63 @@
+AC_DEFUN([AC_CHECK_SENDFILE],[
+
+saved_LIBS="$LIBS"
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
+
+dnl platforms like Solaris need libsendfile, first check if it's there
+AC_CHECK_LIB(sendfile, sendfile,
+ [
+ LIBS="-lsendfile $LIBS"
+ SENDFILE_LIBS="-lsendfile"
+ AC_SUBST(SENDFILE_LIBS)
+ ], [])
+
+ac_sendfile_supported=no
+AC_MSG_CHECKING([whether sendfile() is supported and what prototype it has])
+
+dnl Linux/Solaris
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/sendfile.h>
+ #include <stdio.h>]],
+ [[sendfile(1, 1, NULL, 0);]])],
+ [
+ AC_DEFINE(HAVE_SENDFILE4_SUPPORT, 1,
+ [Define this if Linux/Solaris sendfile() is supported])
+ AC_MSG_RESULT([Linux/Solaris sendfile()])
+ ac_sendfile_supported=yes
+ ], [])
+
+dnl FreeBSD-like
+if test x$ac_sendfile_supported = xno; then
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>
+ #include <stdio.h>]],
+ [[sendfile(1, 1, 0, 0, NULL, NULL, 0);]])],
+ [
+ AC_DEFINE(HAVE_SENDFILE7_SUPPORT, 1,
+ [Define this if FreeBSD sendfile() is supported])
+ AC_MSG_RESULT([FreeBSD sendfile()])
+ ac_sendfile_supported=yes
+ ], [])
+fi
+
+dnl macOS-like
+if test x$ac_sendfile_supported = xno; then
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>
+ #include <stdio.h>
+ #include <sys/uio.h>]],
+ [[sendfile(1, 1, 0, NULL, NULL, 0);]])],
+ [
+ AC_DEFINE(HAVE_SENDFILE6_SUPPORT, 1,
+ [Define this if MacOS sendfile() is supported])
+ AC_MSG_RESULT([MacOS sendfile()])
+ ac_sendfile_supported=yes
+ ], [])
+fi
+
+if test x$ac_sendfile_supported = xno; then
+ AC_MSG_RESULT([no sendfile() support, using read/send])
+fi
+
+CFLAGS="$saved_CFLAGS"
+LIBS="$saved_LIBS"
+
+])
diff --git a/configure.ac b/configure.ac
index 989a34f..bdef732 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,8 @@ AC_CHECK_FUNCS_ONCE(m4_flatten([
scandirat
]))
+AC_CHECK_SENDFILE
+
AC_ARG_WITH([eprefix], [AS_HELP_STRING([--with-eprefix], [path for Gentoo/Prefix project])])
# ensure eprefix ends with a slash, since the code base expects that
case "$with_eprefix" in
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-13 8:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-13 8:39 [gentoo-commits] proj/portage-utils:master commit in: autotools/m4/, / Fabian Groffen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox