commit:     7ce2716d901d834c375b5a24c928a7ce33ba0653
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 09:49:51 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 11:58:17 2019 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=7ce2716d

Rework --multipath support

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 defaults/initrd.scripts                            |   4 +-
 defaults/software.sh                               |  21 +++
 gen_cmdline.sh                                     |  12 --
 gen_determineargs.sh                               |   5 +
 gen_initramfs.sh                                   |  43 +++---
 gkbuilds/eudev.gkbuild                             |  46 ++++++
 gkbuilds/multipath-tools.gkbuild                   |  62 ++++++++
 gkbuilds/userspace-rcu.gkbuild                     |  17 +++
 .../multipath-tools-0.7.5-respect-flags.patch      |  19 +++
 .../multipath-tools-0.8.0-respect-sysroot.patch    |  55 +++++++
 .../0.8.0/multipath-tools-0.8.0-static-libs.patch  | 159 +++++++++++++++++++++
 11 files changed, 407 insertions(+), 36 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index be76a4d..fc9045d 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1198,16 +1198,18 @@ start_volumes() {
                        good_msg "Scanning for multipath devices"
                        good_msg ":: Populating scsi_id info for libudev 
queries"
                        mkdir -p /run/udev/data
+
+                       local ech
                        for ech in /sys/block/*
                        do
                                local tgtfile=b$(cat ${ech}/dev)
                                /lib/udev/scsi_id -g -x /dev/${ech##*/} |sed -e 
's/^/E:/' >/run/udev/data/${tgtfile}
                        done
+
                        ${multipath_path} -v 0
                        sleep 2
                        good_msg "Activating multipath devices"
                        ${dmsetup_path} ls --target multipath --exec 
"${kpartx_path} -a -v"
-                       #for MULTIPATH_VOLUMES in /dev/mapper/*; do 
${kpartx_path} -a ${MULTIPATH_VOLUMES}; done
                fi
        fi
 

diff --git a/defaults/software.sh b/defaults/software.sh
index cecad69..acf5439 100644
--- a/defaults/software.sh
+++ b/defaults/software.sh
@@ -37,6 +37,13 @@ 
GKPKG_DROPBEAR_SRCTAR="${GKPKG_DROPBEAR_SRCTAR:-${DISTDIR}/dropbear-${GKPKG_DROP
 GKPKG_DROPBEAR_SRCDIR="${GKPKG_DROPBEAR_SRCDIR:-dropbear-${GKPKG_DROPBEAR_PV}}"
 
GKPKG_DROPBEAR_BINPKG="${GKPKG_DROPBEAR_BINPKG:-%%CACHE%%/dropbear-${GKPKG_DROPBEAR_PV}-%%ARCH%%.tar.xz}"
 
+GKPKG_EUDEV_PN="eudev"
+GKPKG_EUDEV_PV="${GKPKG_EUDEV_PV:-VERSION_EUDEV}"
+GKPKG_EUDEV_DEPS=""
+GKPKG_EUDEV_SRCTAR="${GKPKG_EUDEV_SRCTAR:-${DISTDIR}/eudev-${GKPKG_EUDEV_PV}.tar.gz}"
+GKPKG_EUDEV_SRCDIR="${GKPKG_EUDEV_SRCDIR:-eudev-${GKPKG_EUDEV_PV}}"
+GKPKG_EUDEV_BINPKG="${GKPKG_EUDEV_BINPKG:-%%CACHE%%/eudev-${GKPKG_EUDEV_PV}-%%ARCH%%.tar.xz}"
+
 GKPKG_E2FSPROGS_PN="e2fsprogs"
 GKPKG_E2FSPROGS_PV="${GKPKG_E2FSPROGS_PV:-VERSION_E2FSPROGS}"
 GKPKG_E2FSPROGS_DEPS="util-linux"
@@ -107,6 +114,13 @@ 
GKPKG_MDADM_SRCDIR="${GKPKG_MDADM_SRCDIR:-mdadm-${GKPKG_MDADM_PV}}"
 
GKPKG_MDADM_SRCTAR="${GKPKG_MDADM_SRCTAR:-${DISTDIR}/mdadm-${GKPKG_MDADM_PV}.tar.xz}"
 
