# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: mutantmonkey <mutantmonkey@gmail.com>

_pkgname=sendmail # libmilter is bundled with the sendmail source
pkgname=libmilter
pkgver=8.18.1
pkgrel=1
pkgdesc='Implementation of the sendmail Mail Filter API'
url='https://www.proofpoint.com/us/sendmail-open-source'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
options=('staticlibs')
license=('Sendmail')
# Signing keys sourced from upstream. Current version is signed with the 2024 keys.
# https://www.proofpoint.com/us/products/email-protection/open-source-email-solution
validpgpkeys=('8AB063D7A4C5939DA9C01E38C4065A87C71F6844')
source=(
  "https://ftp.sendmail.org/$_pkgname.$pkgver.tar.gz"{,.sig}
  'fd-passing-libmilter.patch'
  'site.config.m4'
)
sha512sums=('9ce713b44439d4de6faa9e3cdfa2226b44b4fbeb352a5f81584c062570e9472da244158287e489aabe258d28fe54ca4964565c7b0adc7e1763d212be42f98061'
            'SKIP'
            '438dfb94d4b884a08abbb20849a8b309b251b9d48c098575e67603d9d4d23d8ac799287cedd975b8aae61c550b987a9bf8dd7c9343ed289185b7e2ca72cbc82a'
            '01c8f7f9f7a20888604fdbf5696c563dc42e75642f9857cb3cfd3593c058a3a6c84f86250c8459b6dcc1d2b71cfcc5c84e717f8d86df5f9f468086d4d94810bd')
b2sums=('3afa36073fd611c7fdb43ef0ab9f02d5fb8ae388e9471bdc7275c6c9dcee0a654f46ddef505b70e978cb1b818b0da375250678e501676d8bace534d59ee40d90'
        'SKIP'
        'ea2f1811666ce1b2c7532794845de9ec1f1e72d6c58a02c4c5800e93359c1c1cd4a0353fee572c258c378b0fea776d03ba19d794da7ed3295d9432b47ceb2481'
        '4173a1abd272908faeef7f44b5d033f639101f0494be0bcb7e43e29b087f436f082e05a3065fc89f428b91e94cfa0c4b4abf92be77bd722a646012a1f428300a')

prepare() {
  cd "$_pkgname-$pkgver"
  patch -p1 -i ../fd-passing-libmilter.patch # FS#49421
  cp ../site.config.m4 devtools/Site
}

build() {
  cd "$_pkgname-$pkgver/$pkgname"
  ./Build
}

package() {
  cd "$_pkgname-$pkgver/$pkgname"

  # create install directory
  install -vd "$pkgdir/usr/lib"
  ./Build DESTDIR="$pkgdir" install

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" ../LICENSE

  # correct permissions
  chown -R root:root "$pkgdir"
}
