modules-$(CONFIG_LVM2) += lvm2

lvm2_version := 2.03.23
lvm2_dir := lvm2.$(lvm2_version)
lvm2_tar := LVM2.$(lvm2_version).tgz
lvm2_url := https://mirrors.kernel.org/sourceware/lvm2/$(lvm2_tar)
lvm2_hash := 74e794a9e9dee1bcf8a2065f65b9196c44fdf321e22d63b98ed7de8c9aa17a5d

# cross compiling test assumes malloc/realloc aren't glibc compat
# so we force it via the configure cache.
lvm2_configure := \
	$(CROSS_TOOLS) \
	ac_cv_func_malloc_0_nonnull=yes \
	ac_cv_func_realloc_0_nonnull=yes \
	./configure \
	--host $(MUSL_ARCH)-elf-linux \
	--prefix "" \
	--libexecdir "/bin" \
	--with-optimisation=-Os \
	--enable-devmapper \
	--disable-selinux \
	--without-systemd \
	--disable-lvmimportvdo \
	--disable-realtime \
	--disable-dmfilemapd \
	--disable-dmeventd \
	--disable-lvmpolld \
	--disable-readline \
	--disable-udev_sync \
	--enable-static_link \
	--disable-use-lvmlockd \
	--disable-use-lvmpolld \
	--disable-dmfilemapd \
	--disable-cmirrord \
	--disable-cache_check_needs_check \
	--disable-thin_check_needs_check \
	--with-cluster=none \
	--with-thin-check= \

# not sure why LIB_SUFFIX is not defined in the cross build
lvm2_target := \
	$(MAKE_JOBS) \
	$(CROSS_TOOLS) \
	DESTDIR="$(INSTALL)" \
	all \
	&& \
	$(MAKE) \
	-C "$(build)/$(lvm2_dir)" \
	$(MAKE_JOBS) \
	$(CROSS_TOOLS) \
	DESTDIR="$(INSTALL)" \
	install_device-mapper \

lvm2_libraries := libdm/ioctl/libdevmapper.so.1.02

lvm2_output := \
	./libdm/dm-tools/dmsetup \
	tools/lvm \

lvm2_depends := util-linux libaio $(musl_dep)