# Created by: vfom@narod.ru
# $FreeBSD: net-mgmt/netmond/Makefile 327757 2013-09-20 22:24:43Z bapt $

PORTNAME=	netmond
PORTVERSION=	2.2b6
PORTREVISION=	5
CATEGORIES=	net-mgmt
MASTER_SITES=	http://freebsd.unixfreunde.de/sources/ \
		ftp://ftp.risp.ru/pub/RinetSoftware/
DISTNAME=	netmond-2.2-b6
EXTRACT_SUFX=	.tgz

PATCH_SITES=	http://freebsd.unixfreunde.de/sources/ \
		http://vfom.narod.ru/download/
PATCH_VERSION=	1
PATCHFILES=	${DISTNAME}.patch${PATCH_VERSION}${EXTRACT_SUFX}  ${DISTNAME}.docs${EXTRACT_SUFX}

MAINTAINER=	ports@FreeBSD.org
COMMENT=	Netmond - IP network monitoring daemon

USERS=	netmon
GROUPS=	${USERS}

BROKEN=		Does not patch

#MK_IFGRAPH=	yes
PATCHDIR=	${WRKDIR}/patches

GNU_CONFIGURE=	yes
USES=		bison
CFLAGS+=	-Wno-return-type

BINOWN=		root
BINGRP=		netmon
BINMODE=	0550

PLIST_FILES=	sbin/netmond sbin/netmond_watchdog sbin/netmondctl \
		etc/netmond.conf.sample
USE_RC_SUBR=	netmond
SUB_FILES+=	pkg-message netmond_watchdog netmondctl
PORTDOCS=	README README.ru CHANGES README.port.eng README.port.ru index.html netmond.css en/ ru/

OPTIONS_DEFINE=	DOCS GD

NO_STAGE=	yes
.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MGD}
LIB_DEPENDS=	gd:${PORTSDIR}/graphics/gd
PLIST_FILES+=	sbin/ifgraph
.else
CONFIGURE_ARGS=	--without-ifgraph
.endif

post-extract:
	${MKDIR} ${PATCHDIR}
	${TAR} -zxf ${DISTDIR}/${DISTNAME}.patch${PATCH_VERSION}${EXTRACT_SUFX} -C ${PATCHDIR}
	${CP} ${PATCHDIR}/pipe.c ${WRKSRC}

do-install:
	${INSTALL_PROGRAM} ${WRKSRC}/netmond      ${PREFIX}/sbin/netmond
.if defined(MK_IFGRAPH)
	${INSTALL_PROGRAM} ${WRKSRC}/ifgraph      ${PREFIX}/sbin/ifgraph
.endif
	${INSTALL_SCRIPT}   ${WRKDIR}/netmond_watchdog ${PREFIX}/sbin/netmond_watchdog
	${INSTALL_SCRIPT}   ${WRKDIR}/netmondctl ${PREFIX}/sbin/netmondctl
	${INSTALL_DATA} ${WRKSRC}/netmon.conf.sample ${PREFIX}/etc/netmond.conf.sample
	${CHMOD} u+s ${PREFIX}/sbin/netmond
.if ${PORT_OPTIONS:MDOCS}
	@${MKDIR}  ${DOCSDIR}
	${CHMOD} 755 ${DOCSDIR}
	${TAR}  -zxf ${DISTDIR}/${DISTNAME}.docs${EXTRACT_SUFX} -C ${DOCSDIR}
.endif

post-install:
	${CAT} ${PKGMESSAGE}

.include <bsd.port.mk>
