modules-$(CONFIG_CRYPTSETUP2) += cryptsetup2

cryptsetup2_depends := util-linux popt lvm2 json-c $(musl_dep)

cryptsetup2_version := 2.6.1
cryptsetup2_dir := cryptsetup-$(cryptsetup2_version)
cryptsetup2_tar := cryptsetup-$(cryptsetup2_version).tar.xz
cryptsetup2_url := https://www.kernel.org/pub/linux/utils/cryptsetup/v2.6/cryptsetup-$(cryptsetup2_version).tar.xz
cryptsetup2_hash := 410ded65a1072ab9c8e41added37b9729c087fef4d2db02bb4ef529ad6da4693

# Use an empty prefix so that the executables will not include the
# build path.
cryptsetup2_configure := \
	$(CROSS_TOOLS) \
	CFLAGS="-Os" \
	./configure \
	--host $(MUSL_ARCH)-elf-linux \
	--prefix "/" \
	--enable-internal-sse-argon2 \
	--disable-rpath \
	--disable-gcrypt-pbkdf2 \
	--disable-ssh-token \
	--disable-asciidoc \
	--disable-nls \
	--disable-selinux \
	--disable-udev \
	--disable-external-tokens \
	--with-crypto_backend=kernel \
	--with-tmpfilesdir=$(INSTALL)/lib/tmpfiles.d

# but after building, replace prefix so that they will be installed
# in the correct directory.
cryptsetup2_target := \
	$(MAKE_JOBS) \
	&& $(MAKE) \
		-C $(build)/$(cryptsetup2_dir) \
		prefix="$(INSTALL)" \
		install

cryptsetup2_output := \
	.libs/cryptsetup \
	.libs/veritysetup \

cryptsetup2_libraries := \
	.libs/libcryptsetup.so.12 \