2014-12-04 12:26:46 +00:00
AC_INIT([btrfs-progs],
2018-04-30 14:37:07 +00:00
m4_flatten(m4_include([VERSION])),
2014-12-04 12:26:46 +00:00
[linux-btrfs@vger.kernel.org],,
2023-03-16 21:38:21 +00:00
[https://btrfs.readthedocs.io])
2014-12-04 12:26:46 +00:00
2015-02-13 13:39:43 +00:00
if test "x$PACKAGE_URL" = "x"; then
2023-03-16 21:38:21 +00:00
AC_DEFINE([PACKAGE_URL], ["https://btrfs.readthedocs.io"], [URL])
2015-02-13 13:39:43 +00:00
fi
2020-10-20 13:43:45 +00:00
dnl Package version
BTRFS_VERSION_PLAIN=`cat VERSION`
BTRFS_VERSION_PLAIN="${BTRFS_VERSION_PLAIN#v*}"
BTRFS_VERSION_MAJOR=`echo "${BTRFS_VERSION_PLAIN#v*}" | awk -F. '{print $1}'`
BTRFS_VERSION_MINOR=`echo "${BTRFS_VERSION_PLAIN#v*}" | awk -F. '{print $2}'`
BTRFS_VERSION_PATCHLEVEL=`echo "${BTRFS_VERSION_PLAIN#v*}" | awk -F. '{print $3}'`
dnl libbtrfs .so version
2014-12-09 14:58:11 +00:00
LIBBTRFS_MAJOR=0
LIBBTRFS_MINOR=1
2016-12-12 16:48:19 +00:00
LIBBTRFS_PATCHLEVEL=2
2014-12-04 12:26:46 +00:00
2020-10-20 13:43:45 +00:00
dnl libbtrfsutil .so version
2020-08-20 04:36:18 +00:00
BTRFS_UTIL_VERSION_MAJOR=`sed -rn 's/^\#define BTRFS_UTIL_VERSION_MAJOR ([0-9])+$/\1/p' libbtrfsutil/btrfsutil.h`
BTRFS_UTIL_VERSION_MINOR=`sed -rn 's/^\#define BTRFS_UTIL_VERSION_MINOR ([0-9])+$/\1/p' libbtrfsutil/btrfsutil.h`
BTRFS_UTIL_VERSION_PATCH=`sed -rn 's/^\#define BTRFS_UTIL_VERSION_PATCH ([0-9])+$/\1/p' libbtrfsutil/btrfsutil.h`
2015-02-05 14:11:40 +00:00
CFLAGS=${CFLAGS:-"-g -O1 -Wall -D_FORTIFY_SOURCE=2"}
2015-02-04 18:23:38 +00:00
AC_SUBST([CFLAGS])
2014-12-10 10:56:59 +00:00
2014-12-04 12:26:46 +00:00
AC_PREREQ([2.60])
AC_CONFIG_AUX_DIR([config])
2023-05-26 19:03:19 +00:00
AC_CONFIG_MACRO_DIR([config])
2014-12-04 12:26:46 +00:00
dnl AC_USE_SYSTEM_EXTENSIONS must be called before any macros that run
dnl the compiler (like AC_PROG_LIBTOOL) to avoid autoconf errors.
AC_USE_SYSTEM_EXTENSIONS
AC_CONFIG_SRCDIR([btrfs.c])
2015-11-30 09:36:28 +00:00
AC_PREFIX_DEFAULT([/usr/local])
2014-12-04 12:26:46 +00:00
AC_PROG_CC
AC_CANONICAL_HOST
btrfs-progs: crypto: add PCL based implementation for crc32c
Copy faster implementation of crc32c from linux kernel as of 6.5-rc7
(x86_64, arch/x86/crypto/crc32c-pcl-intel-asm_64.S). This needs
assembler build support, so detect target architecture so
cross-compilation still works.
Add a special CPU flag so the old and new implementations can be
benchmarked and verified separately.
Sample benchmark:
CPU flags: 0x1ff
CPU features: SSE2 SSSE3 SSE41 SSE42 SHA AVX AVX2 CRC32C_PCL
Block size: 4096
Iterations: 1000000
Implementation: builtin
Units: CPU cycles
NULL-NOP: cycles: 77177218, cycles/i 77
NULL-MEMCPY: cycles: 226313072, cycles/i 226, 62133.395 MiB/s
CRC32C-ref: cycles: 24418596066, cycles/i 24418, 575.859 MiB/s
CRC32C-NI: cycles: 1188335920, cycles/i 1188, 11833.073 MiB/s
CRC32C-PCL: cycles: 463193456, cycles/i 463, 30358.037 MiB/s
XXHASH: cycles: 851606646, cycles/i 851, 16511.916 MiB/s
SHA256-ref: cycles: 74476234956, cycles/i 74476, 188.808 MiB/s
SHA256-NI: cycles: 34198637428, cycles/i 34198, 411.177 MiB/s
BLAKE2-ref: cycles: 14761411664, cycles/i 14761, 952.597 MiB/s
BLAKE2-SSE2: cycles: 18101896796, cycles/i 18101, 776.807 MiB/s
BLAKE2-SSE41: cycles: 12599091062, cycles/i 12599, 1116.087 MiB/s
BLAKE2-AVX2: cycles: 9668247506, cycles/i 9668, 1454.418 MiB/s
The new implementation is about 2.5x faster.
Note: there new version does not work on musl because of linkage
problems (relocations in .rodata), so it's still using the old
implementation.
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-21 21:18:13 +00:00
AC_CANONICAL_TARGET
2014-12-04 12:26:46 +00:00
AC_C_CONST
AC_C_VOLATILE
AC_C_BIGENDIAN
2023-03-01 00:32:26 +00:00
AX_CHECK_COMPILE_FLAG([-msse2], [HAVE_CFLAG_msse2=1], [HAVE_CFLAG_msse2=0])
AC_SUBST([HAVE_CFLAG_msse2])
AC_DEFINE_UNQUOTED([HAVE_CFLAG_msse2], [$HAVE_CFLAG_msse2], [Compiler supports -msse2])
AX_CHECK_COMPILE_FLAG([-msse4.1], [HAVE_CFLAG_msse41=1], [HAVE_CFLAG_msse41=0])
AC_SUBST([HAVE_CFLAG_msse41])
AC_DEFINE_UNQUOTED([HAVE_CFLAG_msse41], [$HAVE_CFLAG_msse41], [Compiler supports -msse4.1])
AX_CHECK_COMPILE_FLAG([-mavx2], [HAVE_CFLAG_mavx2=1], [HAVE_CFLAG_mavx2=0])
AC_SUBST([HAVE_CFLAG_mavx2])
AC_DEFINE_UNQUOTED([HAVE_CFLAG_mavx2], [$HAVE_CFLAG_mavx2], [Compiler supports -mavx2])
2023-02-09 13:58:08 +00:00
AX_CHECK_COMPILE_FLAG([-msha], [HAVE_CFLAG_msha=1], [HAVE_CFLAG_msha=0])
AC_SUBST([HAVE_CFLAG_msha])
AC_DEFINE_UNQUOTED([HAVE_CFLAG_msha], [$HAVE_CFLAG_msha], [Compiler supports -msha])
2023-02-15 00:51:20 +00:00
AX_CHECK_COMPILE_FLAG([-std=gnu11], [],
[AC_MSG_ERROR([std=gnu11 compiler required])])
2014-12-04 12:26:46 +00:00
AC_SYS_LARGEFILE
AC_PROG_INSTALL
2014-12-09 15:41:10 +00:00
AC_PROG_LN_S
2016-01-14 10:18:03 +00:00
AC_CHECK_TOOL([AR], [ar])
2015-01-28 17:41:17 +00:00
AC_PATH_PROG([RM], [rm], [rm])
AC_PATH_PROG([RMDIR], [rmdir], [rmdir])
2014-12-04 12:26:46 +00:00
2018-02-02 19:51:25 +00:00
2014-12-04 12:26:46 +00:00
AC_CHECK_FUNCS([openat], [],
[AC_MSG_ERROR([cannot find openat() function])])
2018-02-22 11:45:14 +00:00
AC_CHECK_FUNCS([reallocarray])
btrfs-progs: crypto: add time-based measurement to hash-speedtest
People are interested in measuring the hash performance on non-x86_64
architectures. Add option to do time-based measurements (in nanoseconds)
in case there's no support for clock-based measurements.
$ ./hash-speedtest --cycles
Block size: 4096
Iterations: 100000
Implementation: builtin
Units: cycles
NULL-NOP: cycles: 43035633, cycles/i 430
NULL-MEMCPY: cycles: 72478624, cycles/i 724
CRC32C: cycles: 181712982, cycles/i 1817
XXHASH: cycles: 136251305, cycles/i 1362
SHA256: cycles: 10758567410, cycles/i 107585
BLAKE2b: cycles: 2249704806, cycles/i 22497
$ ./hash-speedtest --time
Block size: 4096
Iterations: 100000
Implementation: builtin
Units: nsecs
NULL-NOP: nsecs: 12459033, nsecs/i 124
NULL-MEMCPY: nsecs: 20687845, nsecs/i 206
CRC32C: nsecs: 52648264, nsecs/i 526
XXHASH: nsecs: 39591766, nsecs/i 395
SHA256: nsecs: 3079668837, nsecs/i 30796
BLAKE2b: nsecs: 644766582, nsecs/i 6447
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-26 18:22:55 +00:00
AC_CHECK_FUNCS([clock_gettime])
btrfs-progs: crypto: add PCL based implementation for crc32c
Copy faster implementation of crc32c from linux kernel as of 6.5-rc7
(x86_64, arch/x86/crypto/crc32c-pcl-intel-asm_64.S). This needs
assembler build support, so detect target architecture so
cross-compilation still works.
Add a special CPU flag so the old and new implementations can be
benchmarked and verified separately.
Sample benchmark:
CPU flags: 0x1ff
CPU features: SSE2 SSSE3 SSE41 SSE42 SHA AVX AVX2 CRC32C_PCL
Block size: 4096
Iterations: 1000000
Implementation: builtin
Units: CPU cycles
NULL-NOP: cycles: 77177218, cycles/i 77
NULL-MEMCPY: cycles: 226313072, cycles/i 226, 62133.395 MiB/s
CRC32C-ref: cycles: 24418596066, cycles/i 24418, 575.859 MiB/s
CRC32C-NI: cycles: 1188335920, cycles/i 1188, 11833.073 MiB/s
CRC32C-PCL: cycles: 463193456, cycles/i 463, 30358.037 MiB/s
XXHASH: cycles: 851606646, cycles/i 851, 16511.916 MiB/s
SHA256-ref: cycles: 74476234956, cycles/i 74476, 188.808 MiB/s
SHA256-NI: cycles: 34198637428, cycles/i 34198, 411.177 MiB/s
BLAKE2-ref: cycles: 14761411664, cycles/i 14761, 952.597 MiB/s
BLAKE2-SSE2: cycles: 18101896796, cycles/i 18101, 776.807 MiB/s
BLAKE2-SSE41: cycles: 12599091062, cycles/i 12599, 1116.087 MiB/s
BLAKE2-AVX2: cycles: 9668247506, cycles/i 9668, 1454.418 MiB/s
The new implementation is about 2.5x faster.
Note: there new version does not work on musl because of linkage
problems (relocations in .rodata), so it's still using the old
implementation.
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-21 21:18:13 +00:00
AX_CHECK_DEFINE([features.h],[__GLIBC__],[HAVE_GLIBC=1],[HAVE_GLIBC=0])
AC_SUBST([HAVE_GLIBC])
2022-07-27 22:27:19 +00:00
AX_GCC_BUILTIN([__builtin_add_overflow])
AX_GCC_BUILTIN([__builtin_sub_overflow])
AX_GCC_BUILTIN([__builtin_mul_overflow])
2023-09-12 21:32:38 +00:00
AX_GCC_BUILTIN([__builtin_cpu_supports__pclmul])
2022-07-27 22:27:19 +00:00
btrfs-progs: crypto: add perf support to speed test
Use perf events to read the cycle count, this should work on all
architectures. Enabled by option --perf and the sysctl
kernel.perf_event_paranoid must be 0 or 1.
The results are roughly the same as for raw cycles on x86_64 but worse
because of the additional overhead (read, context switch):
Block size: 4096
Iterations: 100000
Implementation: builtin
Units: CPU cycles
NULL-NOP: cycles: 42719688, cycles/i 427
NULL-MEMCPY: cycles: 72941208, cycles/i 729, 18670.314 MiB/s
CRC32C: cycles: 183709926, cycles/i 1837, 7413.009 MiB/s
XXHASH: cycles: 136727614, cycles/i 1367, 9960.264 MiB/s
SHA256: cycles: 10711594532, cycles/i 107115, 127.137 MiB/s
BLAKE2: cycles: 2256957529, cycles/i 22569, 603.398 MiB/s
Block size: 4096
Iterations: 100000
Implementation: builtin
Units: perf event: CPU cycles
NULL-NOP: perf_c: 29649530, perf_c/i 296
NULL-MEMCPY: perf_c: 59954062, perf_c/i 599, 15137.464 MiB/s
CRC32C: perf_c: 179009071, perf_c/i 1790, 6929.460 MiB/s
XXHASH: perf_c: 136413509, perf_c/i 1364, 9982.950 MiB/s
SHA256: perf_c: 10997356664, perf_c/i 109973, 127.046 MiB/s
BLAKE2: perf_c: 2379077576, perf_c/i 23790, 588.780 MiB/s
Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-01 19:41:53 +00:00
AC_CHECK_HEADERS([linux/perf_event.h])
AC_CHECK_HEADERS([linux/hw_breakpoint.h])
2022-08-15 20:54:42 +00:00
AC_CHECK_HEADERS([linux/fsverity.h])
2023-05-03 21:54:30 +00:00
AC_CHECK_HEADERS([printf.h])
2022-08-15 20:54:42 +00:00
if grep -q 'HAVE_LINUX_FSVERITY_H.*1' confdefs.h; then
have_fsverity='yes'
else
have_fsverity='no'
fi
btrfs-progs: crypto: add perf support to speed test
Use perf events to read the cycle count, this should work on all
architectures. Enabled by option --perf and the sysctl
kernel.perf_event_paranoid must be 0 or 1.
The results are roughly the same as for raw cycles on x86_64 but worse
because of the additional overhead (read, context switch):
Block size: 4096
Iterations: 100000
Implementation: builtin
Units: CPU cycles
NULL-NOP: cycles: 42719688, cycles/i 427
NULL-MEMCPY: cycles: 72941208, cycles/i 729, 18670.314 MiB/s
CRC32C: cycles: 183709926, cycles/i 1837, 7413.009 MiB/s
XXHASH: cycles: 136727614, cycles/i 1367, 9960.264 MiB/s
SHA256: cycles: 10711594532, cycles/i 107115, 127.137 MiB/s
BLAKE2: cycles: 2256957529, cycles/i 22569, 603.398 MiB/s
Block size: 4096
Iterations: 100000
Implementation: builtin
Units: perf event: CPU cycles
NULL-NOP: perf_c: 29649530, perf_c/i 296
NULL-MEMCPY: perf_c: 59954062, perf_c/i 599, 15137.464 MiB/s
CRC32C: perf_c: 179009071, perf_c/i 1790, 6929.460 MiB/s
XXHASH: perf_c: 136413509, perf_c/i 1364, 9982.950 MiB/s
SHA256: perf_c: 10997356664, perf_c/i 109973, 127.046 MiB/s
BLAKE2: perf_c: 2379077576, perf_c/i 23790, 588.780 MiB/s
Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-01 19:41:53 +00:00
2014-12-04 12:26:46 +00:00
m4_ifndef([PKG_PROG_PKG_CONFIG],
[m4_fatal([Could not locate the pkg-config autoconf
macros. These are usually located in /usr/share/aclocal/pkg.m4.
If your macros are in a different location, try setting the
environment variable AL_OPTS="-I/other/macro/dir" before running
./autogen.sh or autoreconf again.])])
PKG_PROG_PKG_CONFIG
dnl
dnl Calls pkg-config --static
dnl
AC_DEFUN([PKG_STATIC], [
2018-02-19 17:13:46 +00:00
if AC_RUN_LOG([${PKG_CONFIG} --exists --print-errors "$2"]); then
$1=`${PKG_CONFIG} --libs --static "$2"`
2014-12-04 12:26:46 +00:00
AC_SUBST([$1])
else
AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available])
fi
])
2014-12-10 14:21:24 +00:00
AC_ARG_ENABLE([backtrace],
AS_HELP_STRING([--disable-backtrace], [disable btrfs backtrace]),
[], [enable_backtrace=yes]
)
AS_IF([test "x$enable_backtrace" = xno], [
AC_DEFINE([BTRFS_DISABLE_BACKTRACE], [1], [disable backtrace stuff in kerncompat.h ])
])
2015-02-03 15:50:33 +00:00
if test "x$enable_backtrace" = xyes; then
AC_CHECK_HEADERS([execinfo.h])
AC_CHECK_FUNCS([backtrace backtrace_symbols_fd], [],
AC_MSG_ERROR([standard library does not have backtrace support]))
fi
2014-12-12 10:54:06 +00:00
AC_ARG_ENABLE([documentation],
2018-11-26 17:08:21 +00:00
AS_HELP_STRING([--disable-documentation], [do not build documentation]),
2014-12-12 10:54:06 +00:00
[], [enable_documentation=yes]
)
AS_IF([test "x$enable_documentation" = xyes], [DISABLE_DOCUMENTATION=0], [DISABLE_DOCUMENTATION=1])
AC_SUBST([DISABLE_DOCUMENTATION])
2015-02-03 14:38:17 +00:00
dnl detect tools to build documentation
2022-01-13 17:29:42 +00:00
DOC_TOOL="none"
2015-02-03 14:38:17 +00:00
if test "x$enable_documentation" = xyes; then
2022-01-13 17:29:42 +00:00
DOC_TOOL='sphinx'
AC_PATH_PROG([SPHINX], [sphinx-build])
2015-02-03 14:38:17 +00:00
AC_PROG_SED
2022-01-13 17:29:42 +00:00
if test -z "$SPHINX"; then
AC_MSG_ERROR([cannot find sphinx-build, cannot build documentation])
2018-02-02 19:51:25 +00:00
fi
2015-02-03 14:38:17 +00:00
fi
2022-01-13 17:29:42 +00:00
AC_SUBST([DOC_TOOL])
2015-02-03 14:38:17 +00:00
2018-07-26 20:34:38 +00:00
AC_ARG_ENABLE([programs],
AS_HELP_STRING([--disable-programs], [do not build utility programs]),
[], [enable_programs=yes]
)
AS_IF([test "x$enable_programs" = xyes], [BUILD_PROGRAMS=1], [BUILD_PROGRAMS=0])
AC_SUBST([BUILD_PROGRAMS])
2018-07-26 20:34:39 +00:00
AC_ARG_ENABLE([shared],
AS_HELP_STRING([--disable-shared], [do not build shared libraries]),
[], [enable_shared=yes]
)
AS_IF([test "x$enable_shared" = xyes], [BUILD_SHARED_LIBRARIES=1], [BUILD_SHARED_LIBRARIES=0])
AC_SUBST([BUILD_SHARED_LIBRARIES])
AC_ARG_ENABLE([static],
AS_HELP_STRING([--disable-static], [do not build static libraries]),
[], [enable_static=yes]
)
AS_IF([test "x$enable_static" = xyes], [BUILD_STATIC_LIBRARIES=1], [BUILD_STATIC_LIBRARIES=0])
AC_SUBST([BUILD_STATIC_LIBRARIES])
2015-02-03 15:22:55 +00:00
AC_ARG_ENABLE([convert],
AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]),
2018-07-26 20:34:38 +00:00
[], [enable_convert=$enable_programs]
2015-02-03 15:22:55 +00:00
)
2015-03-25 00:55:41 +00:00
AS_IF([test "x$enable_convert" = xyes], [DISABLE_BTRFSCONVERT=0], [DISABLE_BTRFSCONVERT=1])
2015-02-03 15:22:55 +00:00
AC_SUBST([DISABLE_BTRFSCONVERT])
2016-08-23 15:21:30 +00:00
AC_ARG_WITH([convert],
AS_HELP_STRING([[[]--with-convert[[=auto]]]], [built-in filesystems for convert (default: auto)
2017-08-22 16:30:43 +00:00
supported (comma separated list): ext2,reiserfs]),
2016-08-23 15:21:30 +00:00
[], [with_convert=auto]
)
if test "$with_convert" = "yes"; then
with_convert=auto
fi
if test "$with_convert" = "no"; then
with_convert=
fi
convertfs=
BTRFSCONVERT_EXT2=0
2017-08-22 16:30:43 +00:00
BTRFSCONVERT_REISERFS=0
2015-03-25 00:55:41 +00:00
if test "x$enable_convert" = xyes; then
2016-08-23 15:21:30 +00:00
if test "x$with_convert" = "xauto" || echo "$with_convert" | grep -q "ext2"; then
2018-04-30 14:37:06 +00:00
PKG_CHECK_MODULES(EXT2FS, [ext2fs])
2016-08-23 15:21:30 +00:00
PKG_CHECK_MODULES(COM_ERR, [com_err])
convertfs="${convertfs:+$convertfs,}ext2"
BTRFSCONVERT_EXT2=1
fi
2017-08-22 16:30:43 +00:00
if test "x$with_convert" = "xauto"; then
PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
[BTRFSCONVERT_REISERFS=1],
[BTRFSCONVERT_REISERFS=0])
elif echo "$with_convert" | grep -q "reiserfs"; then
PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
[BTRFSCONVERT_REISERFS=1],[])
fi
if test "$BTRFSCONVERT_REISERFS" = 1; then
convertfs="${convertfs:+$convertfs,}reiserfs"
fi
2016-08-23 15:21:30 +00:00
fi
AC_SUBST([BTRFSCONVERT_EXT2])
2017-08-22 16:30:43 +00:00
AC_SUBST([BTRFSCONVERT_REISERFS])
2016-08-23 15:21:30 +00:00
# catch typos
2017-10-12 12:08:54 +00:00
tmp=$(echo "$with_convert" | sed -e 's/auto//' | sed -e 's/ext2//' | sed -e 's/reiserfs//' | sed -e 's/,\+//')
2016-08-23 15:21:30 +00:00
if ! test "x$tmp" = "x"; then
AC_MSG_ERROR([unknown tokens for --with-convert: $tmp])
fi
if test "$DISABLE_BTRFSCONVERT" = 0 && test "x$convertfs" = "x"; then
AC_MSG_ERROR([no filesystems for convert, use --disable-convert instead])
2015-02-03 16:12:28 +00:00
fi
2020-04-06 19:02:56 +00:00
AC_ARG_WITH([crypto],
2020-05-28 20:39:43 +00:00
AS_HELP_STRING([[[]--with-crypto[[=builtin]]]], [provider of cryptographic primitives: builtin, libgcrypt, libsodium, libkcapi]),
2020-04-06 19:02:56 +00:00
[], [with_crypto=builtin]
)
cryptoprovider=
cryptoproviderversion=
CRYPTOPROVIDER_BUILTIN=0
2023-03-01 14:27:52 +00:00
CRYPTOPROVIDER_LIBGCRYPT=0
CRYPTOPROVIDER_LIBSODIUM=0
CRYPTOPROVIDER_LIBKCAPI=0
2020-04-06 19:02:56 +00:00
if test "$with_crypto" = "builtin"; then
cryptoprovider="builtin"
CRYPTOPROVIDER_BUILTIN=1
elif test "$with_crypto" = "libgcrypt"; then
cryptoprovider="libgcrypt"
PKG_CHECK_MODULES(GCRYPT, [libgcrypt >= 1.8.0])
2023-03-01 14:27:52 +00:00
CRYPTOPROVIDER_LIBGCRYPT=1
2021-03-09 21:24:40 +00:00
cryptoproviderversion=`${PKG_CONFIG} libgcrypt --version`
2020-04-06 19:02:56 +00:00
elif test "$with_crypto" = "libsodium"; then
cryptoprovider="libsodium"
PKG_CHECK_MODULES(SODIUM, [libsodium >= 1.0.4])
2023-03-01 14:27:52 +00:00
CRYPTOPROVIDER_LIBSODIUM=1
2021-03-09 21:24:40 +00:00
cryptoproviderversion=`${PKG_CONFIG} libsodium --version`
2020-05-28 20:39:43 +00:00
elif test "$with_crypto" = "libkcapi"; then
cryptoprovider="libkcapi"
PKG_CHECK_MODULES(KCAPI, [libkcapi >= 1.0.0])
2023-03-01 14:27:52 +00:00
CRYPTOPROVIDER_LIBKCAPI=1
2021-03-09 21:24:40 +00:00
cryptoproviderversion=`${PKG_CONFIG} libkcapi --version`
2020-04-06 19:02:56 +00:00
else
AC_MSG_ERROR([unrecognized crypto provider: $with_crypto])
fi
AC_SUBST([CRYPTOPROVIDER_BUILTIN])
2023-03-01 14:27:52 +00:00
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER_BUILTIN],[$CRYPTOPROVIDER_BUILTIN],[Use builtin implementation])
AC_SUBST([CRYPTOPROVIDER_LIBGCRYPT])
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER_LIBGCRYPT],[$CRYPTOPROVIDER_LIBGCRYPT],[Use libcrypt])
AC_SUBST([CRYPTOPROVIDER_LIBSODIUM])
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER_LIBSODIUM],[$CRYPTOPROVIDER_LIBSODIUM],[Use libsodium])
AC_SUBST([CRYPTOPROVIDER_LIBKCAPI])
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER_LIBKCAPI],[$CRYPTOPROVIDER_LIBKCAPI],[Use libkcapi])
2020-04-06 19:02:56 +00:00
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER],["$cryptoprovider"],[Crypto implementation source name])
2016-06-24 12:04:04 +00:00
AX_CHECK_DEFINE([linux/fiemap.h], [FIEMAP_EXTENT_SHARED], [],
2021-03-20 09:27:28 +00:00
[AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [1],
[Define to 1 if kernel headers do not define FIEMAP_EXTENT_SHARED])
2020-03-27 20:36:52 +00:00
AC_MSG_WARN([no definition of FIEMAP_EXTENT_SHARED found, probably old kernel, will use own definition, 'btrfs fi du' might report wrong numbers])])
2016-10-14 16:39:40 +00:00
2021-03-14 18:49:13 +00:00
AX_CHECK_DEFINE([ext2fs/ext2_fs.h], [EXT4_EPOCH_MASK],
[AC_DEFINE([HAVE_EXT4_EPOCH_MASK_DEFINE], [1],
[Define to 1 if e2fsprogs defines EXT4_EPOCH_MASK])],
btrfs-progs: build: fix detection of ext4 i_{a,c,a}time_extra
Running convert-tests.sh Reported that the 019-ext4-copy-timestamps test
failed:
...
mount -o loop -t ext4 btrfs-progs/tests/test.img btrfs-progs/tests/mnt
====== RUN CHECK touch btrfs-progs/tests/mnt/file
====== RUN CHECK stat btrfs-progs/tests/mnt/file
File: 'btrfs-progs/tests/mnt/file'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 700h/1792d Inode: 13 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:unlabeled_t:s0
Access: 2021-08-24 22:10:21.999209679 +0800
Modify: 2021-08-24 22:10:21.999209679 +0800
Change: 2021-08-24 22:10:21.999209679 +0800
...
btrfs-progs/btrfs-convert btrfs-progs/tests/test.img
...
====== RUN CHECK mount -t btrfs -o loop btrfs-progs/tests/test.img btrfs-progs/tests/mnt
====== RUN CHECK stat btrfs-progs/tests/mnt/file
File: 'btrfs-progs/tests/mnt/file'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 2ch/44d Inode: 267 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:unlabeled_t:s0
Access: 2021-08-24 22:10:21.000000000 +0800
Modify: 2021-08-24 22:10:21.000000000 +0800
Change: 2021-08-24 22:10:21.000000000 +0800
...
atime on converted inode does not match
test failed for case 019-ext4-copy-timestamps
Obviously, the log says that btrfs-convert does not support nanoseconds.
I looked at the source code and found that only if ext2_fs.h defines
EXT4_EPOCH_MASK btrfs-convert to support nanoseconds. But in e2fsprogs,
EXT4_EPOCH_MASK was introduced in v1.43, but in some older versions,
such as v1.40, e2fsprogs actually supports nanoseconds. It seems that if
struct ext2_inode_large contains the i_atime_extra member, ext4 is
supports nanoseconds, so I updated the logic to determine whether the
current ext4 file system supports nanosecond precision. In addition, I
imported some definitions to encode and decode tv_nsec (copied from
e2fsprogs source code).
Author: Li Zhang <zhanglikernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-08-24 17:04:47 +00:00
[have_ext4_epoch_mask_define=no])
AS_IF([test "x$have_ext4_epoch_mask_define" = xno], [
AC_CHECK_MEMBERS([struct ext2_inode_large.i_atime_extra],
[
AC_DEFINE([HAVE_EXT4_EPOCH_MASK_DEFINE], [1], [Define to 1 if ext2_inode_large includes i_atime_extra])
AC_DEFINE([EXT4_EPOCH_BITS], [2],[for encode and decode tv_nsec in ext2 inode])
AC_DEFINE([EXT4_EPOCH_MASK], [((1 << EXT4_EPOCH_BITS) - 1)], [For encode and decode tv_nsec info in ext2 inode])
AC_DEFINE([EXT4_NSEC_MASK], [(~0UL << EXT4_EPOCH_BITS)], [For encode and decode tv_nsec info in ext2 inode])
AC_DEFINE([inode_includes(size, field)],[m4_normalize[(size >= (sizeof(((struct ext2_inode_large *)0)->field) + offsetof(struct ext2_inode_large, field)))]],
[For encode and decode tv_nsec info in ext2 inode])
],
[AC_MSG_WARN([It seems that ext2_inode_large don't includes tv_nsec related info, probably old e2fsprogs, no 64bit time precision of converted images])],
[[#include <ext2fs/ext2_fs.h>]])
])
2021-02-24 15:31:11 +00:00
2021-04-26 06:27:19 +00:00
AC_CHECK_HEADER(linux/blkzoned.h, [blkzoned_found=yes], [blkzoned_found=no])
2021-05-03 19:27:12 +00:00
AC_CHECK_MEMBER([struct blk_zone.capacity], [blkzoned_capacity=yes], [blkzoned_capacity=no], [[#include <linux/blkzoned.h>]])
AX_CHECK_DEFINE([linux/blkzoned.h], [BLKGETZONESZ], [blkzoned_getzonesz=yes], [blkzoned_getzonesz=no])
2021-04-26 06:27:19 +00:00
AC_ARG_ENABLE([zoned],
2022-02-07 17:41:03 +00:00
AS_HELP_STRING([--disable-zoned], [disable zoned block device support (default: detect)]),
[], [enable_zoned=$blkzoned_capacity]
2021-04-26 06:27:19 +00:00
)
2022-02-07 17:41:03 +00:00
# Autodetect zoned support
AS_IF([test "x$enableval" = "x"], [
cansupportzoned=yes
if test "x$blkzoned_found" = xno; then
cansupportzoned=no
fi
if test "x$blkzoned_capacity" = xno; then
cansupportzoned=no
fi
if test "x$blkzoned_getzonesz" = xno; then
cansupportzoned=no
fi
if test "x$cansupportzoned" = xno; then
AC_MSG_NOTICE([insufficient support for zoned mode, cannot enable])
enable_zoned=no
else
enable_zoned=yes
fi
])
# Explicitly requested by --enable-zoned
2021-04-26 06:27:19 +00:00
AS_IF([test "x$enable_zoned" = xyes], [
2021-05-03 19:27:12 +00:00
if test "x$blkzoned_found" = xno; then
AC_MSG_ERROR([Couldn't find linux/blkzoned.h])
fi
if test "x$blkzoned_capacity" = xno; then
AC_MSG_ERROR([linux/blkzoned.h does not provide blk_zone.capacity])
fi
if test "x$blkzoned_getzonesz" = xno; then
AC_MSG_ERROR([linux/blkzoned.h does not define BLKGETZONESZ])
fi
AC_DEFINE([BTRFS_ZONED], [1], [Define to 1 if zoned device support is available])
2021-04-26 06:27:19 +00:00
])
2014-12-04 12:26:46 +00:00
dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
dnl
dnl The default PKG_CHECK_MODULES() action-if-not-found is end the
dnl execution with error. The static libs are optional.
PKG_CHECK_MODULES(BLKID, [blkid])
PKG_STATIC(BLKID_LIBS_STATIC, [blkid])
PKG_CHECK_MODULES(UUID, [uuid])
PKG_STATIC(UUID_LIBS_STATIC, [uuid])
PKG_CHECK_MODULES(ZLIB, [zlib])
PKG_STATIC(ZLIB_LIBS_STATIC, [zlib])
2017-09-08 20:29:23 +00:00
AC_ARG_ENABLE([zstd],
2022-06-20 23:53:05 +00:00
AS_HELP_STRING([--disable-zstd], [build without zstd support for restore and receive (default: enabled)]),
2017-11-14 14:24:39 +00:00
[], [enable_zstd=yes]
2017-09-08 20:29:23 +00:00
)
if test "x$enable_zstd" = xyes; then
PKG_CHECK_MODULES(ZSTD, [libzstd >= 1.0.0])
PKG_STATIC(ZSTD_LIBS_STATIC, [libzstd])
fi
2022-06-20 23:53:05 +00:00
AS_IF([test "x$enable_zstd" = xyes], [COMPRESSION_ZSTD=1], [COMPRESSION_ZSTD=0])
AC_SUBST(COMPRESSION_ZSTD)
2017-09-08 20:29:23 +00:00
2021-10-05 14:43:02 +00:00
AC_ARG_ENABLE([libudev],
AS_HELP_STRING([--disable-libudev], [build without libudev support (for multipath)]),
[], [enable_libudev=yes]
)
if test "x$enable_libudev" = xyes; then
2021-09-30 12:06:32 +00:00
PKG_CHECK_MODULES([LIBUDEV], [libudev])
AC_DEFINE([HAVE_LIBUDEV], [1], [Define to 1 if libudev is available])
fi
2017-12-18 08:31:25 +00:00
AC_ARG_ENABLE([python],
AS_HELP_STRING([--disable-python], [do not build libbtrfsutil Python bindings]),
2018-07-26 20:34:39 +00:00
[], [enable_python=$enable_shared]
2017-12-18 08:31:25 +00:00
)
if test "x$enable_python" = xyes; then
AM_PATH_PYTHON([3.4])
2018-02-27 20:42:38 +00:00
PKG_CHECK_MODULES(PYTHON, [python-${PYTHON_VERSION}])
2017-12-18 08:31:25 +00:00
fi
AS_IF([test "x$enable_python" = xyes], [PYTHON_BINDINGS=1], [PYTHON_BINDINGS=0])
AC_SUBST(PYTHON_BINDINGS)
AC_SUBST(PYTHON)
2021-08-23 14:42:51 +00:00
AC_ARG_ENABLE([experimental],
AS_HELP_STRING([--enable-experimental], [allow UNSTABLE and EXPERIMENTAL features]))
AS_IF([test "x$enable_experimental" = xyes], [EXPERIMENTAL=1], [EXPERIMENTAL=0])
AC_SUBST(EXPERIMENTAL)
AC_DEFINE_UNQUOTED([EXPERIMENTAL],[$EXPERIMENTAL],[Define to 1 if you experimental and unstable features are build])
experimental_msg=
if test "x$EXPERIMENTAL" = x1; then
experimental_msg="
WARNING: experimental and unstable features are enabled, do not use this
build for production and please report issues
"
fi
2016-08-31 01:15:44 +00:00
# udev v190 introduced the btrfs builtin and a udev rule to use it.
# Our udev rule gives us the friendly dm names but isn't required (or valid)
# on earlier releases.
UDEVDIR=
2018-02-19 17:13:46 +00:00
if ${PKG_CONFIG} udev --atleast-version 190; then
UDEVDIR="$(${PKG_CONFIG} udev --variable=udevdir)"
2016-08-31 01:15:44 +00:00
fi
2016-05-13 03:44:52 +00:00
AC_SUBST(UDEVDIR)
2016-05-09 15:44:26 +00:00
2022-05-24 12:44:29 +00:00
AC_ARG_ENABLE([lzo],
2022-06-20 23:53:05 +00:00
AS_HELP_STRING([--disable-lzo], [build without lzo support for restore and receive (default: enabled)]),
2022-05-24 12:44:29 +00:00
[], [enable_lzo=yes]
)
if test "x$enable_lzo" = xyes; then
dnl lzo library does not provide pkg-config, use classic way
AC_CHECK_LIB([lzo2], [lzo_version], [
LZO2_LIBS="-llzo2"
LZO2_CFLAGS=""
LZO2_LIBS_STATIC="-llzo2"],[
AC_MSG_ERROR([cannot find lzo2 library])
])
AC_SUBST([LZO2_LIBS])
AC_SUBST([LZO2_LIBS_STATIC])
AC_SUBST([LZO2_CFLAGS])
fi
2022-06-20 23:53:05 +00:00
AS_IF([test "x$enable_lzo" = xyes], [COMPRESSION_LZO=1], [COMPRESSION_LZO=0])
AC_SUBST(COMPRESSION_LZO)
2014-12-04 12:26:46 +00:00
2020-08-20 04:36:18 +00:00
dnl call PKG_INSTALLDIR from pkg.m4 to set pkgconfigdir
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_MSG_ERROR([please install pkgconf])])
2014-12-04 12:26:46 +00:00
2020-10-20 13:43:45 +00:00
dnl Versions
AC_SUBST([BTRFS_VERSION_PLAIN])
AC_SUBST([BTRFS_VERSION_MAJOR])
AC_SUBST([BTRFS_VERSION_MINOR])
AC_SUBST([BTRFS_VERSION_PATCHLEVEL])
2014-12-09 14:58:11 +00:00
AC_SUBST([LIBBTRFS_MAJOR])
AC_SUBST([LIBBTRFS_MINOR])
AC_SUBST([LIBBTRFS_PATCHLEVEL])
2014-12-04 12:26:46 +00:00
2020-08-20 04:36:18 +00:00
AC_SUBST([BTRFS_UTIL_VERSION_MAJOR])
AC_SUBST([BTRFS_UTIL_VERSION_MINOR])
AC_SUBST([BTRFS_UTIL_VERSION_PATCH])
2023-02-21 00:41:21 +00:00
AC_CONFIG_HEADERS([include/config.h])
2014-12-04 12:26:46 +00:00
AC_CONFIG_FILES([
2017-01-30 10:04:16 +00:00
Makefile.inc
2015-02-03 13:49:09 +00:00
Documentation/Makefile
2023-01-05 13:18:07 +00:00
libbtrfs/version.h
2020-08-20 04:36:18 +00:00
libbtrfsutil/libbtrfsutil.pc
2014-12-04 12:26:46 +00:00
])
AC_OUTPUT
AC_MSG_RESULT([
2020-10-02 17:51:04 +00:00
btrfs-progs: ${PACKAGE_VERSION}
libbtrfs: ${LIBBTRFS_MAJOR}.${LIBBTRFS_MINOR}.${LIBBTRFS_PATCHLEVEL} (deprecated)
libbtrfsutil: ${BTRFS_UTIL_VERSION_MAJOR}.${BTRFS_UTIL_VERSION_MINOR}.${BTRFS_UTIL_VERSION_PATCH}
2014-12-04 12:26:46 +00:00
2017-09-08 20:29:23 +00:00
prefix: ${prefix}
exec prefix: ${exec_prefix}
2014-12-04 12:26:46 +00:00
2017-09-08 20:29:23 +00:00
bindir: ${bindir}
libdir: ${libdir}
includedir: ${includedir}
2020-08-20 04:36:18 +00:00
pkgconfigdir: ${pkgconfigdir}
2014-12-04 12:26:46 +00:00
2017-09-08 20:29:23 +00:00
compiler: ${CC}
2021-10-05 15:10:36 +00:00
CFLAGS: ${CFLAGS}
LDFLAGS: ${LDFLAGS}
2014-12-04 12:26:46 +00:00
2018-07-26 20:34:38 +00:00
programs: ${enable_programs}
2018-07-26 20:34:39 +00:00
shared libraries: ${enable_shared}
static libraries: ${enable_static}
2017-09-08 20:29:23 +00:00
documentation: ${enable_documentation}
2022-01-13 17:29:42 +00:00
doc generator: ${DOC_TOOL}
2017-09-08 20:29:23 +00:00
backtrace support: ${enable_backtrace}
btrfs-convert: ${enable_convert} ${convertfs:+($convertfs)}
2022-06-20 23:53:05 +00:00
zstd support: ${enable_zstd}
lzo support: ${enable_lzo}
2022-08-15 20:54:42 +00:00
fsverity support: ${have_fsverity}
2017-12-18 08:31:25 +00:00
Python bindings: ${enable_python}
Python interpreter: ${PYTHON}
2020-04-06 19:02:56 +00:00
crypto provider: ${cryptoprovider} ${cryptoproviderversion}
2021-10-05 14:43:02 +00:00
libudev: ${enable_libudev}
2021-04-26 06:27:19 +00:00
zoned device: ${enable_zoned}
2021-08-23 14:42:51 +00:00
${experimental_msg}
2014-12-04 12:26:46 +00:00
Type 'make' to compile.
])