summaryrefslogtreecommitdiff
path: root/www/resin2/Makefile
blob: c3640a76a94250681b1396818a12985c1d5f0f68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# New ports collection makefile for:   resin2
# Whom:                                Jean-Baptiste Quenot <jb.quenot@caraldi.com>
# Date Created:                        2002-07-15 15:00:43
#
# ex:ts=20:sw=20
#
# $FreeBSD$
#

PORTNAME=	resin
PORTVERSION=	2.1.11
PORTREVISION=	1
CATEGORIES=	www java
MASTER_SITES=	http://www.caucho.com/download/

MAINTAINER=	jb.quenot@caraldi.com
COMMENT=	Resin, a Java-based Application Server, 2.x branch

USE_JAVA=	1.2+
HAS_CONFIGURE=	yes
USE_PERL5=	yes

# Customizable settings
RUNASUSER?=	www
RUNASUID?=	80
GROUP?=	${RUNASUSER}
GID?=	${RUNASUID}
PORT?=	8080
# Do not use PKGNAMESUFFIX here because version info is already in PORTVERSION
# If we used PKGNAMESUFFIX, the package name would be resin2-2.1.11
APP_NAME_SUFFIX=	${PORTVERSION:C/\..*$//}
APP_NAME?=	${PORTNAME}${APP_NAME_SUFFIX}
APP_HOME?=	${PREFIX}/${APP_NAME}
WITH_APACHE?=	NO
WITH_APACHE2?=	NO
PID_FILE?=	/var/run/${APP_NAME}.pid

# Other settings
APXS?=	${LOCALBASE}/sbin/apxs
MOD_DIR?=	`${APXS} -q LIBEXECDIR`
PKGINSTALL=	${WRKDIR}/pkg-install
PKGDEINSTALL=	${WRKDIR}/pkg-deinstall
PKGMESSAGE=	${WRKDIR}/pkg-message
# We need WRKSRC and WRKDIR right now so define them "manually"
WRKSRC=	${WRKDIR}/${PORTNAME}-${PORTVERSION}
WRKDIR?=	${WRKDIRPREFIX}${.CURDIR}/work
REINPLACE_FILES=	${WRKSRC}/src/c/plugin/apache/Makefile.in \
	${WRKSRC}/src/c/plugin/apache2/Makefile.in
REPLACE_FILES=	${FILESDIR}/pkg-install \
	${FILESDIR}/pkg-deinstall \
	${FILESDIR}/install.sh \
	${FILESDIR}/pkg-message.in \
	${WRKSRC}/conf/resin.conf \
	${WRKSRC}/bin/wrapper.pl.in \
	${FILESDIR}/resin.sh.in

# Pass JAVA_HOME as determined by bsd.java.mk
CONFIGURE_ARGS+=	--with-java-home=${JAVA_HOME}

# Install the Apache plugin if needed
.if defined(WITH_APACHE) && (${WITH_APACHE} == yes || ${WITH_APACHE} == YES)
#
# Apache 1.3
#
BUILD_DEPENDS+=	${APXS}:${PORTSDIR}/www/apache13
CONFIGURE_ARGS+=	--with-apxs=${APXS}
PLIST_SUB+=	MOD_DIR=libexec/apache
# Allow apxs invocations
PLIST_SUB+=	APACHE=""
.elif defined(WITH_APACHE2) && (${WITH_APACHE2} == yes || ${WITH_APACHE2} == YES)
#
# Apache 2
#
BUILD_DEPENDS+=	${APXS}:${PORTSDIR}/www/apache2
CONFIGURE_ARGS+=	--with-apxs=${APXS}
PLIST_SUB+=	MOD_DIR=libexec/apache2
# Allow apxs invocations
PLIST_SUB+=	APACHE=""
.else
PLIST_SUB+=	MOD_DIR="@comment "
# Prevent apxs invocations
PLIST_SUB+=	APACHE="@comment "
.endif

PLIST_SUB+=	APP_NAME=${APP_NAME}
PLIST_SUB+=	APXS=${APXS}

SUBSTITUTIONS=	-e "s|%%APP_HOME%%|${APP_HOME}|g" \
	-e "s|%%APP_NAME%%|${APP_NAME}|g" \
	-e "s|%%APXS%%|${APXS}|g" \
	-e "s|%%FILESDIR%%|${FILESDIR}|g" \
	-e "s|%%GROUP%%|${GROUP}|g" \
	-e "s|%%GID%%|${GID}|g" \
	-e "s|%%JAVA_HOME%%|${JAVA_HOME}|g" \
	-e "s|%%PERL%%|${PERL}|g" \
	-e "s|%%PID_FILE%%|${PID_FILE}|g" \
	-e "s|%%PORT%%|${PORT}|g" \
	-e "s|%%PORTNAME%%|${PORTNAME}|g" \
	-e "s|%%PREFIX%%|${PREFIX}|g" \
	-e "s|%%RUNASUID%%|${RUNASUID}|g" \
	-e "s|%%RUNASUSER%%|${RUNASUSER}|g" \
	-e "s|%%WRKDIR%%|${WRKDIR}|g" \
	-e "s|%%WRKSRC%%|${WRKSRC}|g"

.include <bsd.port.pre.mk>

post-patch:
.for FILE in ${REINPLACE_FILES}
	@${SED} -i bak ${SUBSTITUTIONS} ${FILE}
.endfor
.for FILE in ${REPLACE_FILES}
	@${SED} ${SUBSTITUTIONS} ${FILE} > ${WRKDIR}/`basename ${FILE}`
.endfor
	@fmt -w 80 < ${WRKDIR}/pkg-message.in > ${PKGMESSAGE}
.if (defined(WITH_APACHE2) && (${WITH_APACHE2} == yes || ${WITH_APACHE2} == YES) || \
defined(WITH_APACHE) && (${WITH_APACHE} == yes || ${WITH_APACHE} == YES))
	@${ECHO_CMD} >> ${PKGMESSAGE}
	@${ECHO_CMD} The Resin Apache module mod_caucho has been activated \
	in the Apache configuration file, where you should also \
	add a line to specify the location of the Resin configuration \
	file, for example: | fmt -w 80 >> ${PKGMESSAGE}
	@${ECHO_CMD} CauchoConfigFile ${PREFIX}/etc/${APP_NAME}.xml >> ${PKGMESSAGE}
.endif
	@${MV} ${WRKDIR}/wrapper.pl.in ${WRKSRC}/bin/wrapper.pl.in

# Resin does not handle installation, so proceed now
post-install:
	@${SH} ${WRKDIR}/install.sh
	@${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
	@${ECHO_CMD}
	@${ECHO_CMD} "********************************************************************************"
	@${CAT} ${PKGMESSAGE}
	@${ECHO_CMD} "********************************************************************************"
	@${ECHO_CMD}

.include <bsd.port.post.mk>