Subject: java, builtin.mk, OS X
To: None <tech-pkg@NetBSD.org>
From: Dan Winship <danw@NetBSD.org>
List: tech-pkg
Date: 09/06/2004 18:22:47
--Apple-Mail-7-238050516
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

The attached patch is my attempt to clean up the current hacks in 
lang/sun-j*13 to deal with Darwin, by making it use builtin.mk instead. 
It seems to work with java 1.4 on OS X 10.3 but I'd appreciate it if 
the relevant java and buildlink experts could review this, and if 
people with java-1.3 versions of OS X could make sure it still works 
there too. (If it doesn't work, reverting the java-vm.mk part of the 
patch may fix it; it should have two separate Darwin cases, but I don't 
know what version the 1.3->1.4 switch happened at.)

-- Dan


--Apple-Mail-7-238050516
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="java.diff"
Content-Disposition: attachment;
	filename=java.diff

Index: mk/java-vm.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/java-vm.mk,v
retrieving revision 1.32
diff -u -r1.32 java-vm.mk
--- mk/java-vm.mk	29 Jul 2004 14:43:16 -0000	1.32
+++ mk/java-vm.mk	6 Sep 2004 22:08:15 -0000
@@ -93,7 +93,7 @@
 	NetBSD-*-i386 Linux-*-i[3-6]86 Darwin-*-*
 _ONLY_FOR_PLATFORMS.sun-jdk14= \
 	NetBSD-1.5Z[A-Z]-i386 NetBSD-1.[6-9]*-i386 NetBSD-[2-9].*-i386 \
-	Linux-*-i[3-6]86
+	Linux-*-i[3-6]86 Darwin-*-*
 _ONLY_FOR_PLATFORMS.kaffe= \
 	*-*-alpha *-*-arm *-*-arm32 *-*-i386 *-*-m68k *-*-mips* *-*-sparc *-*-powerpc
 _ONLY_FOR_PLATFORMS.wonka= \
@@ -146,7 +146,7 @@
 .    endif
 .  elif !empty(MACHINE_PLATFORM:MNetBSD-*-i386) || \
 	!empty(MACHINE_PLATFORM:MDarwin-*-*)
-_PKG_JVM_DEFAULT=	sun-jdk13
+_PKG_JVM_DEFAULT=	sun-jdk14
 .  endif
 .endif
 
Index: lang/sun-jdk13/PLIST.Darwin
===================================================================
RCS file: lang/sun-jdk13/PLIST.Darwin
diff -N lang/sun-jdk13/PLIST.Darwin
--- lang/sun-jdk13/PLIST.Darwin	30 Jun 2002 15:01:48 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,2 +0,0 @@
-@comment $NetBSD: PLIST.Darwin,v 1.1 2002/06/30 15:01:48 schmonz Exp $
-@comment Darwin ships with a JDK based on Sun's 1.3.1 release.
Index: lang/sun-jdk13/builtin.mk
===================================================================
RCS file: lang/sun-jdk13/builtin.mk
diff -N lang/sun-jdk13/builtin.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ lang/sun-jdk13/builtin.mk	6 Sep 2004 22:08:15 -0000
@@ -0,0 +1,33 @@
+.if !defined(IS_BUILTIN.sun-jdk13)
+
+IS_BUILTIN.sun-jdk13?=	no
+
+.include "../../mk/bsd.prefs.mk"
+.if ${OPSYS} == "Darwin"
+_BUILTIN_JAVA_VERSION!=java -version 2>&1 | sed -ne 's/java version "\([0-9.]*\).*/\1/p'
+.  if !empty(_BUILTIN_JAVA_VERSION:M1.3.*)
+.    if exists(/System/Library/Frameworks/JavaVM.framework/Versions/${_BUILTIN_JAVA_VERSION}/Home)
+IS_BUILTIN.sun-jdk13=	yes
+PKG_JAVA_HOME=		/System/Library/Frameworks/JavaVM.framework/Versions/${_BUILTIN_JAVA_VERSION}/Home
+BUILTIN_PKG.sun-jdk13!=	java -version 2>&1 | sed -ne 's/.* VM .*1\.3\.\([0-9]*\)_0*\([0-9]*\).*/sun-jdk13-\1.0.\2/p'
+.    endif
+.  endif
+.endif
+
+.endif  # IS_BUILTIN.sun-jdk13
+
+.if !defined(USE_BUILTIN.sun-jdk13)
+USE_BUILTIN.sun-jdk13?=	${IS_BUILTIN.sun-jdk13}
+.  if defined(BUILTIN_PKG.sun-jdk13)
+.    for _depend_ in ${BUILDLINK_DEPENDS.sun-jdk13}
+.      if !empty(USE_BUILTIN.sun-jdk13:M[yY][eE][sS])
+USE_BUILTIN.sun-jdk13!=							\
+	if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.sun-jdk13}; then	\
+		${ECHO} "yes";						\
+	else								\
+		${ECHO} "no";						\
+	fi
+.      endif
+.    endfor
+.  endif
+.endif  # USE_BUILTIN.sun-jdk13
Index: lang/sun-jdk14/builtin.mk
===================================================================
RCS file: lang/sun-jdk14/builtin.mk
diff -N lang/sun-jdk14/builtin.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ lang/sun-jdk14/builtin.mk	6 Sep 2004 22:08:15 -0000
@@ -0,0 +1,33 @@
+.if !defined(IS_BUILTIN.sun-jdk14)
+
+IS_BUILTIN.sun-jdk14?=	no
+
+.include "../../mk/bsd.prefs.mk"
+.if ${OPSYS} == "Darwin"
+_BUILTIN_JAVA_VERSION!=java -version 2>&1 | sed -ne 's/java version "\([0-9.]*\).*/\1/p'
+.  if !empty(_BUILTIN_JAVA_VERSION:M1.4.*)
+.    if exists(/System/Library/Frameworks/JavaVM.framework/Versions/${_BUILTIN_JAVA_VERSION}/Home)
+IS_BUILTIN.sun-jdk14=	yes
+PKG_JAVA_HOME=		/System/Library/Frameworks/JavaVM.framework/Versions/${_BUILTIN_JAVA_VERSION}/Home
+BUILTIN_PKG.sun-jdk14!=	java -version 2>&1 | sed -ne 's/java version "1\.4\.\([0-9]*\)_0*\([0-9]*\)"/sun-jdk14-\1.\2/p'
+.    endif
+.  endif
+.endif
+
+.endif  # IS_BUILTIN.sun-jdk14
+
+.if !defined(USE_BUILTIN.sun-jdk14)
+USE_BUILTIN.sun-jdk14?=	${IS_BUILTIN.sun-jdk14}
+.  if defined(BUILTIN_PKG.sun-jdk14)
+.    for _depend_ in ${BUILDLINK_DEPENDS.sun-jdk14}
+.      if !empty(USE_BUILTIN.sun-jdk14:M[yY][eE][sS])
+USE_BUILTIN.sun-jdk14!=							\
+	if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.sun-jdk14}; then	\
+		${ECHO} "yes";						\
+	else								\
+		${ECHO} "no";						\
+	fi
+.      endif
+.    endfor
+.  endif
+.endif  # USE_BUILTIN.sun-jdk14
Index: lang/sun-jre13/Makefile.common
===================================================================
RCS file: /cvsroot/pkgsrc/lang/sun-jre13/Makefile.common,v
retrieving revision 1.22
diff -u -r1.22 Makefile.common
--- lang/sun-jre13/Makefile.common	15 Jun 2004 12:00:09 -0000	1.22
+++ lang/sun-jre13/Makefile.common	6 Sep 2004 22:08:15 -0000
@@ -1,6 +1,5 @@
 # $NetBSD: Makefile.common,v 1.22 2004/06/15 12:00:09 abs Exp $
 
