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

_realname=gsasl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.10.0
pkgrel=1
pkgdesc="Simple Authentication and Security Layer framework and a few common SASL mechanisms (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://josefsson.org/gsasl/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' 'staticlibs')
depends=("${MINGW_PACKAGE_PREFIX}-gss"
         "${MINGW_PACKAGE_PREFIX}-gnutls"
         "${MINGW_PACKAGE_PREFIX}-libidn"
         "${MINGW_PACKAGE_PREFIX}-libgcrypt"
         "${MINGW_PACKAGE_PREFIX}-libntlm"
         "${MINGW_PACKAGE_PREFIX}-readline")
validpgpkeys=('B1D2BD1375BECB784CF4F8C4D73CF638C53C06BE'   # Simon Josefsson <simon@josefsson.org>
              '9AA9BDB11BB1B99A21285A330664A76954265E8C')  # Simon Josefsson <simon@josefsson.org>
source=(ftp://ftp.gnu.org/gnu/gsasl/${_realname}-${pkgver}.tar.gz{,.sig}
        "gsasl-avoid-conflicting-types.patch")
sha256sums=('85bcbd8ee6095ade7870263a28ebcb8832f541ea7393975494926015c07568d3'
            'SKIP'
            '6d321e0d0ad49a1b6022f2b139f88fd17eb48af314e96dc50ccb228f255c8732')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/gsasl-avoid-conflicting-types.patch
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-kerberos_v5

  make -j1
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
