pkgname=libmicrohttpd
pkgver=1.0.4
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=('67c70243a144099db0501f102b759b79ef4454af8a2767ce33376ca5db378dd79cc4968c6ac69203669db0c6b88f2a1f90cae19c16874ce77d5eaa4a5fae4e02')
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
}
