pkgname=libmicrohttpd
pkgver=1.0.5
pkgrel=1
pkgdesc="GNU libmicrohttpd is a small C library that is supposed to make it easy to run an HTTP server as part of another application"
arch=(x86_64)
url="https://www.gnu.org/software/libmicrohttpd"
msys2_references=(
  "cpe: cpe:/a:gnu:libmicrohttpd"
)
license=('spdx:LGPL-2.1-or-later')
makedepends=(
  autotools
  gcc
  libgnutls-devel
)
depends=(
  libgnutls
)
source=(
  https://ftp.gnu.org/gnu/libmicrohttpd/${pkgname}-${pkgver}.tar.gz
)
sha512sums=('7ed3e81f0c4253a409f5e825446c8d2d8b975c0eb6f381b6867796bbdcf4890004a24659e95b8ec8c39e8df0a9885cc08a0ba75f953893ee1455ae180dc89391')
validpgpkeys=('D8423BCB326C7907033929C7939E6BE1E29FC3CC'  # Christian Grothoff <christian@grothoff.org>
              'EA812DBEFA5A7EF17DA8F2C1460A317C3326D2AE') # Karlson2k (Evgeny Grin) <k2k@narod.ru>

prepare() {
  cd ${pkgname}-${pkgver}
  autoreconf -fiv
}

build() {
  cd ${pkgname}-${pkgver}
  CPPFLAGS+=" -DGNUTLS_INTERNAL_BUILD" \
  ./configure \
    --disable-examples \
    --enable-https \
    --enable-static \
    --enable-shared

  make
}

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

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install

  install -Dm644 COPYING $pkgdir/usr/share/licenses/$pkgname/LICENSE
}
