# Template file for 'ccextractor'
pkgname=ccextractor
version=0.96.6
revision=2
build_wrksrc="linux"
build_style=gnu-configure
build_helper=rust
configure_args="--enable-ocr --enable-hardsubx"
hostmakedepends="automake cargo clang pkg-config tesseract-ocr-devel"
makedepends="ffmpeg6-devel freetype-devel leptonica-devel libgpac-devel
 libpng-devel libutf8proc-devel rust-std tesseract-ocr-devel zlib-devel"
short_desc="Extract subtitles from video streams"
maintainer="newbluemoon <blaumolch@mailbox.org>"
license="GPL-2.0-or-later"
homepage="https://www.ccextractor.org/"
changelog="https://raw.githubusercontent.com/CCExtractor/ccextractor/master/docs/CHANGES.TXT"
distfiles="https://github.com/CCExtractor/${pkgname}/archive/v${version}.tar.gz"
checksum=d2bda9d2071ccf7a81a43c10e82ec00899b2a25b391c300e965274f92ad46208
CFLAGS="-DPNG_POWERPC_VSX_OPT=0"

pre_configure() {
	vsed -i configure.ac -e "s;tesseract --version;tesseract-ocr --version;g"
	vsed -i Makefile.am -e "s;@@XBPS_CROSS_BASE@@;${XBPS_CROSS_BASE};g"

	# in cross builds the path to the rust output is prefixed with the cross triplet,
	# make the linker find it
	if [ "$CROSS_BUILD" ]; then
		vsed -i Makefile.am -e "s;@RUST_TARGET_SUBDIR@;${XBPS_CROSS_RUST_TARGET}/&;g"
	fi

	./autogen.sh
}

post_install() {
	vinstall ../docs/ccextractor.cnf.sample 644 usr/share/examples/ccextractor
}
