# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=babl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.1.118
pkgrel=1
pkgdesc="Dynamic Pixel Format Translation Library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'ucrt64' 'clang64' 'clangarm64')
url="https://gegl.org/babl/"
msys2_repository_url="https://gitlab.gnome.org/GNOME/babl"
license=("spdx:LGPL-3.0-or-later")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "git")
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-lcms2")
source=("https://download.gimp.org/pub/babl/${pkgver%.*}/${_realname}-${pkgver}.tar.xz")
sha256sums=('c3febe923e225c2a58f952689a89bb1db956788bfecb18a7eff6fc94da9e2469')

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

  if [ "${CARCH}" = "i686" ]; then
    _arch_opt="-Denable-sse2=false"
  fi

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson setup \
    --prefix="${MINGW_PREFIX}" \
    --auto-features=enabled \
    --wrap-mode=nodownload \
    --buildtype=plain \
    -Denable-gir=true \
    -Dwith-docs=false \
    -Dgi-docgen=disabled \
    ${_arch_opt} \
    "../${_realname}-${pkgver}"

  meson compile
}

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

  meson install --destdir "${pkgdir}"

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