# Maintainer: Rafal Brzegowy <rafal.brzegowy@yahoo.com>

_realname=tfel
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=3.4.1
pkgrel=1
pkgdesc='MFront: a code generation tool dedicated to material knowledge (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
provides=('mfront')
depends=("${MINGW_PACKAGE_PREFIX}-gnuplot")
makedepends=("unzip"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-cmake")
license=('GPL')
url='http://tfel.sourceforge.net'
source=(https://github.com/thelfer/${_realname}/archive/TFEL-${pkgver}.zip)
sha256sums=('206D374EB62FC854791B0A6150A02B661258B9AA400C10460EDEC40F236801CB')
noextract=("TFEL-${pkgver}.zip") # bsdtar could not unpack this archive

prepare() {  
  rm -rf "${srcdir}/TFEL-${pkgver}r"
  unzip -oq TFEL-${pkgver}.zip -d ${srcdir}
}

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

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    ${MINGW_PREFIX}/bin/cmake \
      -GNinja \
      -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
      -DCMAKE_BUILD_TYPE=Release \
      -Denable-fortran=ON \
      -Denable-python=OFF \
      -Denable-python-bindings=OFF \
      -Denable-aster=ON \
      -Denable-abaqus=ON \
      -Denable-ansys=ON \
      -Denable-europlexus=ON \
      -Denable-zmat=ON \
      -Denable-cyrano=ON \
      -Denable-calculix=ON \
      -Denable-comsol=ON \
      -Denable-diana-fea=ON \
      -Denable-lsdyna=ON \
      -Denable-cxx-17=ON \
      -Denable-portable-build=ON \
      -Denable-reference-doc=OFF \
      ../${_realname}-TFEL-${pkgver}
  ninja
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  DESTDIR=${pkgdir} cmake --build . --target install
  install -Dm644 ${srcdir}/${_realname}-TFEL-${pkgver}/LICENCE-GNU-GPL ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

# vim: ts=2 sw=2 et:
