# $Id: PKGBUILD 131187 2015-04-11 20:49:37Z svenstaro $
# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Jacobo Arvelo <unix4all@ya.com>
# Contributor: Douglas Soares de Andrade <douglas@archlinux.org>

pkgname=wesnoth-data
pkgver=1.12.2
pkgrel=1
pkgdesc="A turn-based strategy game on a fantasy world (data files)"
arch=('any')
license=('GPL')
url="http://www.wesnoth.org/"
makedepends=('boost' 'cmake' 'sdl_image' 'sdl_ttf' 'sdl_mixer' 'sdl_net' 'lua' 'pango' 'git')
options=(!emptydirs)
source=("git://github.com/wesnoth/wesnoth.git#tag=${pkgver}"
        "wesnoth-boost.patch")
md5sums=('SKIP'
         '9a4ad99ba66990bfc17cb12966b3823b')

build() {
  cd "${srcdir}/wesnoth"

  # Try this again in a new version when they fix their linking to boost
  patch -Np1 < ${srcdir}/wesnoth-boost.patch

  mkdir build && cd build
  cmake .. \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DENABLE_OMP=ON \
      -DENABLE_TOOLS=ON \
      -DMANDIR=share/man \
      -DFIFO_DIR=/var/run/wesnothd
  make
}

package() {
  cd "${srcdir}/wesnoth"

  cd build
  make DESTDIR="$pkgdir" install

  rm -r $pkgdir/usr/bin
  rm -r $pkgdir/usr/share/man

  for file in $(grep -l "python" $pkgdir/usr/share/wesnoth/data/tools/*); do
    sed -i "s|#!/usr/bi#n/env python|#!/usr/bin/env python2|" $file;
  done
}
