# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Doug Newgard <scimmia at archlinux dot org>
# Contributor: XavierCLL <xavier.corredor.llano (a) gmail.com>
# Contributor: SaultDon <sault.don gmail>
# Contributor: Lantald < lantald at gmx.com >
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org
# Contributor: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
# Contributor: Eric Forgeot < http://esclinux.tk >

pkgname=qgis
pkgver=3.8.2
pkgrel=2
pkgdesc='Geographic Information System (GIS) that supports vector, raster & database formats'
url='https://qgis.org/'
license=(GPL)
arch=(x86_64)
depends=(desktop-file-utils exiv2 gdal hicolor-icon-theme libzip python-qscintilla-qt5 qca qt5-3d
         qt5-serialport qt5-webkit qtkeychain qwtpolar spatialindex python-sip)
makedepends=(cmake fcgi gsl python-six qt5-tools txt2tags sip)
optdepends=('fcgi: Map server'
            'gpsbabel: GPS Tools plugin'
            'gsl: Georeferencer plugin'
            'python-gdal: DB Manager plugin; Processing plugin'
            'python-jinja: MetaSearch plugin'
            'python-owslib: MetaSearch plugin'
            'python-psycopg2: DB Manager plugin; Processing plugin'
            'python-pygments: MetaSearch plugin'
            'python-numpy: Processing plugin'
            'python-yaml: Processing plugin')
source=("https://qgis.org/downloads/$pkgname-$pkgver.tar.bz2"
        qt-5.13.patch)
sha256sums=('4d682f7625465a5b3596b3f7e83eddad86a60384fead9c81a6870704baffaddd'
            '2798a8c2d2dfbe18e05a4c44611291d9688dddac3e000dc95f4c8893e0fbfe93')

prepare() {
  [[ -d build ]] || mkdir build

  cd $pkgname-$pkgver
  # Fix build with Qt 5.13
  patch -Np1 -i ../qt-5.13.patch
}

build() {
  cd build
  cmake -G "Unix Makefiles" ../$pkgname-$pkgver/ \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DWITH_3D=TRUE \
    -DWITH_SERVER=TRUE \
    -DWITH_CUSTOM_WIDGETS=TRUE \
    -DBINDINGS_GLOBAL_INSTALL=TRUE \
    -DQGIS_MANUAL_SUBDIR=share/man \
    -DWITH_QWTPOLAR=TRUE \
    -DWITH_INTERNAL_QWTPOLAR=FALSE
  make
}

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