# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Tobias Kieslich <tobias@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: Dominik Ryba <domryba@post.pl>

pkgname=hugin
pkgver=2019.0.0
pkgrel=4
pkgdesc="Panorama photo stitcher"
arch=(x86_64)
url="http://hugin.sourceforge.net/"
license=(GPL)
depends=(wxgtk3 boost-libs libtiff libpano13 libjpeg libpng openexr vigra
         exiv2 glew sqlite lcms2 lapack fftw glu libxi libxmu python
         lensfun make enblend-enfuse)
makedepends=(cmake boost tclap mesa swig)
optdepends=('perl-image-exiftool: GPano tags support'
            'dcraw: RAW import using dcraw'
            'darktable: RAW import using darktable'
            'rawtherapee: RAW import using rawtherapee')
source=("https://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver/r/_r}.tar.bz2" hugin-exiv2-0.27.1.patch)
sha256sums=('f94717c5035b776a552163bac5815916e0662008fabefafd790fa54b352e22d1'
            '93ade29aa894ebc0186570b8eb24c4849001fdf7781a9a95beb661e3ccd3533f')

prepare() {
    mkdir -p build

    cd $pkgname-$pkgver
    patch -p1 -i ../hugin-exiv2-0.27.1.patch # Fix build with exiv2 0.27.1 (Fedora)
}

build() {
    cd build
    cmake ../${pkgname}-${pkgver} \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DENABLE_LAPACK=yes \
        -DBUILD_HSI=ON \
        -DUSE_GDKBACKEND_X11=ON \
        -DwxWidgets_CONFIG_EXECUTABLE=/usr/bin/wx-config-gtk3
    make
}

package() {
    cd build
    make DESTDIR="${pkgdir}" install
}
