summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-05-05 14:34:25 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2019-05-05 23:05:02 -0400
commit52c489837f511771a00be91ecf1b15d390d2980c (patch)
tree741e4bdb7c0818e96bae88009665effbfccaeff1
parentec94594504f4eec3a91fe5a55153dedbe8535790 (diff)
downloadlighttpd-git-52c489837f511771a00be91ecf1b15d390d2980c.tar.gz
[build] detect FreeBSD elftc_copyfile()
-rw-r--r--SConstruct6
-rw-r--r--configure.ac13
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am4
-rw-r--r--src/meson.build8
-rw-r--r--src/mod_webdav.c6
6 files changed, 31 insertions, 7 deletions
diff --git a/SConstruct b/SConstruct
index 74f5358b..c286aed7 100644
--- a/SConstruct
+++ b/SConstruct
@@ -453,6 +453,12 @@ if 1:
if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'):
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ])
+ if autoconf.CheckLibWithHeader('elftc', 'libelftc.h', 'c', 'elftc_copyfile(0, 1);'):
+ autoconf.env.Append(
+ CPPFLAGS = [ '-DHAVE_ELFTC_COPYFILE' ],
+ LIBS = [ 'elftc' ],
+ )
+
if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'):
autoconf.env.Append(
CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ],
diff --git a/configure.ac b/configure.ac
index dcf6a32a..46202791 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,6 +156,19 @@ AC_SEARCH_LIBS([accept], [network])
dnl clock_gettime() needs -lrt with glibc < 2.17, and possibly other platforms
AC_SEARCH_LIBS([clock_gettime], [rt])
+dnl FreeBSD elftc_copyfile()
+save_LIBS=$LIBS
+LIBS=
+AC_SEARCH_LIBS([elftc_copyfile], [elftc], [
+ AC_CHECK_HEADERS([libelftc.h], [
+ ELFTC_LIB=$LIBS
+ AC_DEFINE([HAVE_LIBELFTC], [1], [libelftc])
+ AC_DEFINE([HAVE_ELFTC_COPYFILE], [1], [elftc_copyfile])
+ ])
+])
+LIBS=$save_LIBS
+AC_SUBST([ELFTC_LIB])
+
dnl need dlopen/-ldl to load plugins (when not on windows)
save_LIBS=$LIBS
LIBS=
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0feb851f..6026520f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -188,6 +188,7 @@ check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
if (NOT HAVE_CLOCK_GETTIME)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
endif()
+check_library_exists(elftc elftc_copyfile "libelftc.h" HAVE_ELFTC_COPYFILE)
check_c_source_compiles("
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/src/Makefile.am b/src/Makefile.am
index 1b5446cd..2dccaabb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -144,7 +144,7 @@ lib_LTLIBRARIES += mod_webdav.la
mod_webdav_la_SOURCES = mod_webdav.c
mod_webdav_la_CFLAGS = $(AM_CFLAGS) $(XML_CFLAGS) $(SQLITE_CFLAGS)
mod_webdav_la_LDFLAGS = $(common_module_ldflags)
-mod_webdav_la_LIBADD = $(common_libadd) $(XML_LIBS) $(SQLITE_LIBS) $(UUID_LIBS)
+mod_webdav_la_LIBADD = $(common_libadd) $(XML_LIBS) $(SQLITE_LIBS) $(UUID_LIBS) $(ELFTC_LIB)
if BUILD_WITH_LUA
lib_LTLIBRARIES += mod_magnet.la
@@ -477,7 +477,7 @@ lighttpd_CPPFLAGS = \
lighttpd_LDADD = \
$(common_libadd) \
$(CRYPT_LIB) $(CRYPTO_LIB) \
- $(XML_LIBS) $(SQLITE_LIBS) $(UUID_LIBS) \
+ $(XML_LIBS) $(SQLITE_LIBS) $(UUID_LIBS) $(ELFTC_LIB) \
$(PCRE_LIB) $(Z_LIB) $(BZ_LIB) $(DL_LIB) $(SENDFILE_LIB) $(ATTR_LIB) \
$(FAM_LIBS) $(LIBEV_LIBS) $(LIBUNWIND_LIBS)
lighttpd_LDFLAGS = -export-dynamic
diff --git a/src/meson.build b/src/meson.build
index ef537da9..6a2e53d3 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -161,6 +161,12 @@ if not(conf_data.get('HAVE_CLOCK_GETTIME'))
endif
endif
+libelftc = []
+if compiler.has_function('elftc_copyfile', args: defs + ['-lelftc'], prefix: '#include <libelftc.h>')
+ conf_data.set('HAVE_ELFTC_COPYFILE', true)
+ libelftc = [ compiler.find_library('elftc') ]
+endif
+
conf_data.set('HAVE_IPV6', compiler.compiles('''
#include <sys/types.h>
#include <sys/socket.h>
@@ -881,7 +887,7 @@ modules = [
[ 'mod_userdir', [ 'mod_userdir.c' ] ],
[ 'mod_usertrack', [ 'mod_usertrack.c' ] ],
[ 'mod_vhostdb', [ 'mod_vhostdb.c' ] ],
- [ 'mod_webdav', [ 'mod_webdav.c' ], libsqlite3 + libuuid + libxml2 ],
+ [ 'mod_webdav', [ 'mod_webdav.c' ], libsqlite3 + libuuid + libxml2 + libelftc ],
[ 'mod_wstunnel', [ 'mod_wstunnel.c' ], libcrypto ],
]
diff --git a/src/mod_webdav.c b/src/mod_webdav.c
index 60288d4e..619f4513 100644
--- a/src/mod_webdav.c
+++ b/src/mod_webdav.c
@@ -2015,7 +2015,7 @@ webdav_prop_select_propnames (const plugin_config * const pconf,
#if defined(__APPLE__) && defined(__MACH__)
#include <copyfile.h> /* fcopyfile() *//* OS X 10.5+ */
#endif
-#ifdef __FreeBSD__
+#ifdef HAVE_ELFTC_COPYFILE/* __FreeBSD__ */
#include <libelftc.h> /* elftc_copyfile() */
#endif
#ifdef __linux__
@@ -2053,15 +2053,13 @@ webdav_fcopyfile_sz (int ifd, int ofd, off_t isz)
if (0 != lseek(ofd, 0, SEEK_SET)) return -1;
#endif
- #if 0
- #ifdef __FreeBSD__
+ #ifdef HAVE_ELFTC_COPYFILE /* __FreeBSD__ */
if (0 == elftc_copyfile(ifd, ofd))
return 0;
if (0 != lseek(ifd, 0, SEEK_SET)) return -1;
if (0 != lseek(ofd, 0, SEEK_SET)) return -1;
#endif
- #endif
#ifdef __linux__ /* Linux 2.6.33+ sendfile() supports file-to-file copy */
off_t offset = 0;