# Template file for 'libarchive'
pkgname=libarchive
version=3.7.7
revision=1
bootstrap=yes
build_style=gnu-configure
configure_args="$(vopt_enable acl) $(vopt_enable acl xattr)
 $(vopt_with expat) $(vopt_with lzo lzo2) $(vopt_with lz4)
 $(vopt_with ssl openssl) $(vopt_with zstd) --without-xml2
 --without-libb2 --without-nettle --disable-rpath"
hostmakedepends="pkgconf"
makedepends="zlib-devel bzip2-devel liblzma-devel
 $(vopt_if acl acl-devel) $(vopt_if expat expat-devel) $(vopt_if zstd libzstd-devel)
 $(vopt_if lzo lzo-devel) $(vopt_if lz4 liblz4-devel) $(vopt_if ssl openssl-devel)"
short_desc="Library to read/write several different streaming archive formats"
maintainer="Orphaned <orphan@voidlinux.org>"
license="BSD-2-Clause"
homepage="https://www.libarchive.org/"
changelog="https://github.com/libarchive/libarchive/releases"
distfiles="https://github.com/libarchive/libarchive/releases/download/v${version}/libarchive-${version}.tar.xz"
checksum=879acd83c3399c7caaee73fe5f7418e06087ab2aaf40af3e99b9e29beb29faee

build_options="acl expat lzo lz4 ssl zstd"
build_options_default="acl ssl lz4 zstd"

pre_configure() {
	export LIBS=-pthread
}

do_check() {
	case "$XBPS_TARGET_LIBC" in
		*musl)
			make check ${makejobs} ||
				msg_warn "Tests can fail due to encoding conversions\n"
			;;
		*)
			make check ${makejobs}
			;;
	esac
}

post_install() {
	vlicense COPYING
}

bsdtar_package() {
	replaces="bsdcpio>=0"
	short_desc="BSD utilities using libarchive"
	pkg_install() {
		vmove usr/bin
		vmove usr/share/man/man1
		vmove usr/share/man/man5
		# Conflicts with mtree.
		mv ${PKGDESTDIR}/usr/share/man/man5/{mtree.5,libarchive-mtree.5}
	}
}

bsdunzip_package() {
	reverts="20160115_1 20160115_2"
	build_style="meta"
	short_desc="BSD utilities using libarchive (transitional dummy package)"
	depends="bsdtar>=${version}_${revision}"
}

libarchive-devel_package() {
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
		vmove usr/lib/pkgconfig
		vmove usr/share
	}
}
