# SliTaz package receipt.

PACKAGE="mplayer-opt"
VERSION="1.1.1"
CATEGORY="multimedia"
SHORT_DESC="The Ultimate Movie Player For Linux (with CPU optimizations)"
MAINTAINER="pankso@slitaz.org"
LICENSE="GPL2"
SOURCE="MPlayer"
TARBALL="$SOURCE-$VERSION.tar.xz"
WEB_SITE="http://www.mplayerhq.hu/design7/news.html"
WGET_URL="http://www1.mplayerhq.hu/MPlayer/releases/$TARBALL"
HOST_ARCH="i486 arm"

# Dont forget to update all related pkgs
RELATED="mplayer-codecs mencoder" 
DEPENDS="gtk+ cdparanoia-III libmad xorg-libXv alsa-lib ncurses lame \
xorg-libXdamage giflib enca xorg-libXxf86vm esound libmng audiofile \
libogg zlib xorg-libXss"
BUILD_DEPENDS="gtk+-dev libmad-dev xorg-libXv-dev alsa-lib-dev \
ncurses-dev lame-dev xorg-libXdamage-dev giflib-dev xorg-libXxf86vm-dev \
audiofile-dev libogg-dev zlib-dev \
xorg-xextproto pkg-config yasm"

# Handle arch package install. Less deps and no GTK gui for ARM
case "$SLITAZ_ARCH" in
	arm*) 
		DEPENDS="alsa-lib zlib libmad xorg-libXv xorg-libXxf86vm libogg \
		libvorbis libtheora libsdl xvidcore lame esound gtk+" ;;
esac

# Handle cross compilation. Host coreutils-file-* are used
case "$ARCH" in
	i?86) 
		ARCH_ARGS="--target=i486-linux --disable-sdl" 
		BUILD_DEPENDS="$BUILD_DEPENDS libmng-dev" ;;
	arm*) 
		BUILD_DEPENDS="$BUILD_DEPENDS libsdl-dev" 
		ARCH_ARGS="--target=arm-linux --enable-cross-compile --enable-sdl" ;;
esac

# Rules to configure and make the package.
compile_rules()
{
	# just remove next configure options:
	# --disable-mmx --disable-mmxext --disable-3dnow --disable-3dnowext
	# --disable-sse --disable-sse2 --disable-ssse3
	./configure \
		--prefix=/usr \
		--confdir=/etc/mplayer \
		--libdir=/usr/lib/mplayer \
		--enable-gui \
		--language="en ru" \
		--enable-runtime-cpudetection \
		--disable-mencoder \
		--disable-gl \
		--disable-jack \
		--disable-liblzo \
		--disable-libdv \
		--disable-fribidi \
		--disable-ivtv \
		--disable-smb \
		--disable-ftp \
		--disable-openal \
		--disable-faac \
		--disable-speex \
		--disable-cdparanoia --disable-pvr --disable-enca \
		--disable-maemo --disable-lirc --disable-lircc \
		--disable-nemesi --disable-vstream --disable-live \
		--disable-ladspa --disable-libbs2b --disable-dvdnav \
		--disable-pulse --disable-esd --disable-vdpau \
		${ARCH_ARGS} &&
	make $MAKEFLAGS &&
	make DESTDIR=$DESTDIR install | sed '/install: strip: .*/'d
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/share/mplayer/skins
	cp -a $install/usr/bin $fs/usr
	# Mencoder goes in a splited package.
	rm $fs/usr/bin/mencoder
	[ -d "$install/usr/share/mplayer" ] && \
		cp -a $install/usr/share/mplayer $fs/usr/share
	cp -a $install/etc $fs
	cp $src/etc/example.conf $fs/etc/mplayer
	# Config to use Xv by default.
	cp $stuff/mplayer.conf $fs/etc/mplayer
	# default skin
	#tar xjf $stuff/productive-1.0.tar.bz2 -C $fs/usr/share/mplayer/skins
	#cd $fs/usr/share/mplayer/skins && ln -s productive default
	# Font
	cd .. && ln -s ../fonts/truetype/ttf-dejavu/DejaVuSans.ttf subfont.ttf
	# Xv support dont work for ARM and gmplayer symlink not created
	case "$ARCH" in
		arm*)
			cp -f $stuff/mplayer-arm.conf $fs/etc/mplayer/mplayer.conf 
			cd $fs/usr/bin && ln -s mplayer gmplayer ;;
	esac
}