summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam>2002-10-13 09:29:12 +0000
committerjlam <jlam>2002-10-13 09:29:12 +0000
commit6d5a42ba1c8c1546a0933f66ab0e19e47e70e71a (patch)
tree9d1c5b50b83abb548ec390aee6592013df86ea7e /mk
parentd47e8c8e601aa40d18151e4ca72b70dffa10248f (diff)
downloadpkgsrc-6d5a42ba1c8c1546a0933f66ab0e19e47e70e71a.tar.gz
Initial cut at java.mk that completely replaces the USE_JAVA-handling code
in bsd.pkg.mk. The java.mk Java handling is largely based on the lang/python/pyversion.mk file. There are two new variables: PKG_JVM_DEFAULT is a user-settable variable whose value is the default JVM to use. PKG_JVMS_ACCEPTED is a package-settable list of JVMs that may be used as possible dependencies for the package. Two existing variables have been redefined to be only read-only, though there is some logic to handle legacy /etc/mk.conf which may contain an explicit PKG_JVM=... PKG_JVM is a publicly readable variable containing the name of the JVM we will be using. PKG_JAVA_HOME is a publicly readable variable containing ${JAVA_HOME} for the PKG_JVM described above. To do: Have some way to specify which JVMs are acceptable for each platform, and use the intersection of these JVMs and the ones listed in PKG_JVMS_ACCEPTED as the JVMS that may really be used. Currently, we assume all of the JVMs are usable by all platforms. I'm not sure if Darwin's special stub sun-{jre,jdk}13 packages are usable by buildlink2. This needs to be verified.
Diffstat (limited to 'mk')
-rw-r--r--mk/java.mk213
1 files changed, 213 insertions, 0 deletions
diff --git a/mk/java.mk b/mk/java.mk
new file mode 100644
index 00000000000..369aac1b13d
--- /dev/null
+++ b/mk/java.mk
@@ -0,0 +1,213 @@
+# $NetBSD: java.mk,v 1.1 2002/10/13 09:29:12 jlam Exp $
+#
+# This Makefile fragment handles Java dependencies and make variables,
+# and is meant to be included by packages that require Java either at
+# build-time or at run-time. java.mk will:
+#
+# * set PKG_JVM and PKG_JAVA_HOME to the name of the JVM used and
+# to the directory in which the JVM is installed, respectively;
+#
+# * add a full dependency on the JRE and possibly a build dependency
+# on the JDK, based on the value of USE_JAVA (if nonempty). You
+# must explicitly set USE_JAVA=build to add the build dependency
+# on the JDK;
+#
+# There are two variables used to tweak the JVM selection:
+#
+# PKG_JVM_DEFAULT is a user-settable variable whose value is the default
+# JVM to use.
+#
+# PKG_JVMS_ACCEPTED is a package-settable list of JVMs that may be used as
+# possible dependencies for the package.
+#
+# TODO:
+#
+# * Have some way to specify which JVMs are acceptable for each
+# platform, and use the intersection of these JVMs and the ones
+# listed in PKG_JVMS_ACCEPTED as the JVMS that may really be used.
+# Currently, we assume all of the JVMs are usable by all platforms.
+
+.if !defined(JAVA_MK)
+JAVA_MK= # defined
+
+.include "../../mk/bsd.prefs.mk"
+
+# By default, assume we need the JDK.
+USE_JAVA?= # empty
+.if !empty(USE_JAVA:M[rR][uU][nN])
+USE_JAVA= run
+.endif
+
+PKG_JVM_DEFAULT?= # empty
+PKG_JVMS_ACCEPTED?= jdk sun-jdk13 sun-jdk14 blackdown-jdk13 kaffe
+
+# To be deprecated: if PKG_JVM is explicitly set, then use it as the
+# default JVM. Note that this has lower precedence than PKG_JVM_DEFAULT.
+#
+.if defined(PKG_JVM)
+. if !empty(PKG_JVM)
+_PKG_JVM_DEFAULT:= ${PKG_JVM}
+. endif
+.endif
+
+# Set the default JVM for this platform.
+#
+.if !empty(PKG_JVM_DEFAULT)
+_PKG_JVM_DEFAULT= ${PKG_JVM_DEFAULT}
+.endif
+.if !defined(_PKG_JVM_DEFAULT)
+. if !empty(MACHINE_PLATFORM:MNetBSD-*-i386) || \
+ !empty(MACHINE_PLATFORM:MLinux-*-i[3456]86)
+_PKG_JVM_DEFAULT?= jdk
+. elif !empty(MACHINE_PLATFORM:MNetBSD-*-powerpc)
+_PKG_JVM_DEFAULT?= blackdown-jdk13
+. elif !empty(MACHINE_PLATFORM:MDarwin-*-*)
+_PKG_JVM_DEFAULT?= sun-jdk
+. else
+_PKG_JVM_DEFAULT?= kaffe
+. endif
+.endif
+
+# Set the accepted JVMs for this platform.
+_PKG_JVMS_ACCEPTED= ${PKG_JVMS_ACCEPTED}
+
+_JAVA_PKGBASE.jdk= jdk
+_JAVA_PKGBASE.sun-jdk13= sun-jdk13
+_JAVA_PKGBASE.sun-jdk14= sun-jdk14
+_JAVA_PKGBASE.blackdown-jdk13= blackdown-jdk13
+_JAVA_PKGBASE.kaffe= kaffe
+
+# Mark the acceptable JVMs and check which JVM packages are installed.
+.for _jvm_ in ${_PKG_JVMS_ACCEPTED}
+_PKG_JVM_OK.${_jvm_}= yes
+_PKG_JVM_INSTALLED.${_jvm_}!= \
+ if ${PKG_INFO} -qe ${_JAVA_PKGBASE.${_jvm_}}; then \
+ ${ECHO} yes; \
+ else \
+ ${ECHO} no; \
+ fi
+.endfor
+
+# Convert "sun-jdk" into "sun-jdk13" or "sun-jdk14" depending on the
+# platform. Recent versions of NetBSD and Linux can use either the 1.3
+# or 1.4 version of the Sun JDK, so default to the newer installed one.
+#
+.if ${_PKG_JVM_DEFAULT} == "sun-jdk"
+. if !empty(MACHINE_PLATFORM:MNetBSD-1.5Z[A-Z]-i386) || \
+ !empty(MACHINE_PLATFORM:MNetBSD-1.[6-9]*-i386) || \
+ !empty(MACHINE_PLATFORM:MLinux-*-i[3456]86)
+. if defined(_PKG_JVM_INSTALLED.sun-jdk14) && \
+ (${_PKG_JVM_INSTALLED.sun-jdk14} == "yes")
+_PKG_JVM_DEFAULT= sun-jdk14
+. elif defined(_PKG_JVM_INSTALLED.sun-jdk13) && \
+ (${_PKG_JVM_INSTALLED.sun-jdk13} == "yes")
+_PKG_JVM_DEFAULT= sun-jdk13
+. else
+_PKG_JVM_DEFAULT= sun-jdk14
+. endif
+. elif !empty(MACHINE_PLATFORM:MNetBSD-*-i386) || \
+ !empty(MACHINE_PLATFORM:MDarwin-*-*)
+_PKG_JVM_DEFAULT= sun-jdk13
+. endif
+.endif
+
+# Use one of the installed JVMs,...
+#
+.if !defined(_PKG_JVM)
+. for _jvm_ in ${_PKG_JVMS_ACCEPTED}
+. if !empty(_PKG_JVM_INSTALLED.${_jvm_}:M[yY][eE][sS])
+_PKG_JVM?= ${_jvm_}
+. else
+_PKG_JVM_FIRSTACCEPTED?= ${_jvm_}
+. endif
+. endfor
+#
+# ...otherwise, prefer the default one if it's accepted,...
+#
+. if defined(_PKG_JVM_OK.${_PKG_JVM_DEFAULT}) && \
+ !empty(_PKG_JVM_OK.${_PKG_JVM_DEFAULT}:M[yY][eE][sS])
+_PKG_JVM= ${_PKG_JVM_DEFAULT}
+. endif
+.endif
+#
+# ...otherwise, just use the first accepted JVM.
+#
+.if !defined(_PKG_JVM)
+_PKG_JVM= ${PKG_JVM_FIRSTACCEPTED}
+.endif
+
+BUILDLINK_DEPENDS.jdk?= jdk-[0-9]*
+BUILDLINK_DEPENDS.sun-jdk13?= sun-jdk13-[0-9]*
+BUILDLINK_DEPENDS.sun-jdk14?= sun-jdk14-[0-9]*
+BUILDLINK_DEPENDS.blackdown-jdk13?= blackdown-jdk13-[0-9]*
+BUILDLINK_DEPENDS.kaffe?= kaffe-[0-9]*
+
+.if ${_PKG_JVM} == "jdk"
+_JDK_PKGSRCDIR= ../../lang/jdk
+_JRE_PKGSRCDIR= ../../lang/jdk
+_JRE_DEPENDENCY= jdk-[0-9]*:${_JRE_PKGSRCDIR}
+_JAVA_HOME_DEFAULT= ${LOCALBASE}/java/jdk-1.1.8
+.elif ${_PKG_JVM} == "sun-jdk13"
+_JDK_PKGSRCDIR= ../../lang/sun-jdk13
+_JRE_PKGSRCDIR= ../../lang/sun-jre13
+_JRE_DEPENDENCY= sun-jre13-[0-9]*:${_JRE_PKGSRCDIR}
+_JAVA_HOME_DEFAULT= ${LOCALBASE}/java/sun-1.3.1
+.elif ${_PKG_JVM} == "sun-jdk14"
+_JDK_PKGSRCDIR= ../../lang/sun-jdk14
+_JRE_PKGSRCDIR= ../../lang/sun-jre14
+_JRE_DEPENDENCY= sun-jre14-[0-9]*:${_JRE_PKGSRCDIR}
+_JAVA_HOME_DEFAULT= ${LOCALBASE}/java/sun-1.4.0
+UNLIMIT_RESOURCES+= datasize
+.elif ${_PKG_JVM} == "blackdown-jdk13"
+_JDK_PKGSRCDIR= ../../lang/blackdown-jdk13
+_JRE_PKGSRCDIR= ../../lang/blackdown-jre13
+_JRE_DEPENDENCY= blackdown-jre13-[0-9]*:${_JRE_PKGSRCDIR}
+_JAVA_HOME_DEFAULT= ${LOCALBASE}/java/blackdown-1.3.1
+.elif ${_PKG_JVM} == "kaffe"
+_JDK_PKGSRCDIR= ../../lang/kaffe
+_JRE_PKGSRCDIR= ../../lang/kaffe
+_JRE_DEPENDENCY= kaffe-[0-9]*:${_JRE_PKGSRCDIR}
+_JAVA_HOME_DEFAULT= ${LOCALBASE}/java/kaffe
+.endif
+_JDK_DEPENDENCY?= ${BUILDLINK_DEPENDS.${_PKG_JVM}}:${_JDK_PKGSRCDIR}
+
+EVAL_PREFIX+= _JAVA_HOME=${_JAVA_PKGBASE.${_PKG_JVM}}
+
+# We always need a run-time dependency on the JRE.
+.if defined(USE_BUILDLINK2)
+. include "${_JRE_PKGSRCDIR}/buildlink2.mk"
+.else
+DEPENDS+= ${_JRE_DEPENDENCY}
+.endif
+
+# If we are building Java software, then we need a build-time dependency on
+# the JDK.
+#
+.if ${USE_JAVA} != "run"
+. if defined(USE_BUILDLINK2)
+. include "${_JDK_PKGSRCDIR}/buildlink2.mk"
+. else
+BUILD_DEPENDS+= ${_JDK_DEPENDENCY}
+. endif
+.endif
+
+# PKG_JVM is a publicly readable variable containing the name of the JVM
+# we will be using.
+#
+# PKG_JAVA_HOME is a publicly readable variable containing ${JAVA_HOME}
+# for the PKG_JVM described above.
+#
+PKG_JVM:= ${_PKG_JVM}
+.if defined(BUILDLINK_JAVA_PREFIX.${_PKG_JVM})
+PKG_JAVA_HOME?= ${BUILDLINK_JAVA_PREFIX.${_PKG_JVM}}
+.else
+PKG_JAVA_HOME?= ${_JAVA_HOME}
+.endif
+BUILD_DEFS+= PKG_JVM PKG_JAVA_HOME
+PATH:= ${PKG_JAVA_HOME}/bin:${PATH}
+
+MAKE_ENV+= JAVA_HOME=${PKG_JAVA_HOME}
+CONFIGURE_ENV+= JAVA_HOME=${PKG_JAVA_HOME}
+SCRIPTS_ENV+= JAVA_HOME=${PKG_JAVA_HOME}
+
+.endif # JAVA_MK