# Description:  Versatile media player and encoder/converter
# URL:          http://www.mplayerhq.hu/
# Maintainer:   Erich Eckner, erich at eckner dot net
# Packager:     Matt Housh, jaeger at morpheus dot net
# Depends on:   expat, freetype, xorg-libxinerama, xorg-libxv, xorg-libxxf86dga, xorg-libxxf86vm, yasm
# Nice to have: libsdl, libjpeg-turbo, libpng, lame, zlib, libogg, libvorbis, cdparanoia, win32-essential-codecs, faac, x264, libdvdnav, libdca

name=mplayer
version=2016-02-17
release=1
source=(http://crux.nu/~tek/mplayer-$version.tar.xz
  http://www1.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2 mplayer.conf)

build() {
  cd mplayer-$version

  # Keep in line with mplayer CFLAGS, but allow people to set their own march/mtune values.
  export CFLAGS="$(echo $CFLAGS | sed -e 's/-O[s0-3]/-O3/') -ffast-math -fomit-frame-pointer -fno-strict-aliasing"

  rm -f ffmpeg/mp_auto_pull

  ./configure --prefix=/usr \
      --mandir=/usr/share/man \
      --codecsdir=/usr/share/codecs \
      --confdir=/etc/mplayer
  make
  make DESTDIR=$PKG install

  (cd $PKG/usr/share/man/man1; rm mencoder.1; ln -s mplayer.1.gz mencoder.1.gz)

  # fonts
  mkdir -p $PKG/usr/share/mplayer
  cp -a $SRC/font-arial-iso-8859-1/font-arial-??-iso-8859-1 \
    $PKG/usr/share/mplayer
  ln -s font-arial-14-iso-8859-1 $PKG/usr/share/mplayer/font

  # config
  mkdir -p $PKG/etc/mplayer
  install -m 644 $SRC/mplayer.conf $PKG/etc/mplayer/
  install -m 644 etc/input.conf $PKG/etc/mplayer/

  # finish up
  rmdir $PKG/usr/lib
  find $PKG -name '*.desc' | xargs chmod g-w
}