File 0001-btrfs-progs-build-add-optional-dependency-on-libudev.patch of Package btrfsprogs.24931
From a17696a9241c50cbba993229eeccdf738fc46cfa Mon Sep 17 00:00:00 2001
From: Nikolay Borisov <nborisov@suse.com>
Date: Thu, 30 Sep 2021 15:06:32 +0300
Subject: [PATCH 1/3] btrfs-progs: build: add optional dependency on libudev
This is needed for future code which will make btrfs-progs' device
scanning logic a little smarter by filtering out path device in
multipath setups. libudev is added as an optional dependency since the
library doesn't have a static version so making it a hard dependency
means forfeiting static build support. To alleviate this a fallback code
will be added for the static build case which doesn't rely on libudev.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
Makefile | 2 +-
Makefile.inc.in | 2 +-
configure.ac | 9 +++++++++
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index ee1fc13992df..a7bbee8bb99f 100644
--- a/Makefile
+++ b/Makefile
@@ -96,7 +96,7 @@ LIBS = $(LIBS_BASE)
LIBBTRFS_LIBS = $(LIBS_BASE)
# Static compilation flags
-STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections
+STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections -DSTATIC_BUILD
STATIC_LDFLAGS = -static -Wl,--gc-sections
STATIC_LIBS = $(STATIC_LIBS_BASE)
diff --git a/Makefile.inc.in b/Makefile.inc.in
index a86c528ed0a5..6a7a37dd07ad 100644
--- a/Makefile.inc.in
+++ b/Makefile.inc.in
@@ -25,7 +25,7 @@ PYTHON_CFLAGS = @PYTHON_CFLAGS@
SUBST_CFLAGS = @CFLAGS@
SUBST_LDFLAGS = @LDFLAGS@
-LIBS_BASE = @UUID_LIBS@ @BLKID_LIBS@ -L. -pthread
+LIBS_BASE = @UUID_LIBS@ @BLKID_LIBS@ @LIBUDEV_LIBS@ -L. -pthread
LIBS_COMP = @ZLIB_LIBS@ @LZO2_LIBS@ @ZSTD_LIBS@
LIBS_PYTHON = @PYTHON_LIBS@
STATIC_LIBS_BASE = @UUID_LIBS_STATIC@ @BLKID_LIBS_STATIC@ -L. -pthread
diff --git a/configure.ac b/configure.ac
index cf792eb5488b..a8a59fe16293 100644
--- a/configure.ac
+++ b/configure.ac
@@ -233,6 +233,15 @@ fi
AS_IF([test "x$enable_zstd" = xyes], [BTRFSRESTORE_ZSTD=1], [BTRFSRESTORE_ZSTD=0])
AC_SUBST(BTRFSRESTORE_ZSTD)
+PKG_CHECK_EXISTS([libudev], [pkg_config_libudev=yes], [pkg_config_libudev=no])
+if test "x$pkg_config_libudev" = xyes; then
+ PKG_CHECK_MODULES([LIBUDEV], [libudev])
+ AC_DEFINE([HAVE_LIBUDEV], [1], [Define to 1 if libudev is available])
+else
+ AC_MSG_CHECKING([for LIBUDEV])
+ AC_MSG_RESULT([no])
+fi
+
AC_ARG_ENABLE([python],
AS_HELP_STRING([--disable-python], [do not build libbtrfsutil Python bindings]),
[], [enable_python=$enable_shared]
--
2.25.1