# SliTaz package receipt.

PACKAGE="mplayerplug-in"
VERSION="3.55"
CATEGORY="multimedia"
SHORT_DESC="a browser plugin that uses mplayer to play videos from websites"
MAINTAINER="jozee@slitaz.org"
DEPENDS="mplayer xorg-libXpm gtk+ gcc-lib-base"
BUILD_DEPENDS="mplayer gtk+-dev xorg-libXpm-dev firefox-dev libIDL gettext"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WEB_SITE="http://mplayerplug-in.sourceforge.net/" 
WGET_URL="http://downloads.sourceforge.net/mplayerplug-in/$TARBALL"
TAGS="player audio video browser"

get_firefox_version()
{
	FIREFOX_VER=`cat $1/var/lib/tazpkg/installed/firefox/receipt | \
			grep VERSION= | cut -d \" -f 2`
}

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	sed -i 's/npupp\.h/npfunctions.h/' */np*
	sed -i 's|char [\* ]*NP*_GetMIMEDescription(|const &|' \
		plugingate/np_entry.cpp Source/plugin.cpp
	cp $stuff/slitaz-hack.h include
	grep -q slitaz-hack include/npplat.h || sed -i \
		's/ne _NPPLAT_H_/ne _NPPLAT_H_\n#include "slitaz-hack.h"/' \
		include/npplat.h
	while read file; do
		[ -f done.$file ] && continue
		echo "Apply $file..."
		patch -p1 < $stuff/$PACKAGE-$VERSION-$file || return 1
		touch done.$file
	done <<EOT
glibc210.u
static-iid-accessor.u
EOT
	make distclean
	touch install.sh
	get_firefox_version
	./configure --prefix=/usr --sysconfdir=/etc \
		--enable-x \
		--enable-wmp \
		--enable-qt \
		--enable-rm \
		--enable-dvx \
		GECKO_XPIDL="$stuff/xpidl" \
		MOZILLA_HOME="/usr/lib/firefox-$FIREFOX_VER" \
		GECKO_IDLDIR="/usr/share/idl/firefox-$FIREFOX_VER" &&
	make $MAKEFLAGS &&
	make DESTDIR=$DESTDIR install
}

genpkg_rules()
{
	mkdir -p $fs/usr/lib
	cp -a $_pkg/etc $fs
	cp -a $_pkg/usr/lib/mozilla $fs/usr/lib		
	# change the default video output to xv,x11
	sed -i "s/#vo=xv,x11/vo=xv,x11/" $fs/etc/$PACKAGE.conf
	      
}

post_install()
{
	echo -n "Processing post install commands..."
	local root
	root=$1
	get_firefox_version $1
	for i in $root/usr/lib/mozilla/plugins/$PACKAGE*.so ; do
		ln -s $i $root/usr/lib/firefox-$FIREFOX_VER/plugins
	done 
	status
}

post_remove()
{
	echo -n "Processing post remove commands..."
	rm -f /usr/lib/firefox*/plugins/$PACKAGE*.so
	status
}