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

# source: BLFS 7.5 updated 6-17-2018
TARBALL=MPlayer-$PKGVER.tar.xz
MD5SUM=e8a4d77ad4f509e81dd5e13b51636c1d
SRC_URL=http://www.mplayerhq.hu/MPlayer/releases/$TARBALL
BUNDLE=

SKINS_TARBALL=Clearlooks-2.0.tar.bz2
SKINS_MD5SUM=c82d4dbd7f0c36dfecd63dff972807c5
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 libopenjpeg2 libmad \
libspeex libtheora liba52 libfaac libxvidcore libvpx lame twolame \
libopencore-amr libx264 libx265 libschroedinger libfaad2 \
fontconfig freetype2 libfribidi unrar libvdpau' # 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-vdpau \
    --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
}
