# $OpenBSD: Makefile,v 1.5 2010/02/25 17:07:17 sthen Exp $

COMMENT-main =	flexible network host monitoring, client
COMMENT-server =flexible network host monitoring, server

V =		1.2.6
DISTNAME =	munin_$V
PKGNAME-main =	munin-node-$Vp2
PKGNAME-server =munin-server-$V
CATEGORIES =	net

HOMEPAGE =	http://munin.projects.linpro.no/
MASTER_SITES =	${MASTER_SITE_SOURCEFORGE:=munin/}

# Mostly GPLv2. VeraMono.ttf has a non-restrictive license (copyright notice
# embedded in the font or xenocara/font/bitstream-vera-ttf/COPYRIGHT.TXT).
PERMIT_PACKAGE_CDROM =	Yes
PERMIT_PACKAGE_FTP =	Yes
PERMIT_DISTFILES_CDROM =Yes
PERMIT_DISTFILES_FTP =	Yes

MAINTAINER =		Stuart Henderson <sthen@openbsd.org>

MULTI_PACKAGES =	-main -server

RUN_DEPENDS-main =	::devel/p5-Net-Server
RUN_DEPENDS-server +=	:p5-RRD-*:net/rrdtool,-perl \
			::www/p5-HTML-Template \
			:munin-node-*:net/munin,-main

BUILD_DEPENDS =		::print/htmldoc \
			::converters/html2text

USE_GMAKE =		Yes
ALL_TARGET =		default build-doc build-man
WRKDIST =		${WRKDIR}/${DISTNAME:S/_/-/}
PKG_ARCH =		*

# only used for MODPY_BIN
MODULES =		lang/python
MODPY_RUNDEP =		No
CONFIGURE_STYLE =	none # hack, otherwise python.port.mk overrides target

MAKE_ENV +=		CONFDIR=${SYSCONFDIR}/munin \
			OSTYPE=openbsd \
			PREFIX=${PREFIX} \
			PYTHON=${MODPY_BIN}

FAKE_FLAGS +=		HTMLDIR=${WRKINST}/${PREFIX}/share/examples/munin/www \
			CGIDIR=${WRKINST}/${PREFIX}/share/examples/munin/www \
			DOCDIR=${WRKINST}/${PREFIX}/share/doc/munin \
			CONFDIR=${WRKINST}/${PREFIX}/share/examples/munin

MUNIN_PLUGINS =		bgpd if_pps_ intr pf_changes pf_searches pf_states \
			sensors_ vmstat

post-extract:
	cp -Rp ${WRKSRC}/node/node.d.freebsd ${WRKSRC}/node/node.d.openbsd
.for i in ${MUNIN_PLUGINS}
	${SUBST_CMD} -c \
	    ${FILESDIR}/$i ${WRKSRC}/node/node.d.openbsd/$i.in
.endfor
	chmod -R +x ${WRKSRC}/node/node.d.openbsd
	rm ${WRKSRC}/node/node.d.openbsd/memory.in # not yet ported

pre-configure:
	cd ${WRKSRC}/node; ${SUBST_CMD} munin-node.in munin-node-configure.in
	perl -pi -e 's,/etc/munin/plugins,${SYSCONFDIR}/munin/plugins,g;' \
	    -e 's,/etc/munin/node.d,${SYSCONFDIR}/munin/plugins,g;' \
	    -e 's,/usr/local/libexec/munin/plugins,${TRUEPREFIX}/libexec/munin/plugins,g;' \
	    -e 's,/usr/share/munin/node/plugins-auto,${TRUEPREFIX}/libexec/munin/plugins,g;' \
	    ${WRKSRC}/node/node.d/* ${WRKSRC}/node/node.d.openbsd/*

post-install:
	${INSTALL_DATA} ${FILESDIR}/openbsd-packages \
	    ${PREFIX}/share/examples/munin/plugin-conf.d
# remove some plugins which require logtail
	rm ${PREFIX}/libexec/munin/plugins/amavis \
	    ${PREFIX}/libexec/munin/plugins/courier_ \
	    ${PREFIX}/libexec/munin/plugins/mailscanner \
	    ${PREFIX}/libexec/munin/plugins/perdition

.include <bsd.port.mk>
