8004265: Add build support for Compact Profiles
authordholmes
Mon, 21 Jan 2013 23:17:58 -0500
changeset 15681 8ca785029fe2
parent 15680 d379c4f7bb47
child 15682 793a36de151d
8004265: Add build support for Compact Profiles Reviewed-by: erikj, ohair
jdk/make/tools/src/build/tools/jarreorder/JarReorder.java
jdk/makefiles/BuildJdk.gmk
jdk/makefiles/CreateJars.gmk
jdk/makefiles/Images.gmk
jdk/makefiles/ProfileNames.gmk
jdk/makefiles/Profiles.gmk
--- a/jdk/make/tools/src/build/tools/jarreorder/JarReorder.java	Mon Jan 21 21:54:51 2013 -0500
+++ b/jdk/make/tools/src/build/tools/jarreorder/JarReorder.java	Mon Jan 21 23:17:58 2013 -0500
@@ -162,8 +162,9 @@
         for (int i = orderList.size() - 1; i >= 0; --i) {
             String s = orderList.get(i);
             if (allFilesExcluded.contains(s)) {
-                System.err.println("Included order file " + s
-                    + " is also excluded, skipping.");
+                // Disable this warning until 8005688 is fixed
+                // System.err.println("Included order file " + s
+                //    + " is also excluded, skipping.");
             } else if (new File(s).exists()) {
                 allFiles.add(s);
             } else {
--- a/jdk/makefiles/BuildJdk.gmk	Mon Jan 21 21:54:51 2013 -0500
+++ b/jdk/makefiles/BuildJdk.gmk	Mon Jan 21 23:17:58 2013 -0500
@@ -39,6 +39,12 @@
 # Setup the java compilers for the JDK build.
 include Setup.gmk
 
+# Include Profile information
+include ProfileNames.gmk
+
+# Include the corresponding custom file, if present.
+-include $(CUSTOM_MAKE_DIR)/BuildJdk.gmk
+
 import: import-only
 import-only:
 #       Import (corba jaxp jaxws langtools hotspot)
@@ -97,6 +103,13 @@
 	+$(MAKE) -f CompileLaunchers.gmk OVERLAY_IMAGES=true
 	+$(MAKE) -f Images.gmk overlay-images
 
+# Create Compact Profile images
+$(ALL_PROFILES):
+	+$(MAKE) PROFILE=$@ -f CreateJars.gmk
+	+$(MAKE) PROFILE=$@ JRE_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/j2re-$(word $(call profile_number,$@),$(PROFILE_NAMES))-image -f Images.gmk profile-image
+
+profiles: $(ALL_PROFILES)
+
 sign-jars:
 	+$(MAKE) -f SignJars.gmk
 
@@ -121,3 +134,4 @@
 .PHONY: import gensrc gendata classes libs launchers genclasses
 .PHONY: import-only gensrc-only gendata-only classes-only libs-only launchers-only genclasses-only
 .PHONY: all jdk demos images overlay-images bundles install
+.PHONY: profiles $(ALL_PROFILES)
--- a/jdk/makefiles/CreateJars.gmk	Mon Jan 21 21:54:51 2013 -0500
+++ b/jdk/makefiles/CreateJars.gmk	Mon Jan 21 23:17:58 2013 -0500
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -35,16 +35,19 @@
 
 include Tools.gmk
 
+include Profiles.gmk
+
 #
 # This makefile...so that altering will trigger rebuilding include/exclude-lists => jars
 #
 MAKEFILE=$(JDK_TOPDIR)/makefiles/CreateJars.gmk
+#
+# And similarly for the Profiles
+PROFILE_MAKEFILES=$(JDK_TOPDIR)/makefiles/Profiles.gmk $(JDK_TOPDIR)/makefiles/profile-rtjar-includes.txt
 
 MAINMANIFEST := $(JDK_TOPDIR)/make/tools/manifest.mf
 BEANMANIFEST := $(JDK_TOPDIR)/make/javax/swing/beaninfo/manifest
 
-JARS:=
-
 $(eval $(call MakeDir,$(IMAGES_OUTPUTDIR)/lib))
 
 ##########################################################################################
@@ -57,7 +60,6 @@
 		JAR:=$(IMAGES_OUTPUTDIR)/lib/jconsole.jar,\
 		SKIP_METAINF:=true))
 
-JARS+=$(IMAGES_OUTPUTDIR)/lib/jconsole.jar
 
 ##########################################################################################
 
@@ -68,7 +70,6 @@
 		JAR:=$(IMAGES_OUTPUTDIR)/lib/ext/dnsns.jar,\
 		SKIP_METAINF:=true))
 
-JARS+=$(IMAGES_OUTPUTDIR)/lib/ext/dnsns.jar
 
 ##########################################################################################
 
@@ -120,15 +121,20 @@
 		JAR:=$(IMAGES_OUTPUTDIR)/lib/ext/localedata.jar,\
 		SKIP_METAINF:=true))
 
-JARS+=$(IMAGES_OUTPUTDIR)/lib/ext/localedata.jar
-
 ##########################################################################################
-# rt.jar and resources.jar are being built in the same way as in the old build. They require
-# the files to be in a certain order and converting that is not easy and will not be needed
-# in jigsaw anyway.
+#
+# Different variants of rt.jar are built based on the current profile. The output
+# directory is augmented with the profile name so that the final jar file and all the
+# intermediary list files will be in directory. This has the form lib$PROFILE rather than
+# lib/$PROFILE so that it won't get copied as part of the image generation process.
+# Each profile customizes the RT_JAR_EXCLUDES variable.
+#
+##########################################################################################
 
