Browse Source

[build] detect FreeBSD elftc_copyfile()

personal/stbuehler/ci-build
Glenn Strauss 3 years ago
parent
commit
52c489837f
  1. 6
      SConstruct
  2. 13
      configure.ac
  3. 1
      src/CMakeLists.txt
  4. 4
      src/Makefile.am
  5. 8
      src/meson.build
  6. 6
      src/mod_webdav.c

6
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' ],

13
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=

1
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>

4
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

8
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 ],
]

6
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;

Loading…
Cancel
Save