# Maintainer (arch): Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>
# Contributor: tobias <tobias@archlinux.org>
# Contributor: red_over_blue
# Contributor: neri
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: Márcio Silva <coadde@hyperbola.info>
# Don't build povray before 3.7 version (that ones are nonfree software)

_pkgname=povray-libre
pkgname=povray
pkgver=3.7.0.8
_v=${pkgver%.*.*} # 3.7
pkgrel=5
pkgrel+=.parabola1
epoch=2
pkgdesc='Script based raytracer for creating 3D graphics'
pkgdesc+=', without nonfree documentation'
arch=('x86_64')
arch+=('i686' 'armv7h')
license=('AGPL3')
url='http://povray.org/' # bad https cert
depends=('boost-libs' 'libpng' 'libtiff' 'openexr')
makedepends=('boost' 'git' 'glu')
conflicts=("$_pkgname")
replaces=("$_pkgname")
backup=("etc/povray/$_v/povray.conf"
        "etc/povray/$_v/povray.ini")
source=("$pkgname-$pkgver.tar.gz::https://github.com/POV-Ray/povray/archive/v$pkgver.tar.gz")
sha512sums=('4de3090cb4c1f7d8004bf5548297f4b95496b3265e5b8b5c861f331bda20de06c9d1ce67858a233740f8091e61315abdd3e519c8db5557b6b37c7a864b85d1c6')

prepare() {
  # remove nonfree documentation
  rm -rv "$pkgname-$pkgver"/doc

  cd "$pkgname-$pkgver/unix"

  sed 's/automake --w/automake --add-missing --w/g' -i prebuild.sh
  sed 's/dist-bzip2/dist-bzip2 subdir-objects/g' -i configure.ac
  ./prebuild.sh

  cd ..
  ./bootstrap
}

build() {
  cd "$pkgname-$pkgver"

  ./configure \
    LIBS="-lboost_system -lboost_thread" \
    COMPILED_BY='Parabola GNU/Linux-libre' \
    --sysconfdir=/etc \
    --prefix=/usr
  make CXXFLAGS+="-std=c++11 -lboost_system -lboost_thread -w"
}

package() {
  cd "$pkgname-$pkgver"

  install -d "$pkgdir/usr/share/$pkgname-$_v"
  cp -r icons include ini scenes scripts "$pkgdir/usr/share/$pkgname-$_v"
  chmod -R u+rwX,g+rX,o+rX "$pkgdir/usr/share/$pkgname-$_v" # fix permissions
  install -Dm755 unix/povray "$pkgdir/usr/bin/povray"
  install -Dm644 povray.conf "$pkgdir/etc/povray/$_v/povray.conf"
  install -Dm644 povray.ini "$pkgdir/etc/povray/$_v/povray.ini"
  install -Dm644 povray.1 "$pkgdir/usr/share/man/man1/povray.1"
}

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