Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
configure.ac | 20 ++------------------
m4/virt-devmapper.m4 | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 18 deletions(-)
create mode 100644 m4/virt-devmapper.m4
diff --git a/configure.ac b/configure.ac
index 1c115805b2..12f3f2fff1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,7 +111,6 @@ fi
dnl Required minimum versions of all libs we depend on
PARTED_REQUIRED="1.8.0"
-DEVMAPPER_REQUIRED=1.0.0
PARALLELS_SDK_REQUIRED="7.0.22"
dnl Where we look for daemons and admin binaries during configure
LIBVIRT_SBIN_PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
@@ -1417,29 +1416,14 @@ AM_CONDITIONAL([WITH_STORAGE_DISK], [test
"$with_storage_disk" = "yes"])
AC_SUBST([LIBPARTED_CFLAGS])
AC_SUBST([LIBPARTED_LIBS])
+LIBVIRT_CHECK_DEVMAPPER
+
if test "$with_storage_mpath" = "yes" ||
test "$with_storage_disk" = "yes"; then
- DEVMAPPER_CFLAGS=
- DEVMAPPER_LIBS=
- PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= $DEVMAPPER_REQUIRED], [],
[DEVMAPPER_FOUND=no])
- if test "$DEVMAPPER_FOUND" = "no"; then
- # devmapper is missing pkg-config files in ubuntu, suse, etc
- save_LIBS="$LIBS"
- save_CFLAGS="$CFLAGS"
- DEVMAPPER_FOUND=yes
- AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no])
- DEVMAPPER_LIBS="-ldevmapper"
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
- fi
- AC_CHECK_HEADERS([libdevmapper.h],,[DEVMAPPER_FOUND=no])
if test "$DEVMAPPER_FOUND" = "no" ; then
AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper >=
$DEVMAPPER_REQUIRED to compile libvirt])
fi
-
fi
-AC_SUBST([DEVMAPPER_CFLAGS])
-AC_SUBST([DEVMAPPER_LIBS])
with_storage=no
for backend in dir fs lvm iscsi scsi mpath rbd disk; do
diff --git a/m4/virt-devmapper.m4 b/m4/virt-devmapper.m4
new file mode 100644
index 0000000000..f0316ac434
--- /dev/null
+++ b/m4/virt-devmapper.m4
@@ -0,0 +1,42 @@
+dnl The devmapper library
+dnl
+dnl Copyright (C) 2016 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library. If not, see
+dnl <
http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([LIBVIRT_CHECK_DEVMAPPER], [
+ DEVMAPPER_REQUIRED=1.0.0
+ DEVMAPPER_CFLAGS=
+ DEVMAPPER_LIBS=
+
+ PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= $DEVMAPPER_REQUIRED], [],
[DEVMAPPER_FOUND=no])
+
+ if test "$DEVMAPPER_FOUND" = "no"; then
+ # devmapper is missing pkg-config files in ubuntu, suse, etc
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ DEVMAPPER_FOUND=yes
+ AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no])
+ DEVMAPPER_LIBS="-ldevmapper"
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+ fi
+
+ AC_CHECK_HEADERS([libdevmapper.h],,[DEVMAPPER_FOUND=no])
+
+ AC_SUBST([DEVMAPPER_CFLAGS])
+ AC_SUBST([DEVMAPPER_LIBS])
+])
--
2.11.0