# $Id: PKGBUILD 126697 2015-01-28 11:36:04Z 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
pkgver=1.12.1
pkgrel=1
pkgdesc="A turn-based strategy game on a fantasy world"
arch=('i686' 'x86_64')
license=('GPL')
url="http://www.wesnoth.org/"
depends=('sdl_ttf' 'sdl_net' 'sdl_mixer' 'sdl_image' 'fribidi' 'boost-libs' 'pango' 'lua' 'wesnoth-data' 'dbus' 'python2')
makedepends=('boost' 'cmake'' git')
install=wesnoth.install
options=(!emptydirs)
source=("git://github.com/wesnoth/wesnoth.git#tag=${pkgver}"
        "wesnoth-boost.patch"
        wesnothd.tmpfiles.conf
        wesnothd.service)
md5sums=('SKIP'
         '9a4ad99ba66990bfc17cb12966b3823b'
         '2d2fea6b3d86dfd589f5ad35a3be1f97'
         'd1b6bf1d3dc05086ee6a370adff0ae4a')

build() {
  cd "$srcdir/$pkgname"
  
  # 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
  make
}

package() {
  cd "$srcdir/$pkgname"

  cd build
  make DESTDIR="$pkgdir" install

  rm -r $pkgdir/usr/share/applications
  rm -r $pkgdir/usr/share/doc
  rm -r $pkgdir/usr/share/pixmaps
  rm -r $pkgdir/usr/share/wesnoth

  install -Dm644 "$srcdir/wesnothd.tmpfiles.conf" "$pkgdir/usr/lib/tmpfiles.d/wesnothd.conf"
  install -Dm644 "$srcdir/wesnothd.service" "$pkgdir/usr/lib/systemd/system/wesnothd.service"
}
