# Maintainer: Antoine Lambert <antoine.lambert@inria.fr>

_realname=tulip
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_pre=
_ver=5.2.1
pkgver=${_ver}${_pre}
pkgrel=1
pkgdesc="Large graphs analysis, drawing and visualization framework"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://tulip.labri.fr/"
license=('LGPL')
options=('strip' 'staticlibs')
source=("https://sourceforge.net/projects/auber/files/tulip/${_realname}-${_ver}${_pre}/${_realname}-${_ver}${_pre}_src.tar.gz"
        "001-fix-tulip-python-install.patch")
sha256sums=('7e7237993f91a0450c056f04a5222436fe829573c7f5b23b5207c5ac8dc7152f'
            'd31e7a2a972c654e77919d7178b6c89264e79c55687c5bd37b4b8023cd1e35ee')
depends=("${MINGW_PACKAGE_PREFIX}-freetype"
         "${MINGW_PACKAGE_PREFIX}-glew"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-libjpeg"
         "${MINGW_PACKAGE_PREFIX}-python3"
         "${MINGW_PACKAGE_PREFIX}-qhull"
         "${MINGW_PACKAGE_PREFIX}-qt5"
         "${MINGW_PACKAGE_PREFIX}-qtwebkit"
         "${MINGW_PACKAGE_PREFIX}-quazip"
         "${MINGW_PACKAGE_PREFIX}-yajl")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-python3-sip"
             "${MINGW_PACKAGE_PREFIX}-python3-sphinx")

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/001-fix-tulip-python-install.patch
}

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_NEED_RESPONSE=ON \
    -DTULIP_FIXUP_BUNDLE=OFF \
    -DTULIP_USE_QT5=ON \
    -DPYTHON_EXECUTABLE=${MINGW_PREFIX}/bin/python3.exe \
    -DTULIP_PYTHON_SITE_INSTALL=ON \
    ../${_realname}-${_ver}${_pre}

  make
}

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