GKPKG_MDADM_BINPKG="${GKPKG_MDADM_BINPKG:-%%CACHE%%/mdadm-${GKPKG_MDADM_PV}-%%ARCH%%.tar.xz}"
 
+GKPKG_MULTIPATH_TOOLS_PN="multipath-tools"
+GKPKG_MULTIPATH_TOOLS_PV="${GKPKG_MULTIPATH_TOOLS_PV:-VERSION_MULTIPATH_TOOLS}"
+GKPKG_MULTIPATH_TOOLS_DEPS="json-c libaio userspace-rcu eudev lvm"
+GKPKG_MULTIPATH_TOOLS_SRCTAR="${GKPKG_MULTIPATH_TOOLS_SRCTAR:-${DISTDIR}/multipath-tools-${GKPKG_MULTIPATH_TOOLS_PV}.tar.gz}"
+GKPKG_MULTIPATH_TOOLS_SRCDIR="${GKPKG_MULTIPATH_TOOLS_SRCDIR:-multipath-tools-${GKPKG_MULTIPATH_TOOLS_PV}-eb688e1}"
+GKPKG_MULTIPATH_TOOLS_BINPKG="${GKPKG_MULTIPATH_TOOLS_BINPKG:-%%CACHE%%/multipath-tools-${GKPKG_MULTIPATH_TOOLS_PV}-%%ARCH%%.tar.xz}"
+
 GKPKG_POPT_PN="popt"
 GKPKG_POPT_PV="${GKPKG_POPT_PV:-VERSION_POPT}"
 GKPKG_POPT_DEPS=""
@@ -121,6 +135,13 @@ 
GKPKG_UNIONFS_FUSE_SRCDIR="${GKPKG_UNIONFS_FUSE_SRCDIR:-unionfs-fuse-${GKPKG_UNI
 
GKPKG_UNIONFS_FUSE_SRCTAR="${GKPKG_UNIONFS_FUSE_SRCTAR:-${DISTDIR}/unionfs-fuse-${GKPKG_UNIONFS_FUSE_PV}.tar.gz}"
 
GKPKG_UNIONFS_FUSE_BINPKG="${GKPKG_UNIONFS_FUSE_BINPKG:-%%CACHE%%/unionfs-fuse-${GKPKG_UNIONFS_FUSE_PV}-%%ARCH%%.tar.xz}"
 
+GKPKG_USERSPACE_RCU_PN="userspace-rcu"
+GKPKG_USERSPACE_RCU_PV="${GKPKG_USERSPACE_RCU_PV:-VERSION_USERSPACE_RCU}"
+GKPKG_USERSPACE_RCU_DEPS=""
+GKPKG_USERSPACE_RCU_SRCTAR="${GKPKG_USERSPACE_RCU_SRCTAR:-${DISTDIR}/userspace-rcu-${GKPKG_USERSPACE_RCU_PV}.tar.bz2}"
+GKPKG_USERSPACE_RCU_SRCDIR="${GKPKG_USERSPACE_RCU_SRCDIR:-userspace-rcu-${GKPKG_USERSPACE_RCU_PV}}"
+GKPKG_USERSPACE_RCU_BINPKG="${GKPKG_USERSPACE_RCU_BINPKG:-%%CACHE%%/userspace-rcu-${GKPKG_USERSPACE_RCU_PV}-%%ARCH%%.tar.xz}"
+
 GKPKG_UTIL_LINUX_PN="util-linux"
 GKPKG_UTIL_LINUX_PV="${GKPKG_UTIL_LINUX_PV:-VERSION_UTIL_LINUX}"
 GKPKG_UTIL_LINUX_DEPS=""

diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 5a1b481..ec5a5bc 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -399,18 +399,6 @@ parse_cmdline() {
                        ;;
                --multipath|--no-multipath)
                        CMD_MULTIPATH=$(parse_optbool "$*")
