# Template file for 'handbrake'
pkgname=handbrake
version=1.3.0
revision=1
archs="i686* x86_64* ppc64*"
wrksrc="HandBrake-${version}"
build_style=gnu-configure
configure_args="--force --disable-gtk-update-checks
 $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
make_build_args="-C ${XBPS_TRIPLET}"
make_install_args="-C ${XBPS_TRIPLET}"
hostmakedepends="automake libtool cmake pkg-config python3 intltool
 nasm wget m4 gettext-devel glib-devel meson"
makedepends="zlib-devel bzip2-devel libnotify-devel gtk+3-devel ncurses-devel
 gst-plugins-base1-devel libgudev-devel x264-devel x265-devel dbus-glib-devel
 fribidi-devel libass-devel fontconfig-devel libxml2-devel libogg-devel
 libdvdnav-devel libdvdread-devel libtheora-devel lame-devel jansson-devel
 libsamplerate-devel libbluray-devel librsvg-devel libvpx-devel ffmpeg-devel
 opus-devel speex-devel atk-devel libnuma-devel $(vopt_if nvenc nv-codec-headers)
 $(vopt_if fdk_aac fdk-aac-devel)"
depends="gst-plugins-good1 desktop-file-utils hicolor-icon-theme"
short_desc="Multithreaded video transcoder"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="GPL-2.0-only"
homepage="https://handbrake.fr/"
distfiles="https://download2.handbrake.fr/${version}/HandBrake-${version}-source.tar.bz2"
checksum=a9a82eb5ca04a793705b3d7d11cefa29946694eeb13b40161446aaca35b31d96

build_options="fdk_aac nvenc"

case "$XBPS_TARGET_MACHINE" in
	x86_64*|i686*)
		CFLAGS="-msse"
		build_options_default="nvenc"
	;;
esac

pre_configure() {
	# use system libraries in place of bundled ones
	for module in ffmpeg libvpx libdvdread libdvdnav x265 fdk-aac; do
	    sed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
	done
}

pre_build() {
	unset AS LD
}

handbrake-cli_package() {
	short_desc+=" - CLI utility"
	pkg_install() {
		vmove usr/bin/HandBrakeCLI
	}
}
