#Maintainer: Thorsten Muehlfelder <thenktor(at)gmx.de>

pkgname=HandBrake
pkgver=0.9.5
pkgrel=1tm
source=("http://download.handbrake.fr/handbrake/release_files/HandBrake-$pkgver.tar.bz2" "A99-dvdread-aclocal-install.patch" "A99-dvdnav-aclocal-install.patch")
url="http://handbrake.fr/"

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (video transcoder)"
"HandBrake is an open-source, GPL-licensed, multiplatform,"
"multithreaded video transcoder. This package contains the Gtk+2"
"frontend."
)

build() {
	cd $startdir/src/HandBrake-$pkgver

	# at first add extra patches that remove hardcoded aclocal install path from libdvdread and libdvdnav
	cp ../A99-dvdread-aclocal-install.patch contrib/libdvdread || return 1
	cp ../A99-dvdnav-aclocal-install.patch contrib/libdvdnav || return 1

	CPU_ARCH=`arch`
	./configure --prefix=/usr \
		--arch=$CPU_ARCH \
		--optimize=speed \
		--force || return 1
	cd build
	make -j $numjobs || return 1
	make DESTDIR=$startdir/pkg/ install

	# icon
	mkdir -p $startdir/pkg/usr/share/icons/hicolor/48x48/apps/
	cp $startdir/pkg/usr/share/icons/hicolor/128x128/apps/hb-icon.png $startdir/pkg/usr/share/icons/hicolor/48x48/apps/
	mogrify -resize 48x48 $startdir/pkg/usr/share/icons/hicolor/48x48/apps/hb-icon.png || return 1

	# docs
	cd ..
	mkdir -p $startdir/pkg/usr/doc/$pkgname-$pkgver
	for DOCS in AUTHORS COPYING CREDITS NEWS THANKS TRANSLATIONS; do
		install -m644 $DOCS $startdir/pkg/usr/doc/$pkgname-$pkgver/
	done
}