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

_realname=libexodus
_releases=2021-04-02
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=8.11
pkgrel=1
pkgdesc="EXODUS is a model developed to store and retrieve data for finite element analyses (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
depends=("${MINGW_PACKAGE_PREFIX}-crt")
makedepends=("unzip"
             "${MINGW_PACKAGE_PREFIX}-netcdf")
url="https://gsjaardema.github.io/seacas/"
license=('BSD')
source=("https://github.com/gsjaardema/seacas/archive/v${_releases}.zip")
sha256sums=('811037A68EAFF0DAF9F34BD31B2AB1C9B8F028DFCB998AB01FBCB80D9458257C')
noextract=("v${_releases}.zip") # bsdtar could not unpack this archive

prepare() {  
  rm -rf "${srcdir}/seacas-${_releases}"
  unzip -oq v${_releases}.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}"
  
  make -f Makefile.standalone -C "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus"
}

package() {
  mkdir -p ${pkgdir}${MINGW_PREFIX}/{lib,include/exodus,include/sierra}
  cd "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus/include"
	install -Dm644 *.h "${pkgdir}${MINGW_PREFIX}/include/exodus"
  cd "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus/sierra"
	install -Dm644 *.h "${pkgdir}${MINGW_PREFIX}/include/sierra"
  cd "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus"
	install -Dm644 lib*.a "${pkgdir}${MINGW_PREFIX}/lib"
  install -Dm644 "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus"/COPYRIGHT ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
