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

pkgname=raine-git
pkgver=2887.cf1e6af5
pkgrel=1
pkgdesc="A multiple arcade emulator focused on 680x0 machines like NeoCD and Neo Geo"
url="http://raine.1emulation.com/"
license=('custom')
arch=('x86_64')
replaces=('neoraine')
depends=('sdl2_ttf' 'sdl2_image' 'muparser' 'glu' 'mpg123' 'lua')
makedepends=('mesa' 'git')
optdepends=('raine-emudx: improved graphic and sound files for some classic games'
            'arcade-history-dat: database with various information about the loaded rom'
            'arcade-command-dat: database with button combinations for special moves in (mostly fighting) games')
source=(git+https://github.com/zelurker/raine)
sha256sums=('SKIP')
options=('emptydirs' '!buildflags')
provides=('raine')
conflicts=('raine')

pkgver() {
  cd "$srcdir/raine"
  printf "%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$srcdir"
  mkdir -p raine-bin
  cd "$srcdir/raine"
  git submodule update --init --recursive
  # 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
  sed -i 's|install_dirs $(RAINE_LNG)|install_dirs|g' makefile
}

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

package() {
  cd "$srcdir"/raine
  make NO_ASM=1 DESTDIR="$pkgdir" install VERBOSE=1
  # 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
}