-                       if isTrue "${CMD_MULTIPATH}" && [ ! -e /sbin/multipath ]
-                       then
-                               echo 'Error: --multipath requires 
sys-fs/multipath-tools' \
-                                       'to be installed on the host system.'
-                               exit 1
-                       fi
-                       if isTrue "${CMD_MULTIPATH}" && [ ! -e 
/usr/include/libdevmapper.h ]
-                       then
-                               echo 'Error: --multipath requires sys-fs/lvm2' \
-                                       'to be installed on the host system.'
-                               exit 1
-                       fi
                        print_info 2 "CMD_MULTIPATH: ${CMD_MULTIPATH}"
                        ;;
                --bootloader=*)

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index a698f77..7d01565 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -415,6 +415,11 @@ determine_real_args() {
                then
                        gen_die "--do-keymap-auto requires --keymap but 
--no-keymap is set!"
                fi
+
+               if isTrue "${MULTIPATH}" && ! isTrue "${LVM}"
+               then
+                       gen_die "--multipath requires --lvm but --no-lvm is 
set!"
+               fi
        fi
 
        MICROCODE=${MICROCODE,,}

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 26b2ea3..c4e9bdb 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -350,43 +350,40 @@ append_unionfs_fuse() {
 #      rm -r "${TEMP}/initramfs-suspend-temp/"
 #}
 
-append_multipath(){
-       if [ -d "${TEMP}/initramfs-multipath-temp" ]
+append_multipath() {
+       local PN=multipath-tools
+       local TDIR="${TEMP}/initramfs-${PN}-temp"
+       if [ -d "${TDIR}" ]
        then
-               rm -r "${TEMP}/initramfs-multipath-temp"
+               rm -r "${TDIR}" || gen_die "Failed to clean out existing 
'${TDIR}'!"
        fi
-       print_info 1 "$(getIndent 2)Multipath: Adding support (using system 
binaries)..."
-       mkdir -p "${TEMP}"/initramfs-multipath-temp/{bin,etc,sbin,lib}/
 
-       # Copy files
-       copy_binaries "${TEMP}/initramfs-multipath-temp" \
-               /bin/mountpoint \
-               /sbin/{multipath,kpartx,dmsetup} \
-               /{lib,lib64}/{udev/scsi_id,multipath/*so}
+       populate_binpkg ${PN}
+
+       mkdir -p "${TDIR}"/etc || gen_die "Failed to create '${TDIR}/etc'!"
 
-       # Support multipath-tools-0.4.8 and previous
-       if [ -x /sbin/mpath_prio_* ]
-       then
-               copy_binaries "${TEMP}/initramfs-multipath-temp" \
-                       /sbin/mpath_prio_*
-       fi
+       unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}"
+
+       cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
 
        if [ -x /sbin/multipath ]
        then
-               cp /etc/multipath.conf "${TEMP}/initramfs-multipath-temp/etc/" 
|| gen_die 'could not copy /etc/multipath.conf please check this'
+               cp -aL /etc/multipath.conf "${TDIR}"/etc/multipath.conf 
2>/dev/null \
+                       || gen_die "Failed to copy '/etc/multipath.conf'!"
        fi
+
        # /etc/scsi_id.config does not exist in newer udevs
        # copy it optionally.
-       if [ -x /sbin/scsi_id -a -f /etc/scsi_id.config ]
+       if [ -f /etc/scsi_id.config ]
        then
-               cp /etc/scsi_id.config "${TEMP}/initramfs-multipath-temp/etc/" 
|| gen_die 'could not copy scsi_id.config'
+               cp -aL /etc/scsi_id.config "${TDIR}"/etc/scsi_id.config 
2>/dev/null \
+                       || gen_die "Failed to copy '/etc/scsi_id.config'!"
        fi
-       cd "${TEMP}/initramfs-multipath-temp"
+
+       cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
        log_future_cpio_content
        find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
-                       || gen_die "compressing multipath cpio"
-       cd "${TEMP}"
-       rm -r "${TEMP}/initramfs-multipath-temp/"
+               || gen_die "Failed to append ${PN} to cpio!"
 }
 
 append_dmraid() {

diff --git a/gkbuilds/eudev.gkbuild b/gkbuilds/eudev.gkbuild
new file mode 100644
index 0000000..26dc8b2
--- /dev/null
+++ b/gkbuilds/eudev.gkbuild
@@ -0,0 +1,46 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+src_prepare() {
+       default
+
+       sed -i \
+               -e 's/scsi_id_LDADD = \\/scsi_id_LDADD = -all-static \\/' \
+               src/scsi_id/Makefile.in \
+               || die "Failed to add '-all-static' for scsi_id program!"
+}
+
+src_configure() {
+       export cc_cv_CFLAGS__flto=no
+
+       local myconf=(
+               ac_cv_search_cap_init=
+               ac_cv_header_sys_capability_h=yes
+               DBUS_CFLAGS=' '
+               DBUS_LIBS=' '
+               --enable-split-usr
+               --disable-manpages
+               --disable-hwdb
+               --enable-static
+               --disable-introspection
+               --disable-kmod
+               --disable-selinux
+               --disable-rule-generator
+       )
+
+       gkconf "${myconf[@]}"
+}
+
+src_install() {
+       default
+
+       "${STRIP}" --strip-all "${D}"/usr/lib/udev/*_id \
+               || die "Failed to strip '${D}/usr/lib/udev/*_id' programs!"
+
+       rm -rf \
+               "${D}"/etc \
+               "${D}"/sbin \
+               "${D}"/usr/bin \
+               "${D}"/usr/sbin \
+               "${D}"/usr/share
+}

diff --git a/gkbuilds/multipath-tools.gkbuild b/gkbuilds/multipath-tools.gkbuild
new file mode 100644
index 0000000..b2c7bd9
--- /dev/null
+++ b/gkbuilds/multipath-tools.gkbuild
@@ -0,0 +1,62 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+src_prepare() {
+       default
+
+       sed -i \
+               -e '/libmpathpersist \\/d' \
+               -e '/multipathd \\/d' \
+               -e '/mpathpersist \\/d' \
+               Makefile || die "Failed to disable unneeded components!"
+}
+
+src_compile() {
+       local MYMAKEOPTS=( "V=1" )
+       MYMAKEOPTS+=( "sysroot='${BROOT}'" )
+       MYMAKEOPTS+=( "ENABLE_LIBDMMP=0" )
+       gkmake "${MYMAKEOPTS[@]}"
+}
+
+src_install() {
+       mkdir "${D}"/sbin || die "Failed to create '${D}/sbin'!"
+
+       cp -a multipath/multipath "${D}"/sbin/ \
+               || die "Failed to copy '${S}/multipath/multipath' to 
'${D}/sbin/'!"
+
+       "${STRIP}" --strip-all "${D}"/sbin/multipath \
+               || die "Failed to strip '${D}/sbin/multipath'!"
+
+       cp -a kpartx/kpartx "${D}"/sbin/ \
+               || die "Failed to copy '${S}/kpartx/kpartx' to '${D}/sbin/'!"
+
+       "${STRIP}" --strip-all "${D}"/sbin/kpartx \
+               || die "Failed to strip '${D}/sbin/kpartx'!"
+
+       mkdir -p "${D}"/lib/multipath || die "Failed to create 
'${D}/lib/multipath'!"
+
+       local -a CHECKERS
+       CHECKERS+=( 'libcheckcciss_tur.so' )
+       CHECKERS+=( 'libcheckdirectio.so' )
+       CHECKERS+=( 'libcheckemc_clariion.so' )
+       CHECKERS+=( 'libcheckhp_sw.so' )
+       CHECKERS+=( 'libcheckrdac.so' )
+       CHECKERS+=( 'libcheckreadsector0.so' )
+       CHECKERS+=( 'libchecktur.so' )
+
+       local checker_lib=
+       for checker_lib in "${CHECKERS[@]}"
+       do
+               cp -a libmultipath/checkers/${checker_lib} 
"${D}"/lib/multipath/ \
+                       || die "Failed to copy checker 
'${S}/libmultipath/checkers/${checker_lib}' to 
'${D}/lib/multipath/${checker_lib}'!"
+
+               "${STRIP}" --strip-all "${D}"/lib/multipath/${checker_lib} \
+                       || die "Failed to strip 
'${D}/lib/multipath/${checker_lib}'!"
+       done
+
+       # Copy file from eudev package into multipath-tools binpkg ...
+       mkdir -p "${D}"/lib/udev || die "Failed to create '${D}/lib/udev'!"
+
+       cp -a "${BROOT}"/usr/lib/udev/scsi_id "${D}"/lib/udev/ \
+               || die "Failed to copy '${BROOT}/usr/lib/udev/scsi_id' to 
'${D}/lib/udev/'!"    
+}

diff --git a/gkbuilds/userspace-rcu.gkbuild b/gkbuilds/userspace-rcu.gkbuild
new file mode 100644
index 0000000..e214039
--- /dev/null
+++ b/gkbuilds/userspace-rcu.gkbuild
@@ -0,0 +1,17 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+src_configure() {
+       local myconf=(
+               --enable-shared
+               --enable-static
+       )
+
+       gkconf "${myconf[@]}"
+}
+
+src_install() {
+       default
+
+       rm -rf "${D}"/usr/share
+}

diff --git 
a/patches/multipath-tools/0.8.0/multipath-tools-0.7.5-respect-flags.patch 
b/patches/multipath-tools/0.8.0/multipath-tools-0.7.5-respect-flags.patch
new file mode 100644
index 0000000..fef55ce
--- /dev/null
+++ b/patches/multipath-tools/0.8.0/multipath-tools-0.7.5-respect-flags.patch
@@ -0,0 +1,19 @@
+--- multipath-tools-0.7.5/Makefile.inc
++++ multipath-tools-0.7.5/Makefile.inc
+@@ -91,12 +91,13 @@
+                 -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
+                 --param=ssp-buffer-size=4
+ 
+-CFLAGS                := $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" 
-DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
+-                 -MMD -MP $(CFLAGS)
++CFLAGS                ?= $(OPTFLAGS)
++CFLAGS                += -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" 
-DRUN_DIR=\"${RUN}\" \
++                 -MMD -MP
+ BIN_CFLAGS    = -fPIE -DPIE
+ LIB_CFLAGS    = -fPIC
+ SHARED_FLAGS  = -shared
+-LDFLAGS               = -Wl,-z,relro -Wl,-z,now
++LDFLAGS               += -Wl,-z,relro -Wl,-z,now
+ BIN_LDFLAGS   = -pie
+ 
+ # Check whether a function with name $1 has been declared in header file $2.

diff --git 
a/patches/multipath-tools/0.8.0/multipath-tools-0.8.0-respect-sysroot.patch 
b/patches/multipath-tools/0.8.0/multipath-tools-0.8.0-respect-sysroot.patch
new file mode 100644
index 0000000..66ac85e
--- /dev/null
+++ b/patches/multipath-tools/0.8.0/multipath-tools-0.8.0-respect-sysroot.patch
@@ -0,0 +1,55 @@
+diff --git a/Makefile.inc b/Makefile.inc
+index fc728ca..825166f 100644
+--- a/Makefile.inc
++++ b/Makefile.inc
+@@ -45,7 +45,8 @@ ifndef SYSTEMDPATH
+       SYSTEMDPATH=usr/lib
+ endif
+ 
+-prefix                =
++sysroot               ?=
++prefix                ?=
+ exec_prefix   = $(prefix)
+ usr_prefix    = $(prefix)
+ bindir                = $(exec_prefix)/sbin
+diff --git a/kpartx/Makefile b/kpartx/Makefile
+index 7eb467e..0a3827b 100644
+--- a/kpartx/Makefile
++++ b/kpartx/Makefile
+@@ -8,7 +8,7 @@ LDFLAGS += $(BIN_LDFLAGS)
+ 
+ LIBDEPS += -ldevmapper
+ 
+-ifneq ($(call check_func,dm_task_set_cookie,/usr/include/libdevmapper.h),0)
++ifneq ($(call 
check_func,dm_task_set_cookie,$(sysroot)/usr/include/libdevmapper.h),0)
+       CFLAGS += -DLIBDM_API_COOKIE
+ endif
+ 
+diff --git a/libmultipath/Makefile b/libmultipath/Makefile
+index a2be42e..becaef3 100644
+--- a/libmultipath/Makefile
++++ b/libmultipath/Makefile
+@@ -20,19 +20,19 @@ ifdef SYSTEMD
+       endif
+ endif
+ 
+-ifneq ($(call check_func,dm_task_no_flush,/usr/include/libdevmapper.h),0)
++ifneq ($(call 
check_func,dm_task_no_flush,$(sysroot)/usr/include/libdevmapper.h),0)
+       CFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE
+ endif
+ 
+-ifneq ($(call check_func,dm_task_set_cookie,/usr/include/libdevmapper.h),0)
++ifneq ($(call 
check_func,dm_task_set_cookie,$(sysroot)/usr/include/libdevmapper.h),0)
+       CFLAGS += -DLIBDM_API_COOKIE
+ endif
+ 
+-ifneq ($(call 
check_func,udev_monitor_set_receive_buffer_size,/usr/include/libudev.h),0)
++ifneq ($(call 
check_func,udev_monitor_set_receive_buffer_size,$(sysroot)/usr/include/libudev.h),0)
+       CFLAGS += -DLIBUDEV_API_RECVBUF
+ endif
+ 
+-ifneq ($(call 
check_func,dm_task_deferred_remove,/usr/include/libdevmapper.h),0)
++ifneq ($(call 
check_func,dm_task_deferred_remove,$(sysroot)/usr/include/libdevmapper.h),0)
+       CFLAGS += -DLIBDM_API_DEFERRED
+ endif
+ 

diff --git 
a/patches/multipath-tools/0.8.0/multipath-tools-0.8.0-static-libs.patch 
b/patches/multipath-tools/0.8.0/multipath-tools-0.8.0-static-libs.patch
new file mode 100644
index 0000000..c29d8b6
--- /dev/null
+++ b/patches/multipath-tools/0.8.0/multipath-tools-0.8.0-static-libs.patch
@@ -0,0 +1,159 @@
+diff --git a/Makefile.inc b/Makefile.inc
+index 76c81fc..6f3bc6d 100644
+--- a/Makefile.inc
++++ b/Makefile.inc
+@@ -101,7 +101,7 @@ BIN_CFLAGS = -fPIE -DPIE
+ LIB_CFLAGS    = -fPIC
+ SHARED_FLAGS  = -shared
+ LDFLAGS               += -Wl,-z,relro -Wl,-z,now
+-BIN_LDFLAGS   = -pie
++BIN_LDFLAGS   = -pie -static
+ 
+ # Check whether a function with name $1 has been declared in header file $2.
+ check_func = $(shell \
+diff --git a/kpartx/Makefile b/kpartx/Makefile
+index 0a3827b..f26101d 100644
+--- a/kpartx/Makefile
++++ b/kpartx/Makefile
+@@ -6,7 +6,7 @@ include ../Makefile.inc
+ CFLAGS += $(BIN_CFLAGS) -I. -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+ LDFLAGS += $(BIN_LDFLAGS)
+ 
+-LIBDEPS += -ldevmapper
++LIBDEPS += -ldevmapper -lm -lpthread
+ 
+ ifneq ($(call 
check_func,dm_task_set_cookie,$(sysroot)/usr/include/libdevmapper.h),0)
+       CFLAGS += -DLIBDM_API_COOKIE
+diff --git a/libmpathcmd/Makefile b/libmpathcmd/Makefile
+index 0f6b816..2fb81e4 100644
+--- a/libmpathcmd/Makefile
++++ b/libmpathcmd/Makefile
+@@ -1,19 +1,23 @@
+ include ../Makefile.inc
+ 
++LIBNAME = libmpathcmd
+ SONAME = 0
+-DEVLIB = libmpathcmd.so
++DEVLIB = $(LIBNAME).so
+ LIBS = $(DEVLIB).$(SONAME)
+ 
+ CFLAGS += $(LIB_CFLAGS)
+ 
+ OBJS = mpath_cmd.o
+ 
+-all: $(LIBS)
++all: $(LIBS) $(LIBNAME).a
+ 
+ $(LIBS): $(OBJS)
+       $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ -o $@ $(OBJS) $(LIBDEPS)
+       $(LN) $@ $(DEVLIB)
+ 
++$(LIBNAME).a: $(OBJS) $(LIBDEPS)
++      $(AR) $(ARFLAGS) $@ $^
++
+ install: $(LIBS)
+       $(INSTALL_PROGRAM) -d $(DESTDIR)$(syslibdir)
+       $(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(syslibdir)/$(LIBS)
+diff --git a/libmpathpersist/Makefile b/libmpathpersist/Makefile
+index 21fdad8..647176f 100644
+--- a/libmpathpersist/Makefile
++++ b/libmpathpersist/Makefile
+@@ -6,7 +6,7 @@ LIBS = $(DEVLIB).$(SONAME)
+ 
+ CFLAGS += $(LIB_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) 
-I$(mpathcmddir)
+ 
+-LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath \
++LIBDEPS += -lm -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath \
+          -L$(mpathcmddir) -lmpathcmd
+ 
+ OBJS = mpath_persist.o mpath_updatepr.o mpath_pr_ioctl.o
+diff --git a/libmultipath/Makefile b/libmultipath/Makefile
+index becaef3..5d3a09c 100644
+--- a/libmultipath/Makefile
++++ b/libmultipath/Makefile
+@@ -3,13 +3,14 @@
+ #
+ include ../Makefile.inc
+ 
++LIBNAME = libmultipath
+ SONAME = 0
+-DEVLIB = libmultipath.so
++DEVLIB = $(LIBNAME).so
+ LIBS = $(DEVLIB).$(SONAME)
+ 
+ CFLAGS += $(LIB_CFLAGS) -I$(mpathcmddir) -I$(mpathpersistdir) -I$(nvmedir)
+ 
+-LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd 
-lurcu -laio
++LIBDEPS += -lm -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd 
-lurcu -laio
+ 
+ ifdef SYSTEMD
+       CFLAGS += -DUSE_SYSTEMD=$(SYSTEMD)
+@@ -45,7 +46,7 @@ OBJS = memory.o parser.o vector.o devmapper.o callout.o \
+       lock.o file.o wwids.o prioritizers/alua_rtpg.o prkey.o \
+       io_err_stat.o dm-generic.o generic.o foreign.o nvme-lib.o
+ 
+-all: $(LIBS)
++all: $(LIBS) $(LIBNAME).a
+ 
+ nvme-lib.o: nvme-lib.c nvme-ioctl.c nvme-ioctl.h
+       $(CC) $(CFLAGS) -Wno-unused-function -c -o $@ $<
+@@ -62,6 +63,9 @@ $(LIBS): $(OBJS)
+       $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ -o $@ $(OBJS) $(LIBDEPS)
+       $(LN) $@ $(DEVLIB)
+ 
++$(LIBNAME).a: $(OBJS)
++      $(AR) $(ARFLAGS) $@ $^
++
+ install:
+       $(INSTALL_PROGRAM) -d $(DESTDIR)$(syslibdir)
+       $(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(syslibdir)/$(LIBS)
+diff --git a/libmultipath/log.c b/libmultipath/log.c
+index debd36d..03d54b5 100644
+--- a/libmultipath/log.c
++++ b/libmultipath/log.c
+@@ -91,7 +91,7 @@ void free_logarea (void)
+       return;
+ }
+ 
+-void log_close (void)
++void mpt_log_close (void)
+ {
+       free_logarea();
+       closelog();
+diff --git a/libmultipath/log.h b/libmultipath/log.h
+index 6551b5c..f0ed15c 100644
+--- a/libmultipath/log.h
++++ b/libmultipath/log.h
+@@ -32,7 +32,7 @@ struct logarea {
+ extern struct logarea* la;
+ 
+ int log_init (char * progname, int size);
+-void log_close (void);
++void mpt_log_close (void);
+ void log_reset (char * progname);
+ int log_enqueue (int prio, const char * fmt, va_list ap);
+ int log_dequeue (void *);
+diff --git a/libmultipath/log_pthread.c b/libmultipath/log_pthread.c
+index be57bb1..10f7228 100644
+--- a/libmultipath/log_pthread.c
++++ b/libmultipath/log_pthread.c
+@@ -131,5 +131,5 @@ void log_thread_stop (void)
+       pthread_mutex_destroy(&logev_lock);
+       pthread_cond_destroy(&logev_cond);
+ 
+-      log_close();
++      mpt_log_close();
+ }
+diff --git a/multipath/Makefile b/multipath/Makefile
+index 0828a8f..8bd6ce4 100644
+--- a/multipath/Makefile
++++ b/multipath/Makefile
+@@ -6,7 +6,7 @@ include ../Makefile.inc
+ CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir)
+ LDFLAGS += $(BIN_LDFLAGS)
+ LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathcmddir) -lmpathcmd \
+-      -lpthread -ldevmapper -ldl -ludev
++      -lpthread -ldevmapper -laio -ldl -ludev -lm
+ 
+ EXEC = multipath
+ 

Reply via email to