-# Exclude list for rt.jar and resources.jar
-RT_JAR_EXCLUDES := \
+# Full JRE exclude list for rt.jar and resources.jar
+# This value should exclude types destined for jars other than rt.jar and resources.jar. 
+# When building a Profile this value augments the profile specific exclusions
+RT_JAR_EXCLUDES += \
 	com/oracle/security \
 	com/sun/codemodel \
 	com/sun/crypto/provider \
@@ -250,24 +256,9 @@
 	sun/tools/util \
 	sun/util/cldr/CLDRLocaleDataMetaInfo.class \
 	sun/util/resources/cldr \
-	$(LOCALEDATA_INCLUDES)
-
-# These files should never be put into rt.jar
-# but due to a misstake...some are put there if embedded
-#
-ifneq ($(JAVASE_EMBEDDED), true)
-# normal (correct) case
-RT_JAR_EXCLUDES += \
+	$(LOCALEDATA_INCLUDES) \
 	com/oracle/jrockit/jfr \
 	oracle/jrockit/jfr
-else
-# embedded (broken) case
-RT_JAR_EXCLUDES += \
-  oracle/jrockit/jfr/parser \
-  oracle/jrockit/jfr/tools \
-  oracle/jrockit/jfr/NativeOptions.class \
-  oracle/jrockit/jfr/RepositoryChunkHandler.class
-endif
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
         RT_JAR_EXCLUDES += com/sun/nio/sctp \
@@ -278,8 +269,8 @@
 ALL_FILES_IN_CLASSES := $(call not-containing,_the.,$(filter-out %javac_state,\
                         $(call CacheFind,$(JDK_OUTPUTDIR)/classes)))
 
-RT_JAR_MANIFEST_FILE := $(IMAGES_OUTPUTDIR)/lib/_the.rt.jar_manifest
-RESOURCE_JAR_MANIFEST_FILE := $(IMAGES_OUTPUTDIR)/lib/_the.resources.jar_manifest
+RT_JAR_MANIFEST_FILE := $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar_manifest
+RESOURCE_JAR_MANIFEST_FILE := $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar_manifest
 
 $(RT_JAR_MANIFEST_FILE): $(MAINMANIFEST) $(BEANMANIFEST)
 	$(MKDIR) -p $(@D)
@@ -299,7 +290,7 @@
 	       $(MAINMANIFEST) >> $@.tmp
 	$(MV) $@.tmp $@
 
-$(IMAGES_OUTPUTDIR)/lib/_the.jars.exclude: $(MAKEFILE)
+$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.exclude: $(MAKEFILE) $(PROFILE_MAKEFILES)
 	$(MKDIR) -p $(@D)
 	$(RM) $@ $@.tmp
 	$(call ListPathsSafely,RT_JAR_EXCLUDES,\n, >> $@.tmp)
@@ -312,55 +303,115 @@
 	$(TOOL_ADDJSUM) $< $@.tmp
 	$(MV) $@.tmp $@
 
-$(IMAGES_OUTPUTDIR)/lib/_the.jars.contents: $(BUILD_TOOLS) $(IMAGES_OUTPUTDIR)/lib/_the.jars.exclude \
+$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents: $(BUILD_TOOLS) $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.exclude \
 					 $(ALL_FILES_IN_CLASSES) $(IMAGES_OUTPUTDIR)/lib/classlist
 	$(MKDIR) -p $(@D)
 	$(RM) $@ $@.tmp
 	($(CD) $(JDK_OUTPUTDIR)/classes && \
 	    $(TOOL_JARREORDER) \
-		-o  $@.tmp $(IMAGES_OUTPUTDIR)/lib/classlist $(IMAGES_OUTPUTDIR)/lib/_the.jars.exclude . )
+		-o  $@.tmp $(IMAGES_OUTPUTDIR)/lib/classlist $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.exclude . )
 	$(MV) $@.tmp $@
 
-$(IMAGES_OUTPUTDIR)/lib/_the.rt.jar.contents: $(IMAGES_OUTPUTDIR)/lib/_the.jars.contents
+$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents
 	$(MKDIR) -p $(@D)
 	$(RM) $@ $@.tmp
-	$(GREP) -e '\.class$$' $(IMAGES_OUTPUTDIR)/lib/_the.jars.contents > $@.tmp
+	$(GREP) -e '\.class$$' $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp
+ifneq ($(PROFILE),)
+#       # Add back classes from excluded packages (fixing the $ substitution in the process)
+	for type in  $(subst \$$,\, $(RT_JAR_INCLUDE_TYPES)) ; do \
+	  $(ECHO) $$type >> $@.tmp ; \
+	done
+endif
 	$(MV) $@.tmp $@
 
-$(IMAGES_OUTPUTDIR)/lib/_the.resources.jar.contents: $(IMAGES_OUTPUTDIR)/lib/_the.jars.contents
+$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents
 	$(MKDIR) -p $(@D)
 	$(RM) $@ $@.tmp
 	$(GREP) -v -e '\.class$$' \
 	    -e '/_the\.*' -e '^_the\.*' -e '\\_the\.*' -e 'javac_state' \
-	    $(IMAGES_OUTPUTDIR)/lib/_the.jars.contents > $@.tmp
+	    $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp
+ifneq ($(PROFILE),)
+#       # Strip out all META-INF/services/ entries
+	$(GREP) -v -e 'META-INF/services/' $@.tmp > $@.tmp2
+#       # Add back the required services
+#       # FIXME: On Solaris if PROFILE_INCLUDE_METAINF_SERVICES is not defined
+#       # we get a syntax error from sh. That doesn't happen on linux
+	for service in $(PROFILE_INCLUDE_METAINF_SERVICES) ; do \
+	  $(ECHO) $$service >> $@.tmp2; \
+	done
+	$(MV) $@.tmp2 $@.tmp
+endif
 	$(MV) $@.tmp $@
 