-# MASTER_SITES is very special, and must end in "=":
 CATEGORIES=	lang java
 EXTRACT_SUFX=	.bin
 
@@ -22,26 +21,14 @@
 
 .include "../../mk/bsd.prefs.mk"
 
-.if ${OPSYS} == "Darwin"
-JAVA_HOME=	/usr
-.else
 JAVA_HOME=	${LOCALBASE}/java/sun-1.3.1
 JAVA_NAME=	sun13
-.endif
 
 .if ${OPSYS} == "NetBSD"
 DEPENDS+=	suse_compat-[0-9]*:../../emulators/${SUSE_DIR_PREFIX}_compat
 DEPENDS+=	suse_x11-[0-9]*:../../emulators/${SUSE_DIR_PREFIX}_x11
 .endif
 
-.if ${OPSYS} == "Darwin"
-DISTFILES=	# empty
-NO_PATCH=	yes
-NO_CONFIGURE=	yes
-NO_BUILD=	yes
-PLIST_SRC=	${PKGDIR}/PLIST.Darwin
-.endif
-
 .if ${OPSYS} == "Linux"
 NO_PATCH=	yes	# no need for patches on Linux
 .endif
@@ -50,7 +37,7 @@
 NO_MTREE=	yes	# since we change PREFIX
 LDD=		${TRUE}
 
-ONLY_FOR_PLATFORM=	NetBSD-*-i386 Linux-*-i[3-6]86 Darwin-*-*
+ONLY_FOR_PLATFORM=	NetBSD-*-i386 Linux-*-i[3-6]86
 
 _FETCH_MESSAGE= 							\
 	${ECHO} "======================================================================"; \
@@ -70,26 +57,19 @@
 	${ECHO} "======================================================================"
 
 
-.if ${OPSYS} != "Darwin"
 post-fetch:
 	@if [ ! -x ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX} ]; then	\
 		${CHMOD} +x ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX};	\
 	fi
-.endif
 
 do-build:	# nothing
 
 post-build:
 	${FIND} ${WRKSRC} -name "*.orig" -print | ${XARGS} ${RM} -f
 
-.if ${OPSYS} == "Darwin"
-do-install:
-	@${ECHO_MSG} "Darwin ships with a JRE/JDK based on Sun's 1.3.1 release."
-.else
 do-install:
 	${INSTALL_PROGRAM_DIR} ${JAVA_HOME}
 	cd ${WRKSRC} && ${PAX} -rwp ma . ${JAVA_HOME}
