# Maintainer: Peter Budai <peterbudai at hotmail.com>

# This package cannot be build with installed libgdiplus package 
# as it doesnt contain reference for GdipFontFamilyCachedGenericSansSerif

_realname=gnuplot
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.4.1
pkgrel=1
pkgdesc="Plotting package which outputs to X11, PostScript, PNG, GIF, and others (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='http://www.gnuplot.info/'
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gnutls"
         "${MINGW_PACKAGE_PREFIX}-libcaca"
         "${MINGW_PACKAGE_PREFIX}-libcerf"
         "${MINGW_PACKAGE_PREFIX}-libgd"
         "${MINGW_PACKAGE_PREFIX}-pango"
         "${MINGW_PACKAGE_PREFIX}-readline"
         "${MINGW_PACKAGE_PREFIX}-wxWidgets")
#optdepends=("${MINGW_PACKAGE_PREFIX}-qt5")
#makedepends=("${MINGW_PACKAGE_PREFIX}-qt5")
options=('strip' 'staticlibs')
source=("https://downloads.sourceforge.net/sourceforge/${_realname}/${_realname}-${pkgver}.tar.gz"
        "01-gnuplot.patch" )
sha256sums=('6b690485567eaeb938c26936e5e0681cf70c856d273cc2c45fabf64d8bc6590e'
            'b07b4220743b47c88d67f41a542562329205d8a2cfa60b9e225ca5b71b4fab5d')


prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/01-gnuplot.patch
  autoreconf -fiv
}

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}

  ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --without-lua \
      --with-caca \
      --with-qt=no \
      --with-bitmap-terminals

    make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
