# New ports collection makefile for:	hoststated
# Date created:				Jan 31 2007
# Whom:					Florent Thoumie <flz@FreeBSD.org>
#
# $FreeBSD$
#

PORTNAME=	hoststated
PORTVERSION=	4.0.${SNAPSHOT}
CATEGORIES=	net
MASTER_SITES=	${MASTER_SITE_LOCAL}
MASTER_SITE_SUBDIR=	flz/hoststated/
DISTFILES=	${PORTNAME}-${SNAPSHOT}.tgz
EXTRACT_ONLY=	${PORTNAME}-${SNAPSHOT}.tgz
SNAPSHOT=	20070131

MAINTAINER=	flz@FreeBSD.org
COMMENT=	Host state daemon for server load-balancing

LIB_DEPENDS=	event-1.2a.1:${PORTSDIR}/devel/libevent

WRKSRC=		${WRKDIR}
MANCOMPRESSED=	yes
USE_RC_SUBR=	hoststated.sh
BUILD_ENV=	BINDIR="${PREFIX}/sbin"	\
		MANDIR="${PREFIX}/man/man"

MAN5=		hoststated.conf.5
MAN8=		hoststatectl.8	\
		hoststated.8

SUBDIRS=	hoststated	\
		hoststatectl

.include <bsd.port.pre.mk>

post-patch:
	@${REINPLACE_CMD} -e 's|-Wbounded|-I/usr/local/include|'	\
			${WRKSRC}/hoststated/Makefile			\
			${WRKSRC}/hoststatectl/Makefile
	@${REINPLACE_CMD} -e 's|-levent|-L/usr/local/lib -levent -lmd|'	\
			${WRKSRC}/hoststated/Makefile
	@${REINPLACE_CMD} -e 's|__dead||' ${WRKSRC}/hoststatectl/hoststatectl.c
	@${REINPLACE_CMD} -e 's|/etc/host|${PREFIX}/etc/host|'		\
			${WRKSRC}/hoststated/hoststated.conf.5		\
			${WRKSRC}/hoststated/hoststated.8		\
			${WRKSRC}/hoststated/hoststated.h

do-build:
.for i in ${SUBDIRS}
	cd ${WRKSRC}/$i; ${SETENV} ${BUILD_ENV} make all
.endfor

do-install:
.for i in ${SUBDIRS}
	cd ${WRKSRC}/$i; ${SETENV} ${BUILD_ENV} make install
.endfor
	${INSTALL_DATA} ${WRKSRC}/hoststated/hoststated.conf ${PREFIX}/etc/hoststated.conf.sample

post-install:
	@if [ ! -f ${PREFIX}/etc/hoststated.conf ]; then \
		${CP} ${PREFIX}/etc/hoststated.conf.sample ${PREFIX}/etc/hoststated.conf; \
	fi
	@${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL

.include <bsd.port.post.mk>
