# New ports collection makefile for:	xgate
# Date created:				2005/10/22
# Whom:					nork@FreeBSD.org
#
# $FreeBSD: ports/japanese/xgate/Makefile,v 1.14 2011/11/07 20:59:27 dougb Exp $

PORTNAME=	xgate
PORTVERSION=	3.7pl6
CATEGORIES=	japanese mail www java
MASTER_SITES=	http://www.orangesoft.co.jp/index.php/download_file/-/192/
DISTNAME=	${PORTNAME}pkg${PORTVERSION}
EXTRACT_SUFX=	.tgz

MAINTAINER=	nork@FreeBSD.org
COMMENT=	xGate webmail system implemented by Servlet over IMAP4/POP3

RUN_DEPENDS=	${APP_HOME}/bin/bootstrap.jar:${PORTSDIR}/www/tomcat6

NO_BUILD=	yes
USE_JAVA=	yes
JAVA_VERSION=	1.6+
SHAREOWN=	www
SHAREGRP=	www

PLIST_SUB=	T=${APP_HOME:S|^${LOCALBASE}/||} \
		WWWUID=${WWWUID} WWWGID=${WWWGID}

PORTDOCS=	AdminGuide.pdf \
		BasicPkgInstallGuide.pdf \
		ConfigSetupGuide.pdf \
		LDAPSchema_V35_37.xls \
		PCUserGuide.pdf \
		ReleaseNote_V3.5.2.pdf \
		ReleaseNote_V3.5.2PL1.pdf \
		ReleaseNote_V3.5.2PL2.pdf \
		ReleaseNote_V3.5.2PL3_3.7.pdf \
		ReleaseNote_V3.5.2PL4_3.7PL1.pdf \
		ReleaseNote_V3.5.2PL5_3.7PL2.pdf \
		ReleaseNote_V3.5.2PL6_3.7PL3.pdf \
		ReleaseNote_V3.5.2PL7_3.7PL4.pdf \
		ReleaseNote_V3.5.2PL8_3.7PL5.pdf \
		ReleaseNote_V3.5.2PL9_3.7PL6.pdf \
		UserGuide.pdf

RESTRICTED=	Commercial license

.include <bsd.port.pre.mk>

.if ${OSVERSION} < 800000
EXTRACT_DEPENDS=	unzip:${PORTSDIR}/archivers/unzip
.endif

APP_HOME!=	${MAKE} -C ${PORTSDIR}/www/tomcat6 -VAPP_HOME

CNFLSTS=	account/admin.ndt	\
		account/license.dat	\
		conf/access.dat		\
		conf/address.data	\
		conf/address.map	\
		conf/admin.ldif		\
		conf/admin_group.ldif	\
		conf/createuser.conf	\
		conf/device_match.conf	\
		conf/entry.data		\
		conf/extra.types	\
		conf/group.data		\
		conf/group.map		\
		conf/ldap.map		\
		conf/log.conf		\
		conf/terminal.dat	\
		conf/user.data		\
		conf/xgate.conf

post-extract:
	@${MKDIR} ${WRKSRC}/xgate
.if ${OSVERSION} < 800000
	@${UNZIP_CMD} ${WRKSRC}/xgate.war -d ${WRKSRC}/xgate
.else
	@${TAR} xvf ${WRKSRC}/xgate.war -C ${WRKSRC}/xgate
.endif
.for conf in ${CNFLSTS}
	@cd ${WRKSRC}/xgate/WEB-INF && ${MV} ${conf} ${conf}-dist
.endfor

post-patch:
	${FIND} ${WRKSRC} -name \*.orig -print0 | ${XARGS} -0 ${RM}

do-install:
	${INSTALL} -d -o ${WWWOWN} -g ${WWWGRP} /var/log/xgate
	${INSTALL} -d -o ${WWWOWN} -g ${WWWGRP} ${APP_HOME}/webapps/${PORTNAME}
	@cd ${WRKSRC}/${PORTNAME} && ${COPYTREE_SHARE} \* ${APP_HOME}/webapps/${PORTNAME}
.for conf in ${CNFLSTS}
	@cd ${APP_HOME}/webapps/xgate/WEB-INF && \
		[ ! -f ${conf} ] && ${CP} -p ${conf}-dist ${conf} || ${TRUE}
.endfor
.if !defined(NOPORTDOCS)
	@${MKDIR} ${DOCSDIR}
.for docf in ${PORTDOCS}
	@${INSTALL_DATA} ${WRKSRC}/docs/${docf} ${DOCSDIR}
.endfor
.endif

.include <bsd.port.post.mk>
