Subject: Non-pkgsrc JDK support for Solaris
To: None <tech-pkg@netbsd.org>
From: Gavan Fantom <gavan@coolfactor.org>
List: tech-pkg
Date: 09/22/2003 19:09:01
Hi folks,

I've been wondering what to do with Java packages on Solaris. There's
obviously no need to depend on a pkgsrc JVM when we have a nicely working
JVM in /usr/java.

Here's a rather rough set of diffs to java-vm.mk to allow a non-pkgsrc JVM
to be used. It could probably be improved on, so here it is for
discussion.

In particular, I wasn't sure whether to leave sun-jdk14 to mean
pkgsrc-sun-jdk14, or to special-case sun-jdk14 to mean non-pkgsrc java if
present. Also, whether "native" is extensible enough to cover non-pkgsrc
java on other systems.

So, comments?


Index: java-vm.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/java-vm.mk,v
retrieving revision 1.16
diff -u -r1.16 java-vm.mk
--- java-vm.mk	2003/09/02 06:59:47	1.16
+++ java-vm.mk	2003/09/22 17:58:13
@@ -45,7 +45,7 @@
 .if defined(USE_JAVA2) && !empty(USE_JAVA2:M[yY][eE][sS])
 _PKG_JVMS?=		sun-jdk13 sun-jdk14 blackdown-jdk13 wonka jdk12 jdk13
 .else
-_PKG_JVMS?=		jdk sun-jdk13 sun-jdk14 blackdown-jdk13 kaffe wonka jdk12 jdk13
+_PKG_JVMS?=		jdk sun-jdk13 sun-jdk14 blackdown-jdk13 kaffe wonka jdk12 jdk13 native
 .endif

 # To be deprecated: if PKG_JVM is explicitly set, then use it as the
@@ -70,6 +70,8 @@
 _PKG_JVM_DEFAULT?=	blackdown-jdk13
 .  elif !empty(MACHINE_PLATFORM:MDarwin-*-*)
 _PKG_JVM_DEFAULT?=	sun-jdk
+.  elif !empty(MACHINE_PLATFORM:MSunOS-*-*)
+_PKG_JVM_DEFAULT?=	native
 .  else
 _PKG_JVM_DEFAULT?=	kaffe
 .  endif
@@ -97,6 +99,8 @@
 	*-*-arm32 *-*-i386 *-*-m68k *-*-mips* *-*-sparc *-*-powerpc
 _ONLY_FOR_PLATFORMS.wonka= \
 	*-*-arm32 *-*-i386
+_ONLY_FOR_PLATFORMS.native= \
+	SunOS-*-*

 # Set the accepted JVMs for this platform.
 .for _jvm_ in ${_PKG_JVMS}
@@ -119,14 +123,20 @@
 # Mark the acceptable JVMs and check which JVM packages are installed.
 .for _jvm_ in ${_PKG_JVMS_ACCEPTED}
 _PKG_JVM_OK.${_jvm_}=	yes
+.  if defined(_JAVA_PKGBASE.${_jvm_})
 _PKG_JVM_INSTALLED.${_jvm_}!= \
 	if ${PKG_INFO} -qe ${_JAVA_PKGBASE.${_jvm_}}; then		\
 		${ECHO} yes;						\
 	else								\
 		${ECHO} no;						\
 	fi
+.  endif
 .endfor

+.if !empty(_PKG_JVMS_ACCEPTED:Mnative) && exists(/usr/java)
+_PKG_JVM_INSTALLED.native=yes
+.endif
+
 # 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.
@@ -205,6 +215,7 @@
 _JRE.blackdown-jdk13=	blackdown-jre13
 _JRE.kaffe=		kaffe
 _JRE.wonka=		wonka
+_JRE.native=		native

 _JAVA_BASE_CLASSES=	classes.zip

@@ -248,9 +259,13 @@
 _JAVA_HOME_DEFAULT=	${LOCALBASE}/java/wonka
 _JAVA_BASE_CLASSES=	wre.jar
 SCRIPTS_ENV+=		JAVAC="jikes"
+.elif ${_PKG_JVM} == "native"
+_JAVA_HOME_DEFAULT=	/usr/java/jre
 .endif
+.if empty(_PKG_JVM:Mnative)
 _JDK_DEPENDENCY?=	${BUILDLINK_DEPENDS.${_PKG_JVM}}:${_JDK_PKGSRCDIR}
 _JRE_DEPENDENCY?=	${BUILDLINK_DEPENDS.${_JRE.${_PKG_JVM}}}:${_JRE_PKGSRCDIR}
+.endif

 EVAL_PREFIX+=		_JAVA_HOME=${_JAVA_PKGBASE.${_PKG_JVM}}

@@ -267,12 +282,12 @@
 # the JDK.
 #
 .if empty(USE_JAVA:M[rR][uU][nN])
-.  if defined(USE_BUILDLINK2) && empty(USE_BUILDLINK2:M[nN][oO])
-.    if defined(_JDK_PKGSRCDIR)
+.  if defined(_JDK_PKGSRCDIR)
+.    if defined(USE_BUILDLINK2) && empty(USE_BUILDLINK2:M[nN][oO])
 .      include "${_JDK_PKGSRCDIR}/buildlink2.mk"
-.    endif
-.  else
+.    else
 BUILD_DEPENDS+=		${_JDK_DEPENDENCY}
+.    endif
 .  endif
 .endif


-- 
Gillette - the best a man can forget