# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: Laurent Carlier <lordheavym@gmail.com>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: Zephyr

pkgname=mupen64plus
pkgver=2.5
pkgrel=13
pkgdesc='Nintendo64 Emulator'
arch=('x86_64')
url='https://github.com/mupen64plus/mupen64plus-core'
license=('GPL')
depends=('glu' 'libsamplerate' 'libpng' 'sdl' 'freetype2' 'boost-libs')
makedepends=('mesa' 'boost')
source=("https://github.com/mupen64plus/mupen64plus-core/releases/download/2.5/mupen64plus-bundle-src-${pkgver}.tar.gz"
        'ui-console-pic.patch')
sha256sums=('9c75b9d826f2d24666175f723a97369b3a6ee159b307f7cc876bbb4facdbba66'
            'bb4784de177aaa4c0b4f5d07b14ae020f3b47e6aa524df65366ac00eb169ee8f')

prepare() {
  cd mupen64plus-bundle-src-$pkgver
  patch -p1 -i ../ui-console-pic.patch
}

build() {
  cd mupen64plus-bundle-src-${pkgver}

  if [[ $CARCH = 'i686' ]]; then
    export CFLAGS="${CFLAGS/-fno-plt/}"
    export CXXFLAGS="${CXXFLAGS/-fno-plt/}"
  fi

  sh m64p_build.sh
}

package() {
  cd mupen64plus-bundle-src-$pkgver
  
  # set LDCONFIG since we are using fakeroot and scripts run root commands by checking the uid
  ./m64p_install.sh DESTDIR="$pkgdir" PREFIX='/usr' MANDIR='/usr/share/man' LDCONFIG='true'
}

# vim: ts=2:sw=2:et
