# Maintainer (Arch): Anton Shestakov <engored*ya.ru>

pkgname=supermodel
pkgver=0.2a
pkgrel=2
pkgdesc='A Sega Model 3 Arcade Emulator'
arch=('i686' 'x86_64')
url='http://www.supermodel3.com/'
license=('GPL3')
depends=('mesa' 'glu' 'sdl' 'zlib')
install=supermodel.install
options=(!buildflags)
source=('multiuser.patch' 'supermodel.sh'
        "http://www.supermodel3.com/Files/Supermodel_${pkgver}_Src.zip")
sha256sums=('d8bb5c2ac4493406aefd12f2600034d1f58378cbfc82d8b3822d7f7b423bd8db'
            'b7afd56a1a33bb1d231a3d6274f2e00a6b41a7d5197101e1a6f3f7d0c5c4c5a4'
            'ecaf3e7fc466593e02cbf824b722587d295a7189654acb8206ce433dcff5497b')

build() {
  cd "$srcdir/Supermodel_${pkgver}_Src"

  CFLAGS="$CFLAGS -Wno-narrowing"
  sed -i "s#-Wall -O3#$CFLAGS#" 'Makefiles/Makefile.SDL.UNIX.GCC'
  patch -p1 < ../multiuser.patch
  make -j1 -f 'Makefiles/Makefile.SDL.UNIX.GCC'
}

package() {
  cd "$srcdir/Supermodel_${pkgver}_Src"

  install -Dm755 "$srcdir/supermodel.sh" "$pkgdir/usr/bin/supermodel"

  install -Dm755 "bin/Supermodel" "$pkgdir/usr/share/supermodel/Supermodel"

  install -Dm644 "Docs/LICENSE.txt" "$pkgdir/usr/share/licenses/supermodel/LICENSE"
  install -Dm644 "Docs/README.txt" "$pkgdir/usr/share/doc/supermodel/README"

  install -d "$pkgdir/usr/share/supermodel/Config"
  install -m644 Config/* "$pkgdir/usr/share/supermodel/Config/"
}
