# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=xapian-omega
pkgver=1.4.25
pkgrel=1
pkgdesc="Indexers and CGI search frontend for Xapian"
url="http://www.xapian.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="$depends_dev xapian-core-dev perl-dev pcre2-dev zlib-dev file-dev"
subpackages="$pkgname-doc"
source="http://oligarchy.co.uk/xapian/$pkgver/xapian-omega-$pkgver.tar.xz"


prepare() {
	default_prepare
	sed -i -e "s/std::getchar/getchar/g" urldecode.h
	sed -i -e "s/template_dir.*/template_dir \/usr\/share\/omega\/templates/g" omega.conf
}

build() {
	./configure XAPIAN_CONFIG=/usr/bin/xapian-config \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc/$pkgname \
		--disable-rpath \
		--enable-static=no
	make
}

check() {
	make check
}

package() {
	local f
	make DESTDIR=$pkgdir install
	install -Dm755 omega.conf "$pkgdir"/etc/$pkgname/omega.conf
	mkdir -p "$pkgdir"/var/log/omega
	mkdir -p "$pkgdir"/var/lib/omega/cdb
	mkdir -p "$pkgdir"/var/lib/omega/data
	for f in templates images; do
		install -d "$pkgdir"/usr/share/omega/$f && cp -ar $f/* "$pkgdir"/usr/share/omega/$f ;
	done
}

sha512sums="
2b0d855baaaabbf6da1b86d61f0d3e85d5fb62d1b7d04738a7e15758d0042b9e22f80f0aa273b9a9a21b04dff579c561280e44f2a69a0c0d4f270cb0fbcef169  xapian-omega-1.4.25.tar.xz
"
