# Maintainer: Johannes Schindelin <johannes.schindelin@gmx.de>

_realname=msmtp
pkgbase="mingw-w64-${_realname}"
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.8.32
pkgrel=1
pkgdesc="An SMTP client (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://marlam.de/msmtp/"
msys2_repository_url="https://git.marlam.de/gitweb/?p=msmtp.git"
msys2_references=(
  'archlinux: msmtp'
  "cpe: cpe:2.3:a:marlam:msmtp"
  "cpe: cpe:2.3:a:martin_lambers:msmtp"
)
license=('spdx:GPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-gnutls"
         "${MINGW_PACKAGE_PREFIX}-gsasl"
         "${MINGW_PACKAGE_PREFIX}-libidn2"
         "${MINGW_PACKAGE_PREFIX}-libsecret"
         "${MINGW_PACKAGE_PREFIX}-libwinpthread")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "${MINGW_PACKAGE_PREFIX}-pkgconf")
source=(https://marlam.de/msmtp/releases/${_realname}-${pkgver}.tar.xz{,.sig})
sha256sums=('20cd58b58dd007acf7b937fa1a1e21f3afb3e9ef5bbcfb8b4f5650deadc64db4'
            'SKIP')
validpgpkeys=('2F61B4828BBA779AECB3F32703A2A4AB1E32FD34') # Martin Lambers <marlam@marlam.de>

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

  CFLAGS+=" -Wno-incompatible-pointer-types" \
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --with-libgsasl

  make
}

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

  make DESTDIR="${pkgdir}" install

  install -Dm0644 "${srcdir}"/${_realname}-${pkgver}/COPYING \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
