# Contributor: SpepS <dreamspepser at yahoo dot it>
# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - link against libatomic for v5/v6

pkgname=openimageio
pkgver=1.8.14
pkgrel=2.1
pkgdesc="A library for reading and writing images, including classes, utilities, and applications"
arch=(x86_64)
url="http://www.openimageio.org/"
license=('custom')
depends=('openexr' 'boost-libs' 'jasper' 'glew' 'libtiff' 'opencolorio' 'intel-tbb' 'openssl' 'libpng')
makedepends=('cmake' 'qt5-base' 'python2' 'boost' 'mesa' 'git' 'freetype2' 'fontconfig' 'libxrender')
optdepends=('qt5-base: iv image viewer'
            'python2: bindings support')
source=(git+git://github.com/OpenImageIO/oiio.git#tag=Release-${pkgver})
md5sums=('SKIP')

build() {
  cd oiio

  [[ -d build ]] && rm -r build
  mkdir build && cd build

  [[ $CARCH == "arm" || $CARCH == "armv6h" ]] && LDFLAGS="-latomic $LDFLAGS"

  # Python is currently broken :(
  cmake .. \
      -DUSE_PYTHON=ON \
      -DUSE_PYTHON3=ON \
      -DUSE_OPENSSL=ON \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_INSTALL_LIBDIR=lib \
      -DPYLIB_INSTALL_DIR=lib/python2.7/site-packages \
      -DPYLIB3_INSTALL_DIR=lib/python3.6/site-packages \
      -DOIIO_BUILD_TESTS=ON \
      -DOIIO_BUILD_TOOLS=ON \
      -DSTOP_ON_WARNING=OFF
  make
}

package() {
  cd oiio/build

  make DESTDIR="$pkgdir" install

  # license
  cd ..
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}