# Maintainer: carstene1ns <arch carsten-teibes de> - http://git.io/ctPKG
# Contributor: trya <tryagainprod@gmail.com>
# Contributor: robb_force <robb_force@holybuffalo.net>

pkgname=raine
pkgver=0.97.6b
pkgrel=1
pkgdesc="A multiple arcade emulator focused on 680x0 machines like NeoCD and Neo Geo"
url="http://raine.1emulation.com/"
license=('custom')
arch=('i686' 'x86_64')
replaces=('neoraine','raine64')
depends_i686=('sdl2' 'sdl2_ttf' 'sdl2_image' 'libcurl' 'openssl' 'lua')
depends_x86_64=('lib32-sdl2' 'lib32-sdl2_ttf' 'lib32-sdl2_image'
'lib32-curl' 'lib32-openssl' 'lib32-lua')
makedepends=('nasm' 'mesa')
makedepends_x86_64=('gcc-multilib')
optdepends=('raine-emudx: improved graphic and sound files for some classic games'
            'raine-blend: transparency information for some games')
source=(raine-$pkgver.tar.gz::"https://github.com/zelurker/raine/archive/$pkgver.tar.gz")
sha256sums=('dda881f9687778035102a3420dd5eebc4ef55e2f5ee03f6199d39e45a8367635')
options=('emptydirs')

prepare() {
  cd "$srcdir"
  mkdir -p raine-bin

  cd raine-$pkgver

  # adapt folder structure to arch standards
  sed 's|$(prefix)/games|\$(prefix)/bin|;s|$(prefix)/share/games|\$(prefix)/share|' -i makefile
  sed 's|share/games/raine|share/raine|' -i source/sdl/dialogs/about.cpp source/raine.c
}

build() {
  make -C "$srcdir"/raine-$pkgver #VERBOSE=1
}

package() {
  cd "$srcdir"/raine-$pkgver
  make DESTDIR="$pkgdir" install
  # doc + license
  install -d "$pkgdir"/usr/share/{doc,licenses}/raine
  install -m644 docs/* changes/* "$pkgdir"/usr/share/doc/raine
  head -n5 source/raine.c > "$pkgdir"/usr/share/licenses/raine/LICENSE
}
