# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=charybdis
pkgver=4.1.2
pkgrel=6
pkgdesc="A highly-scalable IRCv3-compliant IRC daemon"
url="https://github.com/charybdis-ircd/charybdis"
arch="all"
license="GPL-2.0-or-later"
pkgusers="ircd"
makedepends="automake autoconf libtool
	bison flex openssl-dev>3 zlib-dev file
	sqlite-dev libltdl"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/charybdis-ircd/charybdis/archive/charybdis-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	fix-missing-include.patch
	"
builddir="$srcdir"/$pkgname-$pkgname-$pkgver

prepare() {
	default_prepare
	./autogen.sh
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc/charybdis \
		--localstatedir=/var/lib \
		--libexecdir=/usr/lib \
		--libdir=/usr/lib/charybdis \
		--enable-epoll \
		--with-custom-branding=alpinelinux \
		--enable-openssl \
		--enable-ipv6 \
		--with-shared-sqlite \
		--with-rundir=/var/run/charybdis \
		--with-logdir=/var/log/charybdis \
		--with-moduledir=/usr/lib/charybdis/modules \
		--with-program-prefix=charybdis-
	make -j1
}

check() {
	make check
}

package() {
	make -j1 DESTDIR="$pkgdir" install
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/charybdis-ircd
	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/charybdis-ircd
	install -d -o ircd "$pkgdir"/var/run/charybdis
	install -d -o ircd "$pkgdir"/var/lib/charybdis
	install -d -o ircd "$pkgdir"/var/log/charybdis
}

sha512sums="
409d64f1e6660c667699013436f434e419c5a8fb49acc9db0f2f707d0aee55d93df58c81beb60fb736cf8bd64499a64519a32d15b384aa628801eb2f20620545  charybdis-4.1.2.tar.gz
7c5288f5a1f070a534ecfb306b233802515fff916411e7eb7837398f0f126f38b9338a046d5e4fc211f6f8328404b1f2db71aac2b8ef968173a700b09faa5f7a  charybdis.initd
1886b312b0ea40945de45db7a379bff2a3af426155fb77676e03f21f8d1d733e057fb5c3cb65fb72bb56008c4c92f3d2d0010563f871fd0802446de443ddfd5e  charybdis.confd
9266961cbe610eca9b4ad91384244587fd80539e3076c4a291466434be2feeebe8711e5f356e7b8bc0ec0abf41a93ac5ddd9010914f1a5e4f00647249ce9a642  fix-missing-include.patch
"
