# Maintainer: Dirk Stolle

_realname=lrcalc
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.1
pkgrel=1
pkgdesc="Littlewood-Richardson calculator (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://sites.math.rutgers.edu/~asbuch/lrcalc/'
msys2_repository_url='https://bitbucket.org/asbuch/lrcalc'
msys2_references=(
  'archlinux: lrcalc'
  'gentoo: sci-mathematics/lrcalc'
)
license=('spdx:GPL-3.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://sites.math.rutgers.edu/~asbuch/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('996ac00e6ea8321ef09b34478f5379f613933c3254aeba624b6419b8afa5df57')

prepare() {
  cd "${_realname}-${pkgver}"

  # Replace paths in README (documentation).
  sed -i "s|/usr/local/share|${MINGW_PREFIX}/share|g" README
}

build() {
  # Using in-source build, because out-of-source build fails.
  cd "${_realname}-${pkgver}"

  ./configure \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --host="${MINGW_CHOST}" \
    --target="${MINGW_CHOST}" \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "${_realname}-${pkgver}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
