# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=dspam
pkgver=3.10.2
_ver=$pkgver
pkgrel=6
pkgdesc="A statistical-algorithmic hybrid anti-spam filter"
url="http://dspam.nuclearelephant.com/"
pkgusers="dspam"
pkggroups="dspam"
arch="all"
license="GPL-2.0"
depends=
install="$pkgname.pre-install"
makedepends="postgresql-dev sqlite-dev mariadb-dev autoconf automake libtool"
subpackages="$pkgname-dev $pkgname-doc $pkgname-pgsql $pkgname-mysql
	$pkgname-sqlite"

install= #dspam.install
source="http://downloads.sourceforge.net/$pkgname/$pkgname-$_ver.tar.gz
	dspam.logrotate
	dspam.initd
	musl-fixes.patch"


builddir="$srcdir/$pkgname-$_ver"

prepare() {
	cd "$builddir"
	update_config_guess || return 1
	default_prepare || return 1
	#aclocal -I m4 && libtoolize && autoconf && automake
}

build() {
	cd "$builddir"
	./autogen.sh || return 1
	./configure --prefix=/usr \
		--sysconfdir=/etc/dspam \
		--with-dspam-home=/var/lib/dspam \
		--enable-virtual-users \
		--enable-preferences-extension \
		--enable-daemon \
		--with-storage-driver="hash_drv,sqlite3_drv,pgsql_drv,mysql_drv" \
		--with-mysql-includes=/usr/include/mysql \
		|| return 1
	make -j1 || return 1
}

package() {
	cd "$builddir"
	make install DESTDIR="$pkgdir"
	install -Dm755 "$srcdir"/dspam.initd "$pkgdir"/etc/init.d/dspam
	install -Dm644 "$srcdir"/dspam.logrotate "$pkgdir"/etc/logrotate.d/dspam
}

pgsql() {
	pkgdesc="dspam postgresql driver"
	install -d "$subpkgdir"/usr/lib/dspam
	mv "$pkgdir"/usr/lib/dspam/*pgsql* "$subpkgdir"/usr/lib/dspam/
}

mysql() {
	pkgdesc="dspam mysql driver"
	install -d "$subpkgdir"/usr/lib/dspam
	mv "$pkgdir"/usr/lib/dspam/*mysql* "$subpkgdir"/usr/lib/dspam/
}

sqlite() {
	pkgdesc="dspam sqlite driver"
	install -d "$subpkgdir"/usr/lib/dspam
	mv "$pkgdir"/usr/lib/dspam/*sqlite* "$subpkgdir"/usr/lib/dspam/
}

md5sums="0e0e405d3284485b2a43f47eaf6b09bb  dspam-3.10.2.tar.gz
a798e9a6e2d5c30724f84d004bb96339  dspam.logrotate
7d1fb0820f4a23f593f22186ef77d02a  dspam.initd
5e77c0fd2fe8b4bfbdb5d7927835d73a  musl-fixes.patch"
sha256sums="ae76569604021f35b741fb95198a1e611a8c64c3838661973a6cf360bba593a9  dspam-3.10.2.tar.gz
dd5bce638b92936e02ff02faf781cbf903faac7b73c61c1c666eb06cfb56bfac  dspam.logrotate
8fb3ae6a04f59798bc919e6a967015733e28fe0d52e7cbc6e7aa0dbe110edf4d  dspam.initd
ecd01cd869c44507d22f4b4d4804cf2053d5679e7a6f5a71159fc80a91da53b9  musl-fixes.patch"
sha512sums="5fe53e1d0d7cabb3983f5c67274b074b7c647c1bae10ebc7ea3805542f99dbfb39abd4697e344e6eb80554522319a1253e1082ed6b389364bbaec1d6ddd43856  dspam-3.10.2.tar.gz
b0e288f36f0aa2be48c9917bcfca39148df2682cb6bea88192c46dfa6e33226613bf2b5d7b977f2948a43c6932837e186949a99dece34431fac6e9b678f00da5  dspam.logrotate
59177cbb3a42ed4f003a643239433d990c36e7531b6bae5841ac19164548a9ad0054be3d0b0ca5540af05b9a901a8d9f0b2b965d9969fee6779b81ac35b19262  dspam.initd
4c600cccd6601db6c738a940d6309ee621e98d678a000614f4d4927c10a80528c642a32ae5a453d35c2679debacb04af6ca60d1c569d72751acc44e75446245a  musl-fixes.patch"
