# Copyright 2026 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit autotools

DESCRIPTION="ACMEv2 client written in plain C with minimal dependencies"
HOMEPAGE="https://github.com/ndilieto/uacme"
SRC_URI="https://github.com/ndilieto/uacme/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="GPL-3+"
SLOT="0"
KEYWORDS="~amd64"
IUSE="gnutls mbedtls +openssl ualpn"
REQUIRED_USE="^^ ( gnutls mbedtls openssl )"

# Note: Should be able to support LibreSSL as well
RDEPEND="
	virtual/pkgconfig
	>=net-misc/curl-7.38.0
	gnutls? ( >=net-libs/gnutls-3.3.30:= )
	mbedtls? ( net-libs/mbedtls:= )
	openssl? ( >=dev-libs/openssl-1.1.1:= )
	ualpn? ( dev-libs/libev )
"
DEPEND="${RDEPEND}"
BDEPEND="app-text/asciidoc"

src_prepare() {
	default

	# configure.ac requires libev/libev.m4 so generate before de-vendoring
	eautoreconf

	rm -fr libev || die
}

src_configure() {
	econf \
		$(use_with gnutls) \
		$(use_with mbedtls) \
		$(use_with openssl) \
		$(use_with ualpn)
}