# $Id$
# Maintainer: Martchus <martchus@gmx.net>

pkgname=nginx-mod-cache-purge
pkgver=2.3
pkgrel=9
_dirname="ngx_cache_purge-${pkgver}"
_nginxver=1.20.2

pkgdesc='NGINX module that adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches'
arch=('x86_64')
depends=("nginx=$_nginxver" "libutil-linux")
makedepends=("nginx-src")
url='http://labs.frickle.com/nginx_ngx_cache_purge'
license=('CUSTOM')

source=("$pkgname-$pkgver::http://labs.frickle.com/files/${_dirname}.tar.gz")
sha256sums=('279e0d8a46d3b1521fd43b3f78bc1c08b263899142a7cc5058c1c0361a92c89c')

prepare() {
  cd "$srcdir/$_dirname"
  echo '
  if [ "$ngx_module_link" = DYNAMIC ] ; then
      ngx_module_type=HTTP
      ngx_module_name=ngx_http_cache_purge_module
      ngx_module_srcs="$ngx_addon_dir/ngx_cache_purge_module.c"
      . auto/module
  fi' >> config
}

build() {
  cp -r /usr/src/nginx .
  cd "$srcdir"/nginx
  ./configure --with-compat --add-dynamic-module="../$_dirname"
  make modules
}

package() {
  install -Dm755 "$srcdir/$_dirname/LICENSE" "$pkgdir/usr/share/licenses/${pkgname}/LICENSE"
  cd "$srcdir"/nginx/objs
  for mod in ngx_*.so; do
    install -Dm755 $mod "$pkgdir"/usr/lib/nginx/modules/$mod
  done
}
