# Maintainer: Andreas Grapentin <andreas@grapentin.org>
# Maintainer (AUR): Vaporeon <vaporeon@vaporeon.io>
# Contributor: Márcio Silva <coadde@hyperbola.info>
# Contributor (AUR): casa <sympho08@yandex.ru>

pkgbase=mednaffe
pkgname=('mednaffe' 'mednaffe-gtk2')
pkgver=0.8.6
pkgrel=1
arch=('i686' 'x86_64')
url="https://github.com/AmatCoder/mednaffe"
license=('GPL')
makedepends=('mednafen' 'gtk2' 'gtk3')
install=mednaffe.install
source=(https://github.com/AmatCoder/mednaffe/releases/download/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('cda5e3ae42b696b4322dc89a3a46e4b9da4a4b36c48be454d0e591c284927420')

prepare() {
  cd "$srcdir"/$pkgbase-$pkgver

  mkdir build-gtk2
  cd build-gtk2
  ../configure --prefix=/usr
  cd ..

  mkdir build-gtk3
  cd build-gtk3
  ../configure --prefix=/usr --enable-gtk3
  cd ..
}

build() {
  cd "$srcdir"/$pkgbase-$pkgver/build-gtk2
  make

  cd "$srcdir"/$pkgbase-$pkgver/build-gtk3
  make
}

package_mednaffe() {
  pkgdesc="front-end (GUI) for mednafen emulator"
  depends=('mednafen' 'gtk3')

  cd "$srcdir"/$pkgbase-$pkgver/build-gtk3

  make prefix="$pkgdir"/usr install
}

package_mednaffe-gtk2() {
  pkgdesc="front-end (GUI) for mednafen emulator (GTK2 Version)"
  depends=('mednafen' 'gtk2')
  provides=('mednaffe')
  conflicts=('mednaffe')

  cd "$srcdir"/$pkgbase-$pkgver/build-gtk2

  make prefix="$pkgdir"/usr install
}