# Maintainer: Alexander F Rødseth <xyproto@archlinux.org>
# Contributor: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: jlvsimoes <jlvsimoes@oninet.pt>
# Contributor: kevin <kevin@archlinux.org>

pkgname=abuse
pkgver=0.8
pkgrel=9
pkgdesc='Side-scroller action game that pits you against ruthless alien killers'
arch=('x86_64')
url='http://abuse.zoy.org/'
license=('GPL' 'custom')
depends=('desktop-file-utils' 'gcc-libs' 'glu' 'libgl' 'sdl_mixer')
makedepends=('gendesk' 'glu' 'mesa-libgl')
source=("http://abuse.zoy.org/raw-attachment/wiki/download/$pkgname-$pkgver.tar.gz"
        'abuse.sh'
        'default.abuserc'
        'default.gamma.lsp')
sha256sums=('0104db5fd2695c9518583783f7aaa7e5c0355e27c5a803840a05aef97f9d3488'
            '8dcf3b6b6ac419e5ffabc847166917d70ce43af3092c4d651f473947fff0cc7d'
            '6ea2fa9e65c10bbcab4432f40d0c7284cb3970835c40c5c00ced14b39ce1b00f'
            '13df83fea60918d29d5141cdfbd8d56147c053e88d3701209ae676f46447c2f6')

prepare() {
  cd "abuse-$pkgver"

  gendesk -f -n --pkgname "$pkgname" --pkgdesc "$pkgdesc"
}

build() {
  cd "abuse-$pkgver"

  ./configure \
    --prefix=/usr \
    --with-assetdir="/usr/share/$pkgname/orig" \
    --with-x \
    --enable-debug # Fix for FS#52915
  make
}

package() {
  cd "abuse-$pkgver"

  make DESTDIR="$pkgdir" install

  # Desktop shortcut and icon
  install -Dm644 "$pkgname.desktop" \
    "$pkgdir/usr/share/applications/$pkgname.desktop"
  install -Dm644 "doc/$pkgname.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"

  # Default configuration
  mv "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/bin/$pkgname.elf"
  install -Dm755 "$srcdir/$pkgname.sh" "$pkgdir/usr/bin/$pkgname"
  install -Dm644 "$srcdir/default.${pkgname}rc" \
    "$pkgdir/usr/share/$pkgname/default.${pkgname}rc"
  install -Dm644 "$srcdir/default.gamma.lsp" \
    "$pkgdir/usr/share/$pkgname/default.gamma.lsp"

  # License (for the original source code)
  install -d "$pkgdir/usr/share/licenses/abuse"
  sed -n '1,/^$/p' src/view.cpp > "$pkgdir/usr/share/licenses/abuse/original"
}

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