# Maintainer: George Rawlinson <george@rawlinson.net.nz>
# Contributor: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=nginx-mainline-mod-brotli
pkgver=1.0.0rc
pkgrel=12
pkgdesc="Brotli compression filter module (nginx-mainline)"
arch=('x86_64')
url="https://github.com/google/ngx_brotli"
_modname="${url##*/}"
license=('BSD')
depends=('nginx-mainline' 'brotli')
makedepends=('nginx-mainline-src')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
b2sums=('450d0ea693bd98d4a1b615f2cdcaad41ccd28266f6d80beec7fe77fe750ab8c5d1bb55aabe15161b9b6d819d2b4d99a7774f2706f2f6fd084b52a7c7dddbc00c')

prepare() {
  mkdir -p build
  ln -sf -t build /usr/src/nginx/{auto,src}
}

build() {
  cd build
  /usr/src/nginx/configure --with-compat --add-dynamic-module="$srcdir/$_modname-$pkgver"
  make modules
}

package() {
  # modules
  install -vDm755 -t "$pkgdir/usr/lib/nginx/modules" build/objs/*.so

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" "$_modname-$pkgver/LICENSE"
}