# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=coin-or-asl
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.1.0
pkgrel=1
pkgdesc="COIN-OR autotools harness to build AMPL Solver Library. (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://github.com/coin-or-tools/ThirdParty-ASL'
msys2_references=(
  'archlinux: coin-or-asl'
)
license=('spdx:EPL-1.0')
groups=("${MINGW_PACKAGE_PREFIX}-coin-or")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("${url}/archive/releases/${pkgver}/${_realname}-${pkgver}.tar.gz"
       "https://coin-or-tools.github.io/ThirdParty-ASL/solvers-64919f75f.tgz")
sha256sums=('633e9d42b015a5a6a9ae324cac5736af1605fb74eb18299a54912b67d1a69be7'
            'e212926d1d797701adc901ef18eaab6b15edd13f9281dd8c9266e3cdaf8c2dd3')

prepare() {
  cd ThirdParty-ASL-releases-${pkgver}
  cp -r ../solvers .
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../"ThirdParty-ASL-releases-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}"

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"

  make check
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

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