-.endif
 
 .if ${OPSYS} == "NetBSD"
 .  include "../../emulators/suse_linux/Makefile.application"
Index: lang/sun-jre13/PLIST.Darwin
===================================================================
RCS file: lang/sun-jre13/PLIST.Darwin
diff -N lang/sun-jre13/PLIST.Darwin
--- lang/sun-jre13/PLIST.Darwin	30 Jun 2002 15:01:49 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,2 +0,0 @@
-@comment $NetBSD: PLIST.Darwin,v 1.1 2002/06/30 15:01:49 schmonz Exp $
-@comment Darwin ships with a JRE based on Sun's 1.3.1 release.
Index: lang/sun-jre13/builtin.mk
===================================================================
RCS file: lang/sun-jre13/builtin.mk
diff -N lang/sun-jre13/builtin.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ lang/sun-jre13/builtin.mk	6 Sep 2004 22:08:15 -0000
@@ -0,0 +1,33 @@
+.if !defined(IS_BUILTIN.sun-jre13)
+
+IS_BUILTIN.sun-jre13?=	no
+
+.include "../../mk/bsd.prefs.mk"
+.if ${OPSYS} == "Darwin"
+_BUILTIN_JAVA_VERSION!=java -version 2>&1 | sed -ne 's/java version "\([0-9.]*\).*/\1/p'
+.  if !empty(_BUILTIN_JAVA_VERSION:M1.3.*)
+.    if exists(/System/Library/Frameworks/JavaVM.framework/Versions/${_BUILTIN_JAVA_VERSION}/Home)
+IS_BUILTIN.sun-jre13=	yes
+PKG_JAVA_HOME=		/System/Library/Frameworks/JavaVM.framework/Versions/${_BUILTIN_JAVA_VERSION}/Home
+BUILTIN_PKG.sun-jre13!=	java -version 2>&1 | sed -ne 's/.* VM .*1\.3\.\([0-9]*\)_0*\([0-9]*\).*/sun-jre13-\1.0.\2/p'
+.    endif
+.  endif
+.endif
+
+.endif  # IS_BUILTIN.sun-jre13
+
+.if !defined(USE_BUILTIN.sun-jre13)
+USE_BUILTIN.sun-jre13?=	${IS_BUILTIN.sun-jre13}
+.  if defined(BUILTIN_PKG.sun-jre13)
+.    for _depend_ in ${BUILDLINK_DEPENDS.sun-jre13}
+.      if !empty(USE_BUILTIN.sun-jre13:M[yY][eE][sS])
+USE_BUILTIN.sun-jre13!=							\
+	if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.sun-jre13}; then	\
+		${ECHO} "yes";						\
+	else								\
+		${ECHO} "no";						\
+	fi
+.      endif
+.    endfor
+.  endif
+.endif  # USE_BUILTIN.sun-jre13
Index: lang/sun-jre14/builtin.mk
===================================================================
RCS file: lang/sun-jre14/builtin.mk
diff -N lang/sun-jre14/builtin.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ lang/sun-jre14/builtin.mk	6 Sep 2004 22:08:15 -0000
@@ -0,0 +1,33 @@
+.if !defined(IS_BUILTIN.sun-jre14)
+
+IS_BUILTIN.sun-jre14?=	no
+
+.include "../../mk/bsd.prefs.mk"
+.if ${OPSYS} == "Darwin"
+_BUILTIN_JAVA_VERSION!=java -version 2>&1 | sed -ne 's/java version "\([0-9.]*\).*/\1/p'
+.  if !empty(_BUILTIN_JAVA_VERSION:M1.4.*)
+.    if exists(/System/Library/Frameworks/JavaVM.framework/Versions/${_BUILTIN_JAVA_VERSION}/Home)
+IS_BUILTIN.sun-jre14=	yes
+PKG_JAVA_HOME=		/System/Library/Frameworks/JavaVM.framework/Versions/${_BUILTIN_JAVA_VERSION}/Home
+BUILTIN_PKG.sun-jre14!=	java -version 2>&1 | sed -ne 's/java version "1\.4\.\([0-9]*\)_0*\([0-9]*\)"/sun-jre14-\1.\2/p'
+.    endif
+.  endif
+.endif
+
+.endif  # IS_BUILTIN.sun-jre14
+
+.if !defined(USE_BUILTIN.sun-jre14)
+USE_BUILTIN.sun-jre14?=	${IS_BUILTIN.sun-jre14}
+.  if defined(BUILTIN_PKG.sun-jre14)
+.    for _depend_ in ${BUILDLINK_DEPENDS.sun-jre14}
+.      if !empty(USE_BUILTIN.sun-jre14:M[yY][eE][sS])
+USE_BUILTIN.sun-jre14!=							\
+	if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.sun-jre14}; then	\
+		${ECHO} "yes";						\
+	else								\
+		${ECHO} "no";						\
+	fi
+.      endif
+.    endfor
+.  endif
+.endif  # USE_BUILTIN.sun-jre14

--Apple-Mail-7-238050516--