summaryrefslogtreecommitdiff
path: root/mk/java-env.mk
blob: e4c9e2d59e1f713a6f37a9f8f5f043f84855fff2 (plain)
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
# $NetBSD: java-env.mk,v 1.9 2007/02/18 16:25:54 tv Exp $
#
# This Makefile fragment handles Java wrappers and is meant to be included
# by packages that provide a Java build-time and/or run-time environment.
#
# The following variables can be defined in package Makefiles to tune the
# behavior of this file:
#
#	JAVA_CLASSPATH	Classpath that will be prepended on all invocations
#			to this implementation.  Optional.
#
#	JAVA_LD_LIBRARY_PATH
#			Value to prepend to LD_LIBRARY_PATH before running
#			the real command.  Optional; use *only* if necessary.
#
#	JAVA_HOME	Path to the directory holding the Java implementation.
#			Required.
#
#	JAVA_NAME	Base name of the Java implementation.  This will be
#			used as part of wrappers' names.  Required.
#
#	JAVA_UNLIMIT	List of resources to be unlimited at runtime.
#			Can include any of cmdsize, datasize and stacksize.
#			Optional.
#
#	JAVA_WRAPPERS	List of wrappers to be created under ${PREFIX}/bin,
#			pointing to binaries under ${JAVA_HOME}/bin.  The
#			names must match files in the later directory.
#			Required (if empty, the inclusion of this file is
#			useless).
#

.if !defined(JAVA_ENV_MK)
JAVA_ENV_MK=		# defined

JAVA_NAME?=		# undefined
JAVA_HOME?=		# undefined
JAVA_CLASSPATH?=	# empty
JAVA_LD_LIBRARY_PATH?=	# empty
JAVA_UNLIMIT?=		# empty
JAVA_WRAPPERS?=		# empty

.include "../../mk/bsd.prefs.mk"

.if !empty(JAVA_WRAPPERS)
INSTALLATION_DIRS+=	bin

ALTERNATIVES_SRC=	${WRKDIR}/.ALTERNATIVES
${WRKDIR}/.ALTERNATIVES:
.  for w in ${JAVA_WRAPPERS}
	@${ECHO} 'bin/${w} ${PREFIX}/bin/${JAVA_NAME}-${w}' \
		>>${WRKDIR}/.ALTERNATIVES
.  endfor

.  for w in ${JAVA_WRAPPERS}

JAVA_WRAPPER_BIN.${w}?=	${JAVA_HOME}/bin/${w}

post-build:		${WRKDIR}/${w}

.PHONY:			install-java-wrapper-${w}
post-install:		install-java-wrapper-${w}

.    if !target(${WRKDIR}/${w})
${WRKDIR}/${w}:
	@${ECHO} 'Generating ${w} wrapper...'
	@${ECHO} '#! ${SH}' >${WRKDIR}/${w}
	@${ECHO} 'PATH=${JAVA_HOME}/bin:$${PATH}; export PATH' >>${WRKDIR}/${w}
	@${ECHO} 'JAVA_HOME=${JAVA_HOME}; export JAVA_HOME' >>${WRKDIR}/${w}
	@${ECHO} 'JVM_HOME=${JAVA_HOME}; export JVM_HOME' >>${WRKDIR}/${w}
.      if !empty(JAVA_CLASSPATH)
	@${ECHO} 'CLASSPATH=${JAVA_CLASSPATH}:$${CLASSPATH}; export CLASSPATH' \
		>>${WRKDIR}/${w}
.      endif
.      if !empty(JAVA_LD_LIBRARY_PATH)
	@${ECHO} 'LD_LIBRARY_PATH=${JAVA_LD_LIBRARY_PATH}$${LD_LIBRARY_PATH:+:}$${LD_LIBRARY_PATH}; export LD_LIBRARY_PATH' \
		>>${WRKDIR}/${w}
.      endif
.      for f in ${JAVA_UNLIMIT}
	@${ECHO} '${ULIMIT_CMD_${f}}' >>${WRKDIR}/${w}
.      endfor
.      undef f
	@${ECHO} '${JAVA_WRAPPER_BIN.${w}} "$$@"' >>${WRKDIR}/${w}
.    endif

install-java-wrapper-${w}:
	${INSTALL_SCRIPT} ${WRKDIR}/${w} ${PREFIX}/bin/${JAVA_NAME}-${w}

.  endfor
.  undef w
.endif

# Handle the ${PREFIX}/java shared directory automatically.
REQD_DIRS+=		${PREFIX}/java
PRINT_PLIST_AWK+=	/^@dirrm java$$/ { next; }

.endif	# JAVA_ENV_MK