description="The Versatile Commodore 8-bit Emulator"
url="http://vice-emu.sourceforge.net/"
packager="tnut <tnut@nutyx.org>"
contributors="Greg"

name=vice
version=3.2
release=2
makedepends=(gtkglext pulseaudio giflib xorg-bdftopcf
             xorg-mkfontscale libpcap xorg-libxaw ffmpeg xa)

source=(http://downloads.sourceforge.net/project/vice-emu/releases/$name-$version.tar.gz 
        disable-fc-cache.patch)

prepare(){
  cd ${name}-${version}
  rm -rf src/lib/{liblame,libx264,libffmpeg}

  patch -p1 -i "$SRC/disable-fc-cache.patch"
  sed -i 's/lib64/lib/g' configure.ac
  autoreconf -fiv

  sed -e 's|CODEC_CAP_VARIABLE_FRAME_SIZE|AV_&|g' -e 's|CODEC_FLAG_GLOBAL_HEADER|AV_&|g' -e 's|\& AVFMT_RAWPICTURE||' \
    -i src/gfxoutputdrv/ffmpegdrv.c # Fix build with ffmpeg 4
}

build() {
  cd ${name}-${version}

  ./configure --prefix=/usr \
    --libdir=/usr/lib \
    --enable-gnomeui \
    --enable-external-ffmpeg
  make
  make DESTDIR="${PKG}" realdocdir="/usr/share/doc/vice" install -j1
  ln -s /usr/share/doc/vice "${PKG}/usr/lib/vice/doc"
}
