# Maintainer: Bruno Pagani <archange@archlinux.org>

pkgbase=gmt
pkgname=(gmt gmt-doc)
pkgver=6.6.0
pkgrel=2
pkgdesc="Generic Mapping Tools for manipulating and plotting geographic and cartesian data"
arch=(x86_64)
url="https://www.generic-mapping-tools.org"
license=(LGPL)
makedepends=(cmake blas curl ffmpeg fftw gdal geos ghostscript graphicsmagick lapack openmp netcdf pcre2 zlib python-sphinx)
source=(https://github.com/GenericMappingTools/gmt/releases/download/${pkgver}/${pkgname}-${pkgver}-src.tar.xz)
sha256sums=('18ac98b11b8fc924463ce5138385c02e9426780fba9ff63a991e2e8ecdbd1082')

build() {
  cmake -B build -S ${pkgname}-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DGMT_LIBDIR=lib \
    -DGMT_DATADIR=share/gmt \
    -DGMT_MANDIR=share/man \
    -DGMT_DOCDIR=share/doc/gmt \
    -DGMT_ENABLE_OPENMP=ON \
    -DGSHHG_ROOT=/usr/share/gmt/coast \
    -DDCW_ROOT=/usr/share/gmt/dcw \
    -DCOPY_GSHHG=OFF \
    -DCOPY_DCW=OFF \
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5
  make -C build
}

package_gmt() {
  depends=(blas curl fftw gdal geos lapack openmp netcdf pcre2 zlib)
  optdepends=(
    'gmt-doc: documentation'
    'ffmpeg: generate movies'
    'ghostscript: convert PostScript outputs'
    'graphicsmagick: generate animated GIFs'
  )
#    'gmt-coast: coastlines'
#    'gmt-dcw: digital chart of the world polygon map'

  make -C build DESTDIR="${pkgdir}" install
  mv "${pkgdir}"/usr/share/doc "${srcdir}"/
}

package_gmt-doc() {
  install -d "${pkgdir}"/usr/share/
  mv doc "${pkgdir}"/usr/share/
}
