# Template file for 'ffms2'
pkgname=ffms2
version=2.40
revision=1
build_style=gnu-configure
configure_args="--enable-shared --disable-static"
hostmakedepends="pkg-config autoconf automake libtool"
makedepends="ffmpeg-devel zlib-devel"
short_desc="Libav/ffmpeg based frames server"
maintainer="DirectorX <void.directorx@protonmail.com>"
license="MIT, GPL-3.0-or-later"
homepage="https://github.com/FFMS/ffms2"
distfiles="${homepage}/archive/${version}.tar.gz"
checksum=82e95662946f3d6e1b529eadbd72bed196adfbc41368b2d50493efce6e716320

if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
	makedepends+=" libatomic-devel"
	LDFLAGS="-latomic"
fi

pre_configure() {
	mkdir -p src/config
	autoreconf -vfi
}

post_install() {
	vmkdir usr/lib/vapoursynth
	pushd "$DESTDIR/usr/lib/vapoursynth"
	ln -sr $(ls ../libffms2.so.*.* | head -1) libffms2.so
	popd
	vlicense COPYING
}

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

libffms2_package() {
	short_desc+=" - runtime library"
	pkg_install() {
		vmove "usr/lib/*.so.*"
	}
}

vapoursynth-ffms2-source_package() {
	short_desc+=" - vapoursynth plugin"
	depends="libffms2>=${version}_${revision}"
	pkg_install() {
		vmove usr/lib/vapoursynth
	}
}
