### this file is sourced not run
PKGVER=1.2
PKGBUILD=1
PKGARCH=x86_64

# source: BLFS 7.5 updated to 1.2
TARBALL=MPlayer-$PKGVER.tar.xz
MD5SUM=58409fccb8ef33013fb780405405491f
SRC_URL=http://www.mplayerhq.hu/MPlayer/releases/$TARBALL
BUNDLE=

SKINS_TARBALL=Clearlooks-1.7.tar.bz2
SKINS_MD5SUM=833d82734deb8475a8c57e9c1b55bd86
SKINS_SRC=http://www.mplayerhq.hu/MPlayer/skins/$SKINS_TARBALL

SLACKREQ='ffmpeg gtk2 libdvdread libdvdnav libdvdcss librtmp \
alsa-lib libSDL libjack2 giflib libjpeg-turbo libpng libopenjpeg libmad \
libspeex libtheora liba52 libfaac libxvidcore libvpx lame twolame \
libopencore-amr libx264 libx265 libschroedinger libfaad2 \
fontconfig freetype2 libfribidi unrar' # ladspa, libgsm is compile-only
SLACKDESC="mplayer-static: mplayer-static $PKGVER (Media player)  
mplayer-static:  
mplayer-static: MPlayer is a powerful audio/video player controlled via the 
mplayer-static: command line or a graphical interface that is able to play 
mplayer-static: almost every popular audio and video file format. With 
mplayer-static: supported video hardware and additional drivers, MPlayer can 
mplayer-static: play video files without an X Window System installed. This is 
mplayer-static: the version that includes statically-linked ffmpeg, it does 
mplayer-static: not use system ffmpeg.  
mplayer-static: 
mplayer-static:
"
SLACKCON='mplayer'

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cp $CHROOT_DIR/tmp/pkg/ladspa.h usr/include &&
	cd tmp/MPlayer* &&
	sed -i 's:libsmbclient.h:samba-4.0/&:' configure stream/stream_smb.c && # support samba4
	
	SRC_URL=$SKINS_SRC && 
	pkg_check $SRC_DIR $SKINS_TARBALL $SKINS_MD5SUM	
}

### package
pkg_package() {
	mkdir -p usr/share/mplayer/skins &&
	tar -xvf $SRC_DIR/$SKINS_TARBALL \
		   -C usr/share/mplayer/skins &&
	ln -sfv Clearlooks usr/share/mplayer/skins/default &&
	rm -f usr/include/ladspa.h
}

### build
pkg_build() {
	cd /tmp/MPlayer*
	
	# BLFS 7.8 patch for libvpx 1.5.0
	sed -e '/UPD.*=/,/SET_SCA.*=/d' \
		-e '/SET_SHA.*=/d' \
		-e '/GET_LAS.*=/d' \
		-i ffmpeg/libavcodec/libvpxenc.c &&
	
	./configure --prefix=/usr --libdir=/usr/$LIBDIR \
    --confdir=/etc/mplayer   \
    --enable-dynamic-plugins \
    --enable-menu            \
    --enable-gui \
    --disable-ffmpeg_so \
    --enable-libgsm \
    --extra-cflags=-I/usr/include/openjpeg-1.5 \
    --enable-gif &&
    make $MAKEINSTALL && make install &&
	pkg_build_slackdesc &&
	install -v -m755 -d /usr/share/doc/mplayer-$PKGVER &&
	install -v -m644    DOCS/HTML/en/* \
						/usr/share/doc/mplayer-$PKGVER &&
	install -v -m644 etc/codecs.conf /etc/mplayer &&
	install -v -m644 etc/*.conf /etc/mplayer
}
