# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=nmail
pkgver=5.1.16
pkgrel=0
pkgdesc="Terminal-based email client"
url="https://github.com/d99kris/nmail"
arch="all"
license="MIT"
depends="
	bash
	cyrus-sasl-login
	"
makedepends="
	cmake
	cyrus-sasl-dev
	file-dev
	libetpan-dev
	linux-headers
	ncurses-dev
	openssl-dev
	samurai
	sqlite-dev
	util-linux-dev
	xapian-core-dev
	"
subpackages="$pkgname-doc $pkgname-oauth::noarch"
source="https://github.com/d99kris/nmail/archive/v$pkgver/nmail-$pkgver.tar.gz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=ON \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		-DCMAKE_BUILD_TYPE=None \
		-DHAS_CUSTOM_LIBETPAN=OFF
	cmake --build build
}

check() {
	./build/nmail --version

	# i want to run tests when upstream adds them
	ctest --test-dir build --output-on-failure --no-tests=ignore
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -Dvm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

oauth() {
	pkgdesc="$pkgdesc (OAuth2 Python helper script)"
	depends="$pkgname=$pkgver-r$pkgrel py3-requests"

	amove usr/bin/oauth2nmail
}

sha512sums="
cb64661091a5c7a12c2e08531f69df75705c4b34a667316dbde2bab85814f756f00df808785b97e7637aa490f5e08b736e4246c17a688c2a60e587f3633a7957  nmail-5.1.16.tar.gz
"