+# This is a hack but I don't know how to make this fit into the existing scheme
+$(PROFILE_VERSION_CLASS_TARGETS) : $(PROFILE_VERSION_JAVA_TARGETS)
+	@$(JAVAC) -d $(@D)/../../ $(@D)/$(VERSION_JAVA_FILE)
+
+
+# Support for removing the addPropertyChangeListener and removePropertyChangeListener
+# methods from classes that only go into the profile builds. For now the Pack200.Packer
+# and Packer200.Unpacker classes have special handling because of the $ in the file
+# name.
+BEANLESS_CLASSES = $(IMAGES_OUTPUTDIR)/beanless
+
+$(BEANLESS_CLASSES)/%: $(JDK_OUTPUTDIR)/classes/%
+	$(MKDIR) -p $(@D)
+	$(TOOL_REMOVEMETHODS) $< $@ addPropertyChangeListener removePropertyChangeListener
+
+CLASSES_TO_DEBEAN = \
+    java/util/logging/LogManager.class \
+    com/sun/java/util/jar/pack/PackerImpl.class \
+    com/sun/java/util/jar/pack/UnpackerImpl.class
+
+BEANLESS_CLASSES_TARGETS =
+ifneq ($(PROFILE),)
+    BEANLESS_CLASSES_TARGETS := $(foreach c, $(CLASSES_TO_DEBEAN), $(BEANLESS_CLASSES)/$c)
+endif
+
+
 RT_JAR_CREATE_OPTIONS := c0fm
+RT_JAR_UPDATE_OPTIONS := u0f
 ifeq ($(COMPRESS_JARS), true)
     RT_JAR_CREATE_OPTIONS := cfm
+    RT_JAR_UPDATE_OPTIONS := uf
 endif
 
-$(IMAGES_OUTPUTDIR)/lib/rt.jar: $(IMAGES_OUTPUTDIR)/lib/_the.rt.jar.contents $(RT_JAR_MANIFEST_FILE)
-	$(ECHO) Creating rt.jar
+# This defines a target-specific variables to make the shell logic easier to see.
+# We need to find the Version.class file for the profile currently being built
+$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/rt.jar: \
+  CLASS_FILE = $(if $(PROFILE),$(strip $(foreach class,$(PROFILE_VERSION_CLASS_TARGETS),$(if $(findstring $(PROFILE),$(class)),$(class)))), NO_SUCH_FILE)
+# This is the real target
+$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/rt.jar: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents $(RT_JAR_MANIFEST_FILE) $(PROFILE_VERSION_CLASS_TARGETS) $(BEANLESS_CLASSES_TARGETS)
+	$(ECHO) Creating rt.jar $(PROFILE) Compressed=$(COMPRESS_JARS)
 	$(MKDIR) -p $(@D)
 	$(RM) $@ $@.tmp
 	$(CD) $(JDK_OUTPUTDIR)/classes && \
 	    $(JAR) $(RT_JAR_CREATE_OPTIONS) $@.tmp $(RT_JAR_MANIFEST_FILE) \
