Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / java-vm.mk
blob0a6aa3cab79c278e1ad2bf4a265177bef267d334
1 # $NetBSD: java-vm.mk,v 1.89 2012/11/07 16:26:51 jperkin Exp $
3 # This Makefile fragment handles Java dependencies and make variables,
4 # and is meant to be included by packages that require Java either at
5 # build-time or at run-time.
7 # User-settable variables:
9 # PKG_JVM_DEFAULT
10 # The JVM that should be used if nothing particular is specified.
12 # Possible values: kaffe openjdk7 openjdk7-bin
13 # sun-jdk6 sun-jdk7 jdk15 jdk16
14 # Default value: (platform-dependent)
16 # Package-settable variables:
18 # USE_JAVA
19 # When set to "yes", a build-time dependency on the JDK and
20 # a run-time dependency on the JRE are added.
21 # When set to "run", a run-time dependency on the JRE is added.
22 # When set to "build", a build-time dependency on the JRE is added.
24 # Possible values: yes run build
25 # Default value: yes
27 # USE_JAVA2
28 # When the package needs a Java 2 implementation, this variable
29 # should be set to "yes". It can also be set to "1.4", "1.5", "6"
30 # or "7" require an even more recent implementation.
32 # Possible values: yes no 1.4 1.5 6 7
33 # Default value: no
35 # PKG_JVMS_ACCEPTED
36 # The list of JVMs that may be used as possible implementations.
38 # Variables set by this file:
40 # JAVA_BINPREFIX
41 # The prefix for the Java binaries. The path to the real binaries
42 # is constructed by appending -${program} to it.
44 # Examples:
45 # * ${JAVA_BINPREFIX}-java is the path to the Java interpreter.
46 # * ${JAVA_BINPREFIX}-javac is the path to the Java compiler.
48 # PKG_JVM
49 # The name of the selected Java implementation.
51 # PKG_JAVA_HOME
52 # The directory where the JVM is installed.
55 .if !defined(JAVA_VM_MK)
56 JAVA_VM_MK= # defined
58 _VARGROUPS+= java
59 _USER_VARS.java= PKG_JVM_DEFAULT
60 _PKG_VARS.java= USE_JAVA USE_JAVA2 PKG_JVMS_ACCEPTED
61 _SYS_VARS.java= PKG_JVM PKG_JAVA_HOME JAVA_BINPREFIX
63 .include "../../mk/bsd.prefs.mk"
65 USE_JAVA?= yes
66 USE_JAVA2?= no
68 PKG_JVM_DEFAULT?= # empty
69 PKG_JVMS_ACCEPTED?= ${_PKG_JVMS}
71 # This is a list of all of the JDKs that may be used.
73 _PKG_JVMS.7= openjdk7 openjdk7-bin sun-jdk7
74 _PKG_JVMS.6= ${_PKG_JVMS.7} sun-jdk6 jdk16
75 _PKG_JVMS.1.5= ${_PKG_JVMS.6} jdk15
76 _PKG_JVMS.1.4= ${_PKG_JVMS.1.5}
77 _PKG_JVMS.yes= ${_PKG_JVMS.1.4} kaffe
78 _PKG_JVMS.no= ${_PKG_JVMS.yes}
79 _PKG_JVMS= ${_PKG_JVMS.${USE_JAVA2}}
81 # To be deprecated: if PKG_JVM is explicitly set, then use it as the
82 # default JVM. Note that this has lower precedence than PKG_JVM_DEFAULT.
84 .if defined(PKG_JVM)
85 . if !empty(PKG_JVM)
86 _PKG_JVM_DEFAULT:= ${PKG_JVM}
87 . endif
88 .endif
90 # Set the default JVM for this platform.
92 .if !empty(PKG_JVM_DEFAULT)
93 _PKG_JVM_DEFAULT= ${PKG_JVM_DEFAULT}
94 .endif
95 .if !defined(_PKG_JVM_DEFAULT)
96 . if !empty(MACHINE_PLATFORM:MNetBSD-[456789].*-i386) || \
97 !empty(MACHINE_PLATFORM:MNetBSD-[56789].*-x86_64)
98 _PKG_JVM_DEFAULT?= openjdk7
99 . elif !empty(MACHINE_PLATFORM:MNetBSD-*-i386) || \
100 !empty(MACHINE_PLATFORM:MLinux-*-i[3456]86) || \
101 !empty(MACHINE_PLATFORM:MLinux-*-x86_64)
102 _PKG_JVM_DEFAULT?= sun-jdk6
103 . elif !empty(MACHINE_PLATFORM:MDarwin-*-*)
104 _PKG_JVM_DEFAULT?= sun-jdk6
105 . elif !empty(MACHINE_PLATFORM:MSunOS-5.11-i386) || \
106 !empty(MACHINE_PLATFORM:MSunOS-5.11-x86_64)
107 _PKG_JVM_DEFAULT?= sun-jdk6
108 . elif !empty(MACHINE_PLATFORM:MDragonFly-*-*)
109 _PKG_JVM_DEFAULT?= openjdk7
110 . else
111 _PKG_JVM_DEFAULT?= kaffe
112 . endif
113 .endif
115 # These lists are copied from the JVM package Makefiles.
116 _ONLY_FOR_PLATFORMS.jdk15= \
117 DragonFly-*-* \
118 FreeBSD-8.[1-9]*-i386 FreeBSD-8.[1-9]*-x86_64 \
119 NetBSD-[2-9].*-i386 NetBSD-[4-9].*-x86_64
120 _ONLY_FOR_PLATFORMS.jdk16= \
121 DragonFly-*-* \
122 NetBSD-[2-9].*-i386 NetBSD-[4-9].*-x86_64
123 _ONLY_FOR_PLATFORMS.kaffe= \
124 *-*-alpha *-*-arm *-*-arm32 *-*-i386 *-*-m68k \
125 *-*-mipsel* *-*-sparc *-*-powerpc
126 # exclude *-*-x86_64 from kaffe list as it apparently doesn't work
127 _ONLY_FOR_PLATFORMS.sun-jdk6= \
128 Darwin-9.*-i386 Darwin-9.*-x86_64 \
129 Darwin-10.*-i386 Darwin-10.*-x86_64 \
130 Darwin-11.*-i386 Darwin-11.*-x86_64 \
131 DragonFly-*-i386 \
132 FreeBSD-6.*-i386 \
133 Linux-*-i[3-6]86 \
134 Linux-*-x86_64 \
135 NetBSD-*-i386 NetBSD-*-x86_64 \
136 SunOS-5.11-i386 \
137 SunOS-5.11-x86_64
138 _ONLY_FOR_PLATFORMS.openjdk7= \
139 DragonFly-*-* \
140 NetBSD-[4-9]*-i386 \
141 NetBSD-[5-9]*-x86_64
142 _ONLY_FOR_PLATFORMS.openjdk7-bin= \
143 NetBSD-[5-9]*-i386 \
144 NetBSD-[5-9]*-x86_64
145 _ONLY_FOR_PLATFORMS.sun-jdk7= \
146 Darwin-9.*-i386 Darwin-9.*-x86_64 \
147 Darwin-10.*-i386 Darwin-10.*-x86_64 \
148 Darwin-11.*-i386 Darwin-11.*-x86_64 \
149 DragonFly-*-i386 \
150 FreeBSD-6.*-i386 \
151 Linux-*-i[3-6]86 \
152 Linux-*-x86_64 \
153 NetBSD-[6-9]*-i386 NetBSD-[6-9]*-x86_64 \
154 SunOS-5.11-i386 \
155 SunOS-5.11-x86_64
157 # Set ONLY_FOR_PLATFORM based on accepted JVMs
158 .for _jvm_ in ${PKG_JVMS_ACCEPTED}
159 ONLY_FOR_PLATFORM+= ${_ONLY_FOR_PLATFORMS.${_jvm_}}
160 .endfor
162 # Set the accepted JVMs for this platform.
163 .for _jvm_ in ${_PKG_JVMS}
164 . for _pattern_ in ${_ONLY_FOR_PLATFORMS.${_jvm_}}
165 . if !empty(MACHINE_PLATFORM:M${_pattern_})
166 _PKG_JVMS_ACCEPTED+= ${PKG_JVMS_ACCEPTED:M${_jvm_}}
167 . endif
168 . endfor
169 .endfor
171 _JAVA_PKGBASE.jdk= jdk
172 _JAVA_PKGBASE.jdk14= jdk14
173 _JAVA_PKGBASE.jdk15= jdk15
174 _JAVA_PKGBASE.jdk16= jdk16
175 _JAVA_PKGBASE.kaffe= kaffe
176 _JAVA_PKGBASE.openjdk7= openjdk7
177 _JAVA_PKGBASE.openjdk7-bin= openjdk7-bin
178 _JAVA_PKGBASE.sun-jdk6= sun-jre6
179 _JAVA_PKGBASE.sun-jdk7= sun-jre7
181 # The following is copied from the respective JVM Makefiles.
182 _JAVA_NAME.jdk= jdk11
183 _JAVA_NAME.jdk14= jdk14
184 _JAVA_NAME.kaffe= kaffe
185 _JAVA_NAME.openjdk7= openjdk7
186 _JAVA_NAME.openjdk7-bin= openjdk7-bin
187 _JAVA_NAME.sun-jdk6= sun6
188 _JAVA_NAME.sun-jdk7= sun7
190 # Mark the acceptable JVMs and check which JVM packages are installed.
191 .for _jvm_ in ${_PKG_JVMS_ACCEPTED}
192 _PKG_JVM_OK.${_jvm_}= yes
193 _PKG_JVM_INSTALLED.${_jvm_}!= \
194 if ${PKG_INFO} -qe ${_JAVA_PKGBASE.${_jvm_}}; then \
195 ${ECHO} yes; \
196 else \
197 ${ECHO} no; \
199 .endfor
201 # Use one of the installed JVMs,...
203 .if !defined(_PKG_JVM)
204 . for _jvm_ in ${_PKG_JVMS_ACCEPTED}
205 . if !empty(_PKG_JVM_INSTALLED.${_jvm_}:M[yY][eE][sS])
206 _PKG_JVM?= ${_jvm_}
207 . else
208 _PKG_JVM_FIRSTACCEPTED?= ${_jvm_}
209 . endif
210 . endfor
212 # ...otherwise, prefer the default one if it's accepted,...
214 . if defined(_PKG_JVM_OK.${_PKG_JVM_DEFAULT}) && \
215 !empty(_PKG_JVM_OK.${_PKG_JVM_DEFAULT}:M[yY][eE][sS])
216 _PKG_JVM= ${_PKG_JVM_DEFAULT}
217 . endif
218 .endif
220 # ...otherwise, just use the first accepted JVM.
222 .if !defined(_PKG_JVM)
223 . if defined(_PKG_JVM_FIRSTACCEPTED)
224 _PKG_JVM= ${_PKG_JVM_FIRSTACCEPTED}
225 . endif
226 .endif
228 # If there are no acceptable JVMs, then generate an error.
230 .if !defined(_PKG_JVM)
231 # force an error
232 PKG_FAIL_REASON= "no acceptable JVM found"
233 _PKG_JVM= "none"
234 .endif
236 BUILDLINK_API_DEPENDS.jdk15?= jdk15-[0-9]*
237 BUILDLINK_API_DEPENDS.jdk16?= jdk16-[0-9]*
238 BUILDLINK_API_DEPENDS.kaffe?= kaffe>=1.1.4
239 BUILDLINK_API_DEPENDS.openjdk7?= openjdk7-[0-9]*
240 BUILDLINK_API_DEPENDS.openjdk7-bin?= openjdk7-bin-[0-9]*
241 BUILDLINK_API_DEPENDS.sun-jdk6?= sun-jdk6-[0-9]*
242 BUILDLINK_API_DEPENDS.sun-jre6?= sun-jre6-[0-9]*
243 BUILDLINK_API_DEPENDS.sun-jdk7?= sun-jdk7-[0-9]*
244 BUILDLINK_API_DEPENDS.sun-jre7?= sun-jre7-[0-9]*
246 _JRE.jdk15= jdk15
247 _JRE.jdk16= jdk16
248 _JRE.kaffe= kaffe
249 _JRE.openjdk7= openjdk7
250 _JRE.openjdk7-bin= openjdk7-bin
251 _JRE.sun-jdk6= sun-jre6
252 _JRE.sun-jdk7= sun-jre7
254 _JAVA_BASE_CLASSES= classes.zip
256 .if ${_PKG_JVM} == "jdk15"
257 _JDK_PKGSRCDIR= ../../wip/jdk15
258 _JRE_PKGSRCDIR= ${_JDK_PKGSRCDIR}
259 _JAVA_HOME_DEFAULT= ${LOCALBASE}/java/jdk-1.5.0
260 .elif ${_PKG_JVM} == "jdk16"
261 _JDK_PKGSRCDIR= ../../wip/jdk16
262 _JRE_PKGSRCDIR= ${_JDK_PKGSRCDIR}
263 _JAVA_HOME_DEFAULT= ${LOCALBASE}/java/jdk-1.6.0
264 .elif ${_PKG_JVM} == "kaffe"
265 _JDK_PKGSRCDIR= ../../lang/kaffe
266 _JRE_PKGSRCDIR= ${_JDK_PKGSRCDIR}
267 _JAVA_HOME_DEFAULT= ${LOCALBASE}/java/kaffe
268 .elif ${_PKG_JVM} == "openjdk7"
269 _JDK_PKGSRCDIR= ../../lang/openjdk7
270 _JRE_PKGSRCDIR= ${_JDK_PKGSRCDIR}
271 _JAVA_HOME_DEFAULT= ${LOCALBASE}/java/openjdk7
272 .elif ${_PKG_JVM} == "openjdk7-bin"
273 _JDK_PKGSRCDIR= ../../lang/openjdk7-bin
274 _JRE_PKGSRCDIR= ${_JDK_PKGSRCDIR}
275 _JAVA_HOME_DEFAULT= ${LOCALBASE}/java/openjdk7-bin
276 .elif ${_PKG_JVM} == "sun-jdk6"
277 _JDK_PKGSRCDIR= ../../lang/sun-jdk6
278 _JRE_PKGSRCDIR= ../../lang/sun-jre6
279 _JAVA_HOME_DEFAULT= ${LOCALBASE}/java/sun-6
280 UNLIMIT_RESOURCES+= datasize
281 .elif ${_PKG_JVM} == "sun-jdk7"
282 _JDK_PKGSRCDIR= ../../lang/sun-jdk7
283 _JRE_PKGSRCDIR= ../../lang/sun-jre7
284 _JAVA_HOME_DEFAULT= ${LOCALBASE}/java/sun-7
285 UNLIMIT_RESOURCES+= datasize
286 .endif
288 .if defined(_JAVA_HOME_DEFAULT)
289 _JAVA_HOME= ${_JAVA_HOME_DEFAULT}
290 .else
291 EVAL_PREFIX+= _JAVA_HOME=${_JAVA_PKGBASE.${_PKG_JVM}}
292 .endif
294 # If we are not using Java for building, then we need a run-time dependency on
295 # the JRE, otherwise, build-time dependency on the JRE.
296 .if defined(_JRE_PKGSRCDIR)
297 . if exists(${_JRE_PKGSRCDIR}/buildlink3.mk)
298 . if !empty(USE_JAVA:M[bB][uU][iI][lL][dD])
299 BUILDLINK_DEPMETHOD.${_JRE.${_PKG_JVM}}= build
300 . endif
301 . include "${_JRE_PKGSRCDIR}/buildlink3.mk"
302 . endif
303 .endif
305 # If we are building Java software, then we need a build-time dependency on
306 # the JDK.
308 .if !empty(USE_JAVA:M[yE][eE][sS])
309 . if defined(_JDK_PKGSRCDIR)
310 . if exists(${_JDK_PKGSRCDIR}/buildlink3.mk)
311 . include "${_JDK_PKGSRCDIR}/buildlink3.mk"
312 . endif
313 . endif
314 .endif
316 PKG_JVM:= ${_PKG_JVM}
317 .if defined(BUILDLINK_JAVA_PREFIX.${_PKG_JVM})
318 PKG_JAVA_HOME?= ${BUILDLINK_JAVA_PREFIX.${_PKG_JVM}}
319 .else
320 PKG_JAVA_HOME?= ${_JAVA_HOME}
321 .endif
322 .if !defined(CLASSPATH)
323 CLASSPATH_cmd= ${ECHO} `for p in \
324 ${PKG_JAVA_HOME}/lib/${_JAVA_BASE_CLASSES} \
325 ${PKG_JAVA_HOME}/lib/tools.jar; do \
326 ${TEST} ! -f $$p || ${ECHO} $$p; done` \
327 . | ${TR} ' ' :
328 CLASSPATH?= ${CLASSPATH_cmd:sh}
329 .endif
331 ALL_ENV+= CLASSPATH=${CLASSPATH:Q}
332 ALL_ENV+= JAVA_HOME=${PKG_JAVA_HOME}
333 BUILD_DEFS+= ${_USER_VARS.java}
334 BUILD_DEFS_EFFECTS+= ${_SYS_VARS.java}
335 MAKEFLAGS+= PKG_JVM=${PKG_JVM:Q}
336 PREPEND_PATH+= ${PKG_JAVA_HOME}/bin
337 JAVA_BINPREFIX= ${LOCALBASE}/bin/${_JAVA_NAME.${_PKG_JVM}}
339 PLIST_SUBST+= PKG_JAVA_HOME=${PKG_JAVA_HOME:Q}
340 FILES_SUBST+= PKG_JAVA_HOME=${PKG_JAVA_HOME:Q}
342 .endif # JAVA_VM_MK