# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

pkgname=libbsd
pkgver=0.11.8
pkgrel=1
pkgdesc='Provides useful functions commonly found on BSD systems like strlcpy()'
arch=('i686' 'x86_64')
url="https://libbsd.freedesktop.org"
msys2_references=(
  "cpe: cpe:/a:freedesktop:libbsd"
)
license=('custom')
depends=('libmd')
makedepends=("gcc" "autotools" "make")
source=("https://libbsd.freedesktop.org/releases/$pkgname-$pkgver.tar.xz"{,.asc}
        "001-random-hackery.patch")
sha256sums=('55fdfa2696fb4d55a592fa9ad14a9df897c7b0008ddb3b30c419914841f85f33'
            'SKIP'
            '2f7e99e894595364385b9861013505c5aa63f41618708b7c9bdfd98069d35079')
validpgpkeys=('4F3E74F436050C10F5696574B972BF3EA4AE57A3') # Guillem Jover

prepare() {
  cd "${pkgname}-${pkgver}"

  patch -p1 -i "${srcdir}/001-random-hackery.patch"

  autoreconf -vfi
}

build() {
  cd "$pkgname-$pkgver"

  ./configure \
    --build="${CHOST}" \
    --prefix=/usr
  make
}

check() {
  cd "$pkgname-$pkgver"
  make check
}

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

  make DESTDIR="$pkgdir" install
  install -D -m644 COPYING "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
