# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>

pkgname=stuntrally-data
_pkgname=stuntrally
pkgver=2.5
pkgrel=2
pkgdesc="Stunt Rally game with track editor, based on VDrift (data files)"
arch=('any')
license=('GPL3')
url="http://code.google.com/p/vdrift-ogre"
makedepends=('cmake' 'boost' 'libvorbis' 'mygui' 'sdl2' 'enet' 'hicolor-icon-theme' 'libxcursor')
source=("$pkgname-$pkgver.tar.gz::https://github.com/stuntrally/stuntrally/archive/${pkgver}.tar.gz"
        "$pkgname-tracks-$pkgver.tar.gz::https://github.com/stuntrally/tracks/archive/${pkgver}.tar.gz")
sha256sums=('31e565c531b57895745b2dd5ecd1a2f241b1ac415d984d038390a49398974b23'
            '16b3e5d68eaffb8921b46066dde39208337c3142b2e1db5e6431a1bf867461ed')

build() {
  # build the sources
  cd "${srcdir}/stuntrally-${pkgver}/"

  rm -rf build
  mkdir build && cd build

  cmake .. \
      -DCMAKE_INSTALL_PREFIX="/usr" \
      -DSHARE_INSTALL="share/stuntrally"
  make

  # build the tracks
  cd "${srcdir}/tracks-${pkgver}/"

  rm -rf build
  mkdir build && cd build

  cmake .. \
      -DCMAKE_INSTALL_PREFIX="/usr"
  make
}

package() {
  # install the sources
  cd "${srcdir}/stuntrally-${pkgver}/build/"
  make DESTDIR="${pkgdir}" install

  # install the tracks
  cd "${srcdir}/tracks-${pkgver}/build"
  make DESTDIR="${pkgdir}/usr/share/stuntrally/" install

  # clean up
  rm -rf "${pkgdir}/usr/share/stuntrally/tracks/build"
  rm -rf "${pkgdir}/usr/share/icons"
  rm -rf "${pkgdir}/usr/share/applications"
  rm -rf "${pkgdir}/usr/include"
  rm -rf "${pkgdir}/usr/bin"
}
