# Contributor: Fabien Chouteau <chouteau@adacore.com>

_realname=gnatcoll-core
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
replaces=("${MINGW_PACKAGE_PREFIX}-gnatcoll")
conflicts=("${MINGW_PACKAGE_PREFIX}-gnatcoll")
pkgver=25.0.0
pkgrel=2
pkgdesc="GNAT Components Collection - Core packages (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64')
url="https://github.com/AdaCore/gnatcoll-core"
msys2_references=(
  'aur: gnatcoll-core'
  'gentoo: dev-ada/gnatcoll-core'
)
license=('spdx:GPL-3.0-or-later WITH GCC-exception-3.1')
makedepends=("${MINGW_PACKAGE_PREFIX}-gprbuild"
             "${MINGW_PACKAGE_PREFIX}-python"
             "rsync")
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-gcc-ada"
         "${MINGW_PACKAGE_PREFIX}-libgpr")
source=("https://github.com/AdaCore/gnatcoll-core/archive/v${pkgver}/gnatcoll-core-${pkgver}.tar.gz")
sha256sums=('30ebfafcaa44fc20cee50c6869f024bb670e7ea62d44036ce51e528d19de8b9e')

prepare() {
  echo "${pkgver}" > "${srcdir}/gnatcoll-core-${pkgver}/version_information"
}

build() {
  cd "${srcdir}/gnatcoll-core-${pkgver}"

  make BUILD=PROD PROCESSORS="$(nproc)" ENABLE_SHARED=yes
}

package() {
  cd "${srcdir}/gnatcoll-core-${pkgver}"

  make install BUILD=PROD PROCESSORS="$(nproc)" ENABLE_SHARED=yes prefix="${pkgdir}${MINGW_PREFIX}"

  install -Dm644 -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}" \
    "${srcdir}/gnatcoll-core-${pkgver}"/COPYING*
}
