COMMENT=		Daemon for maintaining the accuracy of computer clocks

V=			4.9
DISTNAME=		chrony-$V
CATEGORIES=		net

MAINTAINER=		tom@kupper.org
HOMEPAGE=		https://chrony-project.org/
SITES=			https://chrony-project.org/releases/

# GPLv2+
PERMIT_PACKAGE=		Yes

# uses pledge()
WANTLIB+=		c m pthread edit gnutls nettle

BUILD_DEPENDS+=		textproc/asciidoctor
LIB_DEPENDS+=		security/gnutls security/nettle

USE_GMAKE=		Yes
CONFIGURE_STYLE=	simple

CONFIGURE_ARGS+=	--prefix=${PREFIX}
CONFIGURE_ARGS+=	--mandir=${PREFIX}/man
CONFIGURE_ARGS+=	--localstatedir=${VARBASE}
CONFIGURE_ARGS+=	--with-pidfile=${VARBASE}/run/chrony/chronyd.pid
CONFIGURE_ARGS+=	--chronyvardir=${VARBASE}/db/chrony
CONFIGURE_ARGS+=	--enable-ntp-signd
CONFIGURE_ARGS+=	--with-user=_chrony
CONFIGURE_ARGS+=	--without-tomcrypt
CONFIGURE_ARGS+=	--enable-scfilter
# available on Linux only
CONFIGURE_ARGS+=	--disable-rtc

TEST_TARGET=		check
TEST_DEPENDS=		shells/bash

SUBST_VARS+=		VARBASE
EXAMPLEDIR=		${PREFIX}/share/examples/chrony

pre-configure:
	${SUBST_CMD} ${WRKSRC}/examples/chrony.conf.example3

post-install:
	cp ${FILESDIR}/chronyd.in ${WRKINST}/etc/rc.d/chronyd
	chmod +x ${WRKINST}/etc/rc.d/chronyd
	${INSTALL_DATA_DIR} "${EXAMPLEDIR}"
	${INSTALL_DATA} "${WRKSRC}/examples/chrony.conf.example3" \
		"${EXAMPLEDIR}/chrony.conf";
	${INSTALL_DATA} "${WRKSRC}/examples/chrony.keys.example" \
		"${EXAMPLEDIR}/chrony.keys.example";

.include <bsd.port.mk>