-	        @$(IMAGES_OUTPUTDIR)/lib/_the.rt.jar.contents
+	        @$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents && \
+	    if [ -f $(CLASS_FILE) ]; then \
+	      $(ECHO)  Updating rt.jar $(PROFILE) && \
+	      $(CD) $(patsubst %$(VERSION_CLASS_PATH),%,$(CLASS_FILE)) && \
+                $(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(VERSION_CLASS_PATH); \
+	      $(MKDIR) -p $(BEANLESS_CLASSES)/java/util/jar; \
+	      $(TOOL_REMOVEMETHODS) $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200\$$Packer.class \
+		$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Packer.class addPropertyChangeListener removePropertyChangeListener; \
+	      $(TOOL_REMOVEMETHODS) $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200\$$Unpacker.class \
+		$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Unpacker.class addPropertyChangeListener removePropertyChangeListener; \
+	      $(CD) $(BEANLESS_CLASSES) && \
+		$(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(CLASSES_TO_DEBEAN) java/util/jar/* ; \
+            fi
 	$(MV) $@.tmp $@
 
-$(IMAGES_OUTPUTDIR)/lib/resources.jar: $(IMAGES_OUTPUTDIR)/lib/_the.resources.jar.contents \
+$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/resources.jar: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents \
 				    $(RESOURCE_JAR_MANIFEST_FILE)
 	$(ECHO) Creating resources.jar
 	$(MKDIR) -p $(@D)
 	$(RM) $@ $@.tmp
 	$(CD) $(JDK_OUTPUTDIR)/classes && \
 	    $(JAR) $(RT_JAR_CREATE_OPTIONS) $@.tmp $(RESOURCE_JAR_MANIFEST_FILE) \
-	        @$(IMAGES_OUTPUTDIR)/lib/_the.resources.jar.contents
+	        @$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents
 	$(MV) $@.tmp $@
 
-JARS+=$(IMAGES_OUTPUTDIR)/lib/rt.jar $(IMAGES_OUTPUTDIR)/lib/resources.jar
-
 ##########################################################################################
 
 ifneq ($(OPENJDK_TARGET_OS), windows)
@@ -385,8 +436,6 @@
 		SKIP_METAINF := true, \
                 CHECK_COMPRESS_JAR:=true))
 
-JARS+=$(IMAGES_OUTPUTDIR)/lib/charsets.jar
-
 ##########################################################################################
 
 ifndef OPENJDK
@@ -400,7 +449,6 @@
 		MANIFEST:=$(MAINMANIFEST), \
                 CHECK_COMPRESS_JAR:=true))
 
-    JARS+=$(IMAGES_OUTPUTDIR)/lib/jfr.jar
 endif
 endif
 
@@ -417,8 +465,6 @@
 		MANIFEST:=$(MAINMANIFEST), \
                 CHECK_COMPRESS_JAR:=true))
 
-JARS+=$(IMAGES_OUTPUTDIR)/lib/jsse.jar
-
 ##########################################################################################
 # Create manifest for security jars
 
@@ -438,7 +484,8 @@
 
 ##########################################################################################
 # For all security jars, always build the jar, but for closed, install the prebuilt signed
-# version instead of the newly built jar. For open, signing is not needed. See SignJars.gmk
+# version instead of the newly built jar. Unsigned jars are treated as intermediate targets
+# and explicitly added to the JARS list. For open, signing is not needed. See SignJars.gmk
 # for more information.
 
 SUNPKCS11_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunpkcs11.jar
@@ -464,7 +511,7 @@
 	$(install-file)
 endif
 
-JARS += $(SUNPKCS11_JAR_DST) $(SUNPKCS11_JAR_UNSIGNED)
+JARS += $(SUNPKCS11_JAR_UNSIGNED)
 
 ##########################################################################################
 
@@ -491,7 +538,7 @@
 	$(install-file)
 endif
 
-JARS += $(SUNEC_JAR_DST) $(SUNEC_JAR_UNSIGNED)
+JARS += $(SUNEC_JAR_UNSIGNED)
 
 ##########################################################################################
 
@@ -504,8 +551,6 @@
 		JAR:=$(IMAGES_OUTPUTDIR)/lib/dt.jar,\
 		SKIP_METAINF:=true))
 
-JARS+=$(IMAGES_OUTPUTDIR)/lib/dt.jar
-
 ##########################################################################################
 
 SUNJCE_PROVIDER_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunjce_provider.jar
@@ -531,7 +576,7 @@
 	$(install-file)
 endif
 
-JARS += $(SUNJCE_PROVIDER_JAR_DST) $(SUNJCE_PROVIDER_JAR_UNSIGNED)
+JARS += $(SUNJCE_PROVIDER_JAR_UNSIGNED)
 
 ##########################################################################################
 
@@ -558,7 +603,7 @@
 	$(install-file)
 endif
 
-JARS += $(JCE_JAR_DST) $(JCE_JAR_UNSIGNED)
+JARS +=  $(JCE_JAR_UNSIGNED)
 
 ##########################################################################################
 
@@ -596,7 +641,7 @@
 	$(install-file)
 endif
 
-JARS += $(US_EXPORT_POLICY_JAR_DST) $(US_EXPORT_POLICY_JAR_UNSIGNED)
+JARS += $(US_EXPORT_POLICY_JAR_UNSIGNED)
 
 ##########################################################################################
 
@@ -639,7 +684,7 @@
 	$(install-file)
 endif
 
-JARS += $(LOCAL_POLICY_JAR_DST) $(LOCAL_POLICY_JAR_UNSIGNED)
+JARS += $(LOCAL_POLICY_JAR_UNSIGNED)
 
 ##########################################################################################
 
@@ -668,7 +713,7 @@
 	$(install-file)
 endif
 
-JARS += $(SUNMSCAPI_JAR_DST) $(SUNMSCAPI_JAR_UNSIGNED)
+JARS += $(SUNMSCAPI_JAR_UNSIGNED)
 
 endif
 
@@ -695,7 +740,7 @@
 	@$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt OracleUcrypto provider..."
 	$(install-file)
 
-JARS += $(UCRYPTO_JAR_DST) $(UCRYPTO_JAR_UNSIGNED)
+JARS += $(UCRYPTO_JAR_UNSIGNED) 
 
 endif
 endif
@@ -718,8 +763,6 @@
 		EXTRA_MANIFEST_ATTR:=CLDR-Version: $(CLDRVERSION),\
 		SKIP_METAINF:=true))
 
-JARS += $(CLDRDATA_JAR_DST)
-
 ##########################################################################################
 
 TOOLS_JAR_INCLUDES := \
@@ -793,7 +836,6 @@
 		SKIP_METAINF:=true, \
                 CHECK_COMPRESS_JAR:=true))
 
-JARS+=$(IMAGES_OUTPUTDIR)/lib/tools.jar
 
 ##########################################################################################
 
@@ -834,6 +876,7 @@
 	    -processor com.sun.tools.javac.sym.CreateSymbols \
 	    -Acom.sun.tools.javac.sym.Jar=$(IMAGES_OUTPUTDIR)/lib/rt.jar \
 	    -Acom.sun.tools.javac.sym.Dest=$(IMAGES_OUTPUTDIR)/symbols/META-INF/sym/rt.jar \
+	    -Acom.sun.tools.javac.sym.Profiles=profile-rtjar-includes.txt \
 	    $(CORE_PKGS) $(NON_CORE_PKGS) $(EXCLUDE_PROPWARN_PKGS) $(EXPORTED_PRIVATE_PKGS)
 	$(TOUCH) $@
 
@@ -844,7 +887,6 @@
 		JAR:=$(IMAGES_OUTPUTDIR)/lib/ct.sym, \
 		CHECK_COMPRESS_JAR:=true))
 
-JARS+=$(IMAGES_OUTPUTDIR)/lib/ct.sym
 
 ##########################################################################################
 
@@ -930,8 +972,6 @@
 		ZIP:=$(IMAGES_OUTPUTDIR)/src.zip,\
 		EXTRA_DEPS:=$(LAUNCHER_ZIP_SRC)))
 
-JARS+=$(IMAGES_OUTPUTDIR)/src.zip
-
 ##########################################################################################
 
 #
@@ -941,15 +981,11 @@
 $(IMAGES_OUTPUTDIR)/lib/management-agent.jar : $(JDK_TOPDIR)/src/share/classes/sun/management/manifest
 	$(JAR) cfm $@ $<
 
-JARS += $(IMAGES_OUTPUTDIR)/lib/management-agent.jar
-
 ##########################################################################################
 
 $(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar : $(JDK_OUTPUTDIR)/demo/nio/zipfs/zipfs.jar
 	$(install-file)
 
-JARS += $(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar
-
 ##########################################################################################
 
 ifeq ($(OPENJDK_TARGET_OS),macosx)
@@ -957,8 +993,6 @@
 		SRCS:=$(JDK_OUTPUTDIR)/jobjc_classes,\
 		JAR:=$(IMAGES_OUTPUTDIR)/lib/JObjC.jar, \
 		JARINDEX:=true))
-
-    JARS += $(IMAGES_OUTPUTDIR)/lib/JObjC.jar
 endif
 
 ##########################################################################################
@@ -968,7 +1002,6 @@
 		SRCS:=$(JDK_OUTPUTDIR)/altclasses_classes,\
 		JAR:=$(IMAGES_OUTPUTDIR)/lib/alt-rt.jar))
 
-    JARS += $(IMAGES_OUTPUTDIR)/lib/alt-rt.jar
 endif
 
 ##########################################################################################
@@ -979,8 +1012,6 @@
 $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar: $(JDK_OUTPUTDIR)/lib/sa-jdi.jar
 	$(install-file)
 
-JARS += $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar
-
 ##########################################################################################
 #
 # sec-bin.zip is used by builds where the corresponding sources are not available
--- a/jdk/makefiles/Images.gmk	Mon Jan 21 21:54:51 2013 -0500
+++ b/jdk/makefiles/Images.gmk	Mon Jan 21 23:17:58 2013 -0500
@@ -41,6 +41,8 @@
 
 include Tools.gmk
 
+include Profiles.gmk
+
 # Note: This double-colon rule is intentional, to support
 # custom make file integration.
 images:: jre-image jdk-image
@@ -84,7 +86,7 @@
 ################################################################################
 #
 # Variable prefixes explained:
-# JRE_ refers to files in the j2re-image.
+# JRE_ refers to files in the j2re-*-image.
 # JDK_ refers to files in the j2sdk-image outside of the jre subdir.
 # JDKJRE_ refers to files in the j2sdk-image inside the jre subdir.
 #
@@ -92,7 +94,8 @@
 ################################################################################
 # /bin dir
 
-NOT_JRE_BIN_FILES := \
+ifeq ($(PROFILE),)
+    NOT_JRE_BIN_FILES := \
 	appletviewer$(EXE_SUFFIX) \
 	extcheck$(EXE_SUFFIX) \
 	idlj$(EXE_SUFFIX) \
@@ -125,6 +128,7 @@
         schemagen$(EXE_SUFFIX) \
 	jsadebugd$(EXE_SUFFIX) \
 	jhat$(EXE_SUFFIX)
+endif
 
 WINDOWS_JDK_BIN_FILES = \
 	$(EXE_SUFFIX) \
@@ -196,7 +200,8 @@
 	$(SALIB_NAME)
 endif
 
-NOT_JRE_LIB_FILES := \
+ifeq ($(PROFILE),)
+    NOT_JRE_LIB_FILES := \
 	tools.jar \
 	jconsole.jar \
 	sa-jdi.jar \
@@ -205,8 +210,9 @@
 	ir.idl \
 	ct.sym
 
-ifeq ($(OPENJDK_TARGET_OS), windows)
-    NOT_JRE_LIB_FILES += jawt.lib jvm.lib
+    ifeq ($(OPENJDK_TARGET_OS), windows)
+      NOT_JRE_LIB_FILES += jawt.lib jvm.lib
+    endif
 endif
 
 JDK_LIB_FILES := $(NOT_JRE_LIB_FILES)
@@ -607,6 +613,9 @@
 $(JRE_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
 	$(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 	$(call create-info-file)
+ifneq ($(PROFILE),)
+	$(call info-file-item, "JAVA_PROFILE", "$(call profile_name, $(call profile_number, $(PROFILE)))")
+endif
 
 $(JDK_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
 	$(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
@@ -648,7 +657,7 @@
     EXEC_LIST_OVERLAY:=$(filter $(OVERLAY_FILTER),$(EXEC_LIST_BIN)) $(EXEC_LIST_LIB)
 
     # Filter out non JRE files and convert to unique touch files to depend on
-    JRE_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%,$(IMAGES_OUTPUTDIR)/_strip_jre/%.stripped,\
+    JRE_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%,$(IMAGES_OUTPUTDIR)/_strip_jre$(PROFILE)/%.stripped,\
 			$(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES) $(JDKJRE_LIB_FILES)),\
 				 $(EXEC_LIST)))
 
@@ -688,7 +697,7 @@
     endef
 
     # Setup a rule for stripping files based on touch files
-    $(IMAGES_OUTPUTDIR)/_strip_jre/%.stripped: $(JRE_IMAGE_DIR)/%
+    $(IMAGES_OUTPUTDIR)/_strip_jre$(PROFILE)/%.stripped: $(JRE_IMAGE_DIR)/%
 	$(call strip-file)
 
     $(IMAGES_OUTPUTDIR)/_strip_jdk/%.stripped: $(JDK_IMAGE_DIR)/%
@@ -728,6 +737,20 @@
 	$(JDK_OVERLAY_DEMO_TARGETS) $(JDK_OVERLAY_INFO_FILE) \
 	$(JDKJRE_OVERLAY_STRIP_LIST) $(JDK_OVERLAY_BIN_STRIP_LIST) 
 
+ifneq ($(PROFILE),)
+# Files in lib$(PROFILE) are excluded from the generic copying routines so
+# we have to add them back in here
+$(foreach f,$(CUSTOM_PROFILE_JARS),\
+    $(eval $(call AddFileToCopy,$(IMAGES_OUTPUTDIR)/lib$(PROFILE),$(JRE_IMAGE_DIR)/lib,$f,JRE_LIB_TARGETS)))
+
+profile-image: $(JRE_BIN_TARGETS) $(JRE_LIB_TARGETS) \
+	$(JRE_IMAGE_DIR)/lib/meta-index $(JRE_IMAGE_DIR)/lib/ext/meta-index \
+	$(JRE_INFO_FILE) $(JRE_STRIP_LIST)
+
+.PHONY: profile-image
+
+endif # Profile
+
 ################################################################################
 
 .PHONY: default images jre-image jdk-image
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/ProfileNames.gmk	Mon Jan 21 23:17:58 2013 -0500
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# This was split out from Profiles.gmk to allow GenSrcMisc.gmk to include it
+# without attempting to generate lists for output files that don't exist yet
+
+# These are the external names of each profile
+
+PROFILE_NAMES := compact1 compact2 compact3
+
+# The include files use 1,2,3,4 for simplicity and conciseness. Internally we
+# use profile_1, profile_2 and profile_3. Note that profile_4 is a full JRE so
+# we never have to use it directly.
+
+ALL_PROFILES := profile_1 profile_2 profile_3
+
+# This defines targets to generate per-profile Version.java/class files into
+# distinct locations
+
+VERSION_JAVA_DIR := sun/misc
+VERSION_JAVA_FILE := Version.java
+VERSION_JAVA_PATH := $(VERSION_JAVA_DIR)/$(VERSION_JAVA_FILE)
+VERSION_CLASS_PATH := $(VERSION_JAVA_PATH:.java=.class)
+
+PROFILE_VERSION_JAVA_TARGETS := $(foreach i, $(ALL_PROFILES), $(subst XXX,$i, $(JDK_OUTPUTDIR)/gen_XXX/$(VERSION_JAVA_PATH)))
+
+PROFILE_VERSION_CLASS_TARGETS := $(foreach i, $(PROFILE_VERSION_JAVA_TARGETS), $(i:.java=.class))
+
+# Function to map from profile designator, profile_1 etc, to its number
+profile_number = $(if $(patsubst profile_%,%, $(1)),$(patsubst profile_%,%, $(1)), $(words $(PROFILE_NAMES) extra))
+
+# Function to map from profile number, 1, 2 etc, to the corresponding name
+# An invalid number maps to an empty name
+profile_name = $(word $(1), $(PROFILE_NAMES))
+
+# Function to isolate a profile number from a Version.java target
+# Evaluates to the arg if the arg is not a profile version target
+profile_version_number = $(patsubst $(JDK_OUTPUTDIR)/gen_profile_%/$(VERSION_JAVA_PATH), %, $(1))
+
+# Function to go from a profile Version.java target to profile name. If not 
+# a profile version target then we need a number that maps to an empty name
+profile_version_name = $(word $(if $(filter-out $(call profile_version_number, $(1)), $(1)), $(call profile_version_number, $(1)), $(words $(PROFILE_NAMES) extra)), $(PROFILE_NAMES))
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/Profiles.gmk	Mon Jan 21 23:17:58 2013 -0500
@@ -0,0 +1,331 @@
+#
+# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+include ProfileNames.gmk
+
+# This defines the include lists for each profile, categorized as lib, bin
+# and other. We can use these to define the file lists for each profile
+# directly, rather than constructing a set of files to exclude from the
+# set of all files. But initially we will stick with generating exclude lists
+# as that is how the main build process already works.
+
+include profile-includes.txt
+
+###############################################################################
+# Per profile Jar lists
+#
+# These are the jar files to be built. In some builds these have to be
+# imported (signed jars) rather than built.
+#
+# The incoming lists, eg PROFILE_1_JRE_JARS_FILES, are the jars to be
+# included in this profile. They have the jar name relative to the lib 
+# directory. We have to turn these into targets by adding the 
+# $(IMAGES_OUTPUTDIR)/lib prefix
+#
+# Note that some jars may be optional depending on the type of build (jdk vs.
+# openjdk) and the platform.
+#
+# WARNING: incoming lists are currently validated for linux only!
+###############################################################################
+
+# These are jar files for which the contents vary depending on the profile
+CUSTOM_JARS := rt.jar resources.jar
+# This is used in Images.gmk
+CUSTOM_PROFILE_JARS := $(addprefix $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/, $(CUSTOM_JARS))
+
+# These are the common jar files built for and included with this profile
+# Filter out the custom jars and turn them into targets.
+
+PROFILE_1_JARS :=  \
+    $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(filter-out $(CUSTOM_JARS), $(PROFILE_1_JRE_JAR_FILES)))
+
+PROFILE_2_JARS := \
+    $(if $(PROFILE_2_JRE_JAR_FILES), $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_2_JRE_JAR_FILES))) \
+    $(PROFILE_1_JARS)
+
+ifneq ($(ENABLE_JFR), true)
+  PROFILE_3_JRE_JAR_FILES :=  $(filter-out jfr.jar, $(PROFILE_3_JRE_JAR_FILES))
+endif
+
+PROFILE_3_JARS := \
+    $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_3_JRE_JAR_FILES)) \
+    $(PROFILE_2_JARS)
+
+ifdef OPENJDK
+  PROFILE_4_JRE_JAR_FILES := $(filter-out alt-rt.jar, $(PROFILE_4_JRE_JAR_FILES))
+endif
+
+PROFILE_4_JARS := \
+    $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_4_JRE_JAR_FILES)) \
+    $(PROFILE_3_JARS)
+
+# The full set of "jar" files needed for a complete JDK (ct.sym and src.zip
+# are also included.)
+# Note we need to add back the regular form of all the custom profile jars e.g.
+# rt.jar and resources.jar
+
+ALL_JARS := $(PROFILE_4_JARS) \
+        $(IMAGES_OUTPUTDIR)/lib/rt.jar \
+        $(IMAGES_OUTPUTDIR)/lib/resources.jar \
+        $(IMAGES_OUTPUTDIR)/lib/jconsole.jar \
+        $(IMAGES_OUTPUTDIR)/lib/dt.jar \
+        $(IMAGES_OUTPUTDIR)/lib/tools.jar \
+        $(IMAGES_OUTPUTDIR)/lib/ct.sym \
+        $(IMAGES_OUTPUTDIR)/src.zip \
+        $(IMAGES_OUTPUTDIR)/lib/ext/cldrdata.jar \
+        $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar
+
+ifeq ($(OPENJDK_TARGET_OS),solaris)
+    ifndef OPENJDK
+        ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/ext/ucrypto.jar
+    endif
+endif
+
+ifeq ($(OPENJDK_TARGET_OS),windows)
+    ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/ext/sunmscapi.jar
+endif 
+
+ifeq ($(OPENJDK_TARGET_OS),macosx)
+    ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/JObjC.jar
+endif
+
+ifeq ($(PROFILE), profile_1)
+    PROFILE_JARS := $(PROFILE_1_JARS)
+else ifeq ($(PROFILE), profile_2)
+    PROFILE_JARS := $(PROFILE_2_JARS)
+else ifeq ($(PROFILE), profile_3)
+    PROFILE_JARS := $(PROFILE_3_JARS)
+endif
+ifneq ($(PROFILE),)
+    JARS := $(CUSTOM_PROFILE_JARS) $(PROFILE_JARS)
+else
+    JARS := $(ALL_JARS)
+endif
+
+###############################################################################
+# JRE contents
+###############################################################################
+
+
+# we don't need to do anything if not building a profile
+ifneq ($(PROFILE),)
+
+
+# Need all files to generate the exclude lists
+NEW_ALL_BIN_LIST := $(patsubst $(JDK_OUTPUTDIR)/bin/%,%,$(shell $(FIND) $(JDK_OUTPUTDIR)/bin \( -type f -o -type l \) ! -name "sjavac"))
+
+ALL_JRE_BIN_FILES := \
+   $(PROFILE_1_JRE_BIN_FILES) \
+   $(PROFILE_2_JRE_BIN_FILES) \
+   $(PROFILE_3_JRE_BIN_FILES) \
+   $(PROFILE_4_JRE_BIN_FILES) 
+
+NOT_JRE_BIN_FILES := $(filter-out $(ALL_JRE_BIN_FILES), $(NEW_ALL_BIN_LIST))
+
+# Additional exclusions for profile JRE
+ifeq ($(PROFILE), profile_1)
+    NOT_JRE_BIN_FILES += \
+        $(PROFILE_2_JRE_BIN_FILES) \
+        $(PROFILE_3_JRE_BIN_FILES) \
+        $(PROFILE_4_JRE_BIN_FILES) 
+endif
+
+ifeq ($(PROFILE), profile_2)
+    NOT_JRE_BIN_FILES += \
+        $(PROFILE_3_JRE_BIN_FILES) \
+        $(PROFILE_4_JRE_BIN_FILES) 
+endif
+
+ifeq ($(PROFILE), profile_3)
+    NOT_JRE_BIN_FILES += \
+        $(PROFILE_4_JRE_BIN_FILES) 
+endif
+
+NOT_JRE_BIN_FILES := $(addprefix $(JDK_OUTPUTDIR)/bin/, $(NOT_JRE_BIN_FILES))
+
+# Need all files to generate the exclude lists
+NEW_ALL_LIB_LIST := $(patsubst $(JDK_OUTPUTDIR)/lib/%,%,$(shell $(FIND) $(JDK_OUTPUTDIR)/lib \( -type f -o -type l \) -a ! \( -name "_the*" -o -name "javac_state " \) ))
+NEW_ALL_LIB_LIST += $(patsubst $(IMAGES_OUTPUTDIR)/lib/%,%,$(shell $(FIND) $(IMAGES_OUTPUTDIR)/lib \( -type f -o -type l \) -a ! \( -name "_the*" -o -name "javac_state " \) ))
+
+ALL_JRE_LIB_FILES := \
+   $(PROFILE_1_JRE_LIB_FILES) \
+   $(PROFILE_2_JRE_LIB_FILES) \
+   $(PROFILE_3_JRE_LIB_FILES) \
+   $(PROFILE_4_JRE_LIB_FILES) 
+
+NOT_JRE_LIB_FILES := $(filter-out $(ALL_JRE_LIB_FILES), $(NEW_ALL_LIB_LIST))
+
+# Although these are NOT JRE lib files we have to filter them from the list
+# (ie cause them to be added them back in here) because the logic in
+# Images.gmk expects them to be there and handles them differently.
+# If we don't, they end up in the wrong place in the JDK image.
+# This needs fixing.
+NOT_JRE_LIB_FILES := $(filter-out $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX) $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(SALIB_NAME), $(NOT_JRE_LIB_FILES))
+
+# Additional exclusions for profile JREs
+ifeq ($(PROFILE), profile_1)
+    NOT_JRE_LIB_FILES += \
+        $(PROFILE_2_JRE_LIB_FILES) \
+        $(PROFILE_3_JRE_LIB_FILES) \
+        $(PROFILE_4_JRE_LIB_FILES) 
+endif
+
+ifeq ($(PROFILE), profile_2)
+    NOT_JRE_LIB_FILES += \
+        $(PROFILE_3_JRE_LIB_FILES) \
+        $(PROFILE_4_JRE_LIB_FILES) 
+endif
+
+ifeq ($(PROFILE), profile_3)
+    NOT_JRE_LIB_FILES += \
+        $(PROFILE_4_JRE_LIB_FILES) 
+endif
+
+# Exclude the custom jar files as these will be added back via a special rule
+NOT_JRE_LIB_FILES += $(CUSTOM_JARS)
+
+###############################################################################
+# Customization of rt.jar file contents
+# These are expressed as exclusions from everything found in the 
+# JDK_OUTPUTDIR/classes directory
+###############################################################################
+
+# The main set of excluded types/packages (ie everything not destined to be
+# part of rt.jar or resources.jar is captured in the CreateJars.gmk RT_JAR_EXCLUDES
+# variable. We add to that for the per-profile exclusion lists
+
+# For each profile we have four variables:
+#
+# - PROFILE_n_RTJAR_INCLUDE_PACKAGES
+#
+# This is a package prefix indicating that all classes in that package
+# and conditionally its subpackages are included in rt.jar for this profile.
+# The subpackages will be included as long as they do not appear in the
+# include list of a higher profile
+#
+# - PROFILE_n_RTJAR_INCLUDE_TYPES
+#
+# These are specific types that must be included within a package.
+# There are two cases:
+# - individual types in a package that is otherwise excluded at this 
+#   profile level. The only arises if there are split packages. 
+#
+# - A higher-level package is included in a high profile where a subpackage
+# is included in a lower profile. Including the package in the high profile
+# would exclude it and all subpackages from the lower profile, so instead
+# the classes in the package are listed for that higher profile (as *.class)
+#
+# These types are explicitly added back into the rt.jar content lists.
+#
+# - PROFILE_n_RTJAR_EXCLUDE_TYPES
+#
+# These are specific types that must be excluded even though most of the
+# containing package is include. Again this occurs with split packges.
+#
+# So the exclude list for each profile consists of the include lists
+# for all profiles above it, together with any explicitly excluded types. 
+# This is then combined with the overall RT_JAR_EXCLUDES list (which covers
+# things that go into other jar files).
+#
+# We also have to define the types to be explicitly included. This
+# accumulates up the profiles ie profile 3 has to include the types
+# that profiles 1 and 2 had to include. This is unnecessary if, for example,
+# profile 3 includes the entire package, but it is harmless to add them
+# explicitly, and complex to determine if we still need to include them.
+#
+# Need a way to express: 
+#  for (int i = profile+1; i < 4; i++)
+#     RT_JAR_EXCLUDES += PROFILE_$i_RTJAR_INCLUDE_PACKAGES
+#
+# Do it the long way for now
+#
+# - PROFILE_n_INCLUDE_METAINF_SERVICES
+#
+# These are META-INF/services/ entries found in resources.jar. Together
+# resources.jar and rt.jar hold the contents of the classes directory, (the
+# classes in rt.jar and everything else in resources.jar).Hence the 
+# include/exclude information for resources.jar is tied to that of rt.jar
+
+include profile-rtjar-includes.txt
+
+# Function to expand foo/*.class into the set of classes
+# NOTE: Classfiles with $ in their name are problematic as that is the
+# meta-character for both make and the shell! Hence the \$$$$ substitution.
+# But note that if you echo these values they will NOT display as expected.
+class_list =  $(patsubst $(JDK_OUTPUTDIR)/classes/%,%,\
+     $(foreach i,$(1), $(subst $$,\$$$$, $(wildcard $(JDK_OUTPUTDIR)/classes/$i))))
+
+ifeq ($(PROFILE), profile_1)
+  RT_JAR_EXCLUDES += \
+    $(PROFILE_1_RTJAR_EXCLUDE_TYPES) \
+    $(PROFILE_2_RTJAR_INCLUDE_PACKAGES) \
+    $(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES)) \
+    $(PROFILE_3_RTJAR_INCLUDE_PACKAGES) \
+    $(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES)) \
+    $(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
+    $(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
+  RT_JAR_INCLUDE_TYPES := \
+	$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES))
+  PROFILE_INCLUDE_METAINF_SERVICES := \
+    $(PROFILE_1_INCLUDE_METAINF_SERVICES)
+endif
+ifeq ($(PROFILE), profile_2)
+  RT_JAR_EXCLUDES += \
+    $(PROFILE_2_RTJAR_EXCLUDE_TYPES) \
+    $(PROFILE_3_RTJAR_INCLUDE_PACKAGES) \
+    $(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES)) \
+    $(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
+    $(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
+  RT_JAR_INCLUDE_TYPES := \
+	$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES)) \
+	$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES))
+  PROFILE_INCLUDE_METAINF_SERVICES := \
+    $(PROFILE_1_INCLUDE_METAINF_SERVICES) \
+    $(PROFILE_2_INCLUDE_METAINF_SERVICES)
+endif
+ifeq ($(PROFILE), profile_3)
+  RT_JAR_EXCLUDES += \
+    $(PROFILE_3_RTJAR_EXCLUDE_TYPES) \
+    $(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
+    $(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
+  RT_JAR_INCLUDE_TYPES := \
+	$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES)) \
+	$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES)) \
+	$(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES))
+  PROFILE_INCLUDE_METAINF_SERVICES := \
+    $(PROFILE_1_INCLUDE_METAINF_SERVICES) \
+    $(PROFILE_2_INCLUDE_METAINF_SERVICES) \
+    $(PROFILE_3_INCLUDE_METAINF_SERVICES)
+endif
+
+# Filter out non-OpenJDK services
+ifdef OPENJDK
+  EXCLUDED_SERVICES := META-INF/services/javax.script.ScriptEngineFactory 
+  PROFILE_INCLUDE_METAINF_SERVICES := $(filter-out $(EXCLUDED_SERVICES),$(PROFILE_INCLUDE_METAINF_SERVICES))
+endif
+
+
+endif # profile
+