pkgname=libmicrohttpd
pkgver=1.0.3
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=('5b57df7a4f3f9e5b7c3fea50231490061cf4ee2aaa13575777942ad51564d5a3f1aaed493d8741f736d390888e95161f71d9f39d2bf61cc2e4958df09b496a07')
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
}
