# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgname=libnghttp2
pkgver=%version%
pkgrel=%release%
pkgdesc='Framing layer of HTTP/2 is implemented as a reusable C library'
arch=('x86_64')
url='https://nghttp2.org/'
license=('MIT')
depends=('glibc')
provides=('libnghttp2.so')
makedepends=('git')
conflicts=('nghttp2<1.20.0-2')
validpgpkeys=('F4F3B91474D1EB29889BD0EF7E8403D5D673C366') # Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
source=("git+https://github.com/nghttp2/nghttp2.git#tag=v${pkgver}?signed"
        'git+https://github.com/ngtcp2/munit.git'
        'git+https://github.com/mruby/mruby.git'
        'git+https://github.com/tatsuhiro-t/neverbleed.git')
sha512sums=('a347249408552b1928ca42955a094be9c69a56fe9eb4a21ec8ac62c8c99ce8fa13a3fb2b1ba6363c75ac73a169ac62cbd954cfad607e872e821a6348817027e4'
            'SKIP'
            'SKIP'
            'SKIP')

prepare() {
  cd nghttp2

  git config --file=.gitmodules submodule.tests/munit.url ../munit/
  git config --file=.gitmodules submodule.third-party/mruby.url ../mruby/
  git config --file=.gitmodules submodule.tests/neverbleed.url ../neverbleed/

  git submodule init
  git -c protocol.file.allow=always submodule update

  autoreconf -i
}

build() {
  cd nghttp2

  ./configure \
    --prefix=/usr \
    --disable-examples \
    --disable-python-bindings \
    --enable-lib-only
  make
}

check() {
  cd nghttp2
  make check
}

package() {
  cd nghttp2/lib

  make DESTDIR="$pkgdir" install
  install -Dm644 ../COPYING "$pkgdir/usr/share/licenses/libnghttp2/COPYING"
}
