jdk/make/CreateJars.gmk
author vlivanov
Wed, 10 Sep 2014 19:19:47 +0400
changeset 26467 d69abed3a07d
parent 26360 697f70835528
child 26632 f87ab7e0bf39
permissions -rw-r--r--
8050052: Small cleanups in java.lang.invoke code Reviewed-by: vlivanov, psandoz Contributed-by: john.r.rose@oracle.com

#
# Copyright (c) 2011, 2014, 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 $(SPEC)
include MakeBase.gmk
include JavaCompilation.gmk

default: all

include Tools.gmk

JDK_OUT_CLASSES := $(wildcard $(JDK_OUTPUTDIR)/modules/*)
$(eval $(call FillCacheFind, $(JDK_OUT_CLASSES)))

include Profiles.gmk

#
# This makefile...so that altering will trigger rebuilding include/exclude-lists => jars
#
MAKEFILE = $(JDK_TOPDIR)/make/CreateJars.gmk
#
# And similarly for the Profiles
PROFILE_MAKEFILES = $(JDK_TOPDIR)/make/Profiles.gmk $(JDK_TOPDIR)/make/profile-rtjar-includes.txt

MAINMANIFEST := $(JDK_TOPDIR)/make/data/mainmanifest/manifest.mf
BEANMANIFEST := $(JDK_TOPDIR)/make/data/swingbeaninfo/manifest.mf

$(eval $(call MakeDir, $(IMAGES_OUTPUTDIR)/lib))

##########################################################################################

$(eval $(call SetupArchive,BUILD_JCONSOLE_JAR, , \
    SRCS := $(JDK_OUTPUTDIR)/modules/jdk.jconsole, \
    SUFFIXES := .class .gif .png .properties, \
    INCLUDES := sun/tools/jconsole com/sun/tools/jconsole, \
    JARMAIN := sun.tools.jconsole.JConsole, \
    JAR := $(IMAGES_OUTPUTDIR)/lib/jconsole.jar, \
    SKIP_METAINF := true))


##########################################################################################

$(eval $(call SetupArchive,BUILD_DNS_JAR, , \
    SRCS := $(JDK_OUTPUTDIR)/modules/jdk.naming.dns, \
    INCLUDES := sun/net/spi/nameservice/dns, \
    EXTRA_FILES := META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor, \
    JAR := $(IMAGES_OUTPUTDIR)/lib/ext/dnsns.jar, \
    SKIP_METAINF := true))


##########################################################################################

LOCALEDATA_INCLUDE_LOCALES := ar be bg ca cs da de el es et fi fr ga hi hr hu in is it \
    iw ja ko lt lv mk ms mt nl no pl pt ro ru sk sl sq sr sv \
    th tr uk vi zh

LOCALEDATA_INCLUDES := sun/util/resources/provider/NonEnLocaleDataMetaInfo.class
LOCALEDATA_INCLUDES += $(addprefix sun/text/resources/, $(LOCALEDATA_INCLUDE_LOCALES)) \
    $(addprefix sun/util/resources/, $(LOCALEDATA_INCLUDE_LOCALES))

LOCALEDATA_SERVICES_DIR := $(IMAGES_OUTPUTDIR)/localemetainfo

LOCALEDATA_METAINF_SERVICES := $(LOCALEDATA_SERVICES_DIR)/META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo

$(LOCALEDATA_METAINF_SERVICES): $(JDK_TOPDIR)/src/jdk.localedata/META-INF/localedata-services/sun.util.locale.provider.LocaleDataMetaInfo
	$(install-file)

$(eval $(call SetupArchive,BUILD_LOCALEDATA_JAR, \
    $(LOCALEDATA_METAINF_SERVICES), \
    SRCS := $(JDK_OUTPUTDIR)/modules/jdk.localedata \
        $(LOCALEDATA_SERVICES_DIR), \
    SUFFIXES := .class _dict _th, \
    INCLUDES := $(LOCALEDATA_INCLUDES), \
    EXTRA_FILES := META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo, \
    JAR := $(IMAGES_OUTPUTDIR)/lib/ext/localedata.jar, \
    SKIP_METAINF := true))

##########################################################################################
#
# 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.
#
##########################################################################################

# 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/sun/codemodel \
    com/sun/crypto/provider \
    com/sun/istack/internal/tools \
    com/sun/jarsigner \
    com/sun/java/accessibility \
    com/sun/javadoc \
    com/sun/jdi \
    com/sun/net/ssl/internal/ssl \
    com/sun/source \
    com/sun/tools \
    com/sun/xml/internal/dtdparser \
    com/sun/xml/internal/rngom \
    com/sun/xml/internal/xsom \
    javax/crypto \
    javax/swing/AbstractButtonBeanInfo.class \
    javax/swing/beaninfo \
    javax/swing/BoxBeanInfo.class \
    javax/swing/JAppletBeanInfo.class \
    javax/swing/JButtonBeanInfo.class \
    javax/swing/JCheckBoxBeanInfo.class \
    javax/swing/JCheckBoxMenuItemBeanInfo.class \
    javax/swing/JColorChooserBeanInfo.class \
    javax/swing/JComboBoxBeanInfo.class \
    javax/swing/JComponentBeanInfo.class \
    javax/swing/JDesktopPaneBeanInfo.class \
    javax/swing/JDialogBeanInfo.class \
    javax/swing/JEditorPaneBeanInfo.class \
    javax/swing/JFileChooserBeanInfo.class \
    javax/swing/JFormattedTextFieldBeanInfo.class \
    javax/swing/JFrameBeanInfo.class \
    javax/swing/JInternalFrameBeanInfo.class \
    javax/swing/JLabelBeanInfo.class \
    javax/swing/JLayeredPaneBeanInfo.class \
    javax/swing/JListBeanInfo.class \
    javax/swing/JMenuBarBeanInfo.class \
    javax/swing/JMenuBeanInfo.class \
    javax/swing/JMenuItemBeanInfo.class \
    javax/swing/JOptionPaneBeanInfo.class \
    javax/swing/JPanelBeanInfo.class \
    javax/swing/JPasswordFieldBeanInfo.class \
    javax/swing/JPopupMenuBeanInfo.class \
    javax/swing/JProgressBarBeanInfo.class \
    javax/swing/JRadioButtonBeanInfo.class \
    javax/swing/JRadioButtonMenuItemBeanInfo.class \
    javax/swing/JScrollBarBeanInfo.class \
    javax/swing/JScrollPaneBeanInfo.class \
    javax/swing/JSeparatorBeanInfo.class \
    javax/swing/JSliderBeanInfo.class \
    javax/swing/JSpinnerBeanInfo.class \
    javax/swing/JSplitPaneBeanInfo.class \
    javax/swing/JTabbedPaneBeanInfo.class \
    javax/swing/JTableBeanInfo.class \
    javax/swing/JTextAreaBeanInfo.class \
    javax/swing/JTextFieldBeanInfo.class \
    javax/swing/JTextPaneBeanInfo.class \
    javax/swing/JToggleButtonBeanInfo.class \
    javax/swing/JToolBarBeanInfo.class \
    javax/swing/JTreeBeanInfo.class \
    javax/swing/JWindowBeanInfo.class \
    javax/swing/SwingBeanInfoBase.class \
    javax/swing/text/JTextComponentBeanInfo.class \
    jdk/nio/zipfs \
    META-INF/services/com.sun.jdi.connect.Connector \
    META-INF/services/com.sun.jdi.connect.spi.TransportService \
    META-INF/services/com.sun.tools.attach.spi.AttachProvider \
    META-INF/services/com.sun.tools.xjc.Plugin \
    META-INF/services/javax.script.ScriptEngineFactory \
    META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor \
    META-INF/services/java.nio.file.spi.FileSystemProvider \
    org/relaxng/datatype \
    sun/awt/HKSCS.class \
    sun/awt/motif/X11GB2312.class \
    sun/awt/motif/X11GB2312$$$$Decoder.class \
    sun/awt/motif/X11GB2312$$$$Encoder.class \
    sun/awt/motif/X11GBK.class \
    sun/awt/motif/X11GBK$$$$Encoder.class \
    sun/awt/motif/X11KSC5601.class \
    sun/awt/motif/X11KSC5601$$$$Decoder.class \
    sun/awt/motif/X11KSC5601$$$$Encoder.class \
    sun/jvmstat \
    sun/net/spi/nameservice/dns \
    sun/nio/cs/ext \
    sun/rmi/rmic \
    sun/security/ec \
    sun/security/internal \
    sun/security/mscapi \
    sun/security/pkcs11 \
    sun/security/provider/Sun.class \
    sun/security/rsa/SunRsaSign.class \
    sun/security/ssl \
    sun/security/tools/jarsigner \
    sun/swing/BeanInfoUtils.class \
    sun/text/resources/cldr \
    sun/tools/asm \
    sun/tools/attach \
    sun/tools/java \
    sun/tools/javac \
    sun/tools/jcmd \
    sun/tools/jconsole \
    sun/tools/jinfo \
    sun/tools/jmap \
    sun/tools/jps \
    sun/tools/jstack \
    sun/tools/jstat \
    sun/tools/jstatd \
    sun/tools/native2ascii \
    sun/tools/serialver \
    sun/tools/tree \
    sun/tools/util \
    sun/util/cldr/CLDRLocaleDataMetaInfo.class \
    sun/util/resources/provider/NonEnLocaleDataMetaInfo.class \
    META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo \
    sun/util/resources/cldr \
    $(LOCALEDATA_INCLUDES) \
    com/oracle/jrockit/jfr \
    oracle/jrockit/jfr \
    jdk/jfr \
    jdk/internal/dynalink \
    jdk/nashorn \
    sun/jvm \
    toolbarButtonGraphics \
    sa.properties \
    com/sun/java/swing/action \
    com/sun/java/swing/ui \
    com/oracle/security \
    #

# Find all files in the classes dir to use as dependencies. This could be more fine granular.
ALL_FILES_IN_CLASSES := $(call not-containing, _the., $(filter-out %javac_state, \
    $(call CacheFind, $(JDK_OUT_CLASSES))))

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)
	$(RM) $@ $@.tmp
	$(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \
	    -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \
	    $(MAINMANIFEST) >> $@.tmp
	$(ECHO) >> $@.tmp
	$(CAT) $(BEANMANIFEST) >> $@.tmp
	$(MV) $@.tmp $@

$(RESOURCE_JAR_MANIFEST_FILE): $(MAINMANIFEST)
	$(MKDIR) -p $(@D)
	$(RM) $@ $@.tmp
	$(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \
	    -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \
	    $(MAINMANIFEST) >> $@.tmp
	$(MV) $@.tmp $@

$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.exclude: $(MAKEFILE) $(PROFILE_MAKEFILES)
	$(MKDIR) -p $(@D)
	$(RM) $@ $@.tmp
	$(call ListPathsSafely,RT_JAR_EXCLUDES,\n, >> $@.tmp)
	$(MV) $@.tmp $@

$(IMAGES_OUTPUTDIR)/lib/classlist: $(JDK_TOPDIR)/make/data/classlist/classlist.$(OPENJDK_TARGET_OS) \
    $(MAKEFILE)
	$(MKDIR) -p $(@D)
	$(RM) $@ $@.tmp
	$(TOOL_ADDJSUM) $< $@.tmp
	$(MV) $@.tmp $@

$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents: $(BUILD_TOOLS_JDK) $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.exclude \
    $(ALL_FILES_IN_CLASSES) $(IMAGES_OUTPUTDIR)/lib/classlist
	$(MKDIR) -p $(@D)
	$(RM) $@ $@.tmp
	($(CD) $(JDK_OUTPUTDIR)/modules && \
	$(TOOL_JARREORDER) -m \
	    -o $@.tmp $(IMAGES_OUTPUTDIR)/lib/classlist $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.exclude . )
	$(MV) $@.tmp $@

$(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$(PROFILE)/_the.jars.contents > $@.tmp
        ifneq ($(PROFILE), )
          # Add back classes from excluded packages (fixing the $ substitution in the process)
          # This currently won't work with modular build layout, but there currently are no 
          # types needing to be re added.
	  for type in $(subst \$$,\, $(RT_JAR_INCLUDE_TYPES)) ; do \
	    $(ECHO) $$type >> $@.tmp ; \
	  done
        endif
	$(MV) $@.tmp $@

$(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 ' _the\.' -e 'javac_state' \
	    $(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
          # Preserve any -C <dir> part of the original include line.
	  for service in $(PROFILE_INCLUDE_METAINF_SERVICES) ; do \
	    $(GREP) -e "$$service" $@.tmp >> $@.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)


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

# 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)
	$(ECHO) Creating rt.jar $(PROFILE) Compressed=$(COMPRESS_JARS)
	$(MKDIR) -p $(@D)
	$(RM) $@ $@.tmp
	$(CD) $(JDK_OUTPUTDIR)/modules && \
	$(JAR) $(RT_JAR_CREATE_OPTIONS) $@.tmp $(RT_JAR_MANIFEST_FILE) \
	    @$(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); \
	fi
	$(MV) $@.tmp $@

$(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)/modules && \
	$(JAR) $(RT_JAR_CREATE_OPTIONS) $@.tmp $(RESOURCE_JAR_MANIFEST_FILE) \
	    @$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents
	$(MV) $@.tmp $@

##########################################################################################

ifneq ($(OPENJDK_TARGET_OS), windows)
  CHARSETS_EXTRA_FILES := sun/awt/motif/X11GBK.class \
      sun/awt/motif/X11GB2312$$$$Decoder.class \
      sun/awt/motif/X11GB2312.class \
      sun/awt/motif/X11KSC5601$$$$Decoder.class \
      sun/awt/motif/X11KSC5601$$$$Encoder.class \
      sun/awt/motif/X11GB2312$$$$Encoder.class \
      sun/awt/motif/X11GBK$$$$Encoder.class \
      sun/awt/motif/X11KSC5601.class
endif

$(eval $(call SetupArchive,BUILD_CHARSETS_JAR, , \
    SRCS := $(JDK_OUT_CLASSES), \
    SUFFIXES := .class .dat, \
    INCLUDES := sun/nio/cs/ext, \
    EXTRA_FILES := sun/awt/HKSCS.class \
        $(CHARSETS_EXTRA_FILES), \
    JAR := $(IMAGES_OUTPUTDIR)/lib/charsets.jar, \
    SKIP_METAINF := true, \
    CHECK_COMPRESS_JAR := true))

##########################################################################################

$(eval $(call SetupArchive,BUILD_ZIPFS_JAR, , \
    SRCS := $(JDK_OUT_CLASSES), \
    INCLUDES := jdk/nio/zipfs, \
    EXTRA_FILES := META-INF/services/java.nio.file.spi.FileSystemProvider, \
    JAR := $(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar, \
    SKIP_METAINF := true, \
    CHECK_COMPRESS_JAR := true))

##########################################################################################

ifndef OPENJDK
  ifeq ($(ENABLE_JFR), true)
    $(eval $(call SetupArchive,BUILD_JFR_JAR, , \
        SRCS := $(JDK_OUTPUTDIR)/modules/jdk.jfr, \
        SUFFIXES := .class .jfc .xsd, \
        INCLUDES := com/oracle/jrockit/jfr \
            oracle/jrockit/jfr \
            jdk/jfr, \
        JAR := $(IMAGES_OUTPUTDIR)/lib/jfr.jar, \
        SKIP_METAINF := true, \
        MANIFEST := $(MAINMANIFEST), \
        CHECK_COMPRESS_JAR := true))

  endif
endif

##########################################################################################

$(eval $(call SetupArchive,BUILD_JSSE_JAR, , \
    SRCS := $(JDK_OUT_CLASSES), \
    INCLUDES := sun/security/provider/Sun.class \
        sun/security/rsa/SunRsaSign.class \
        sun/security/ssl \
        com/sun/net/ssl/internal/ssl, \
    JAR := $(IMAGES_OUTPUTDIR)/lib/jsse.jar, \
    SKIP_METAINF := true, \
    MANIFEST := $(MAINMANIFEST), \
    CHECK_COMPRESS_JAR := true))

##########################################################################################

$(eval $(call SetupArchive,BUILD_SWINGBEANS_JAR, , \
    SRCS := $(JDK_OUTPUTDIR)/modules/java.desktop, \
    SUFFIXES := BeanInfo.class .gif, \
    INCLUDES := javax/swing sun/swing, \
    EXCLUDES := javax/swing/plaf, \
    EXTRA_FILES := javax/swing/SwingBeanInfoBase.class sun/swing/BeanInfoUtils.class, \
    JAR := $(IMAGES_OUTPUTDIR)/lib/dt.jar, \
    SKIP_METAINF := true))

##########################################################################################

# Get the CLDRVERSION
include gensrc/GensrcCLDR.gmk

CLDRDATA_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/cldrdata.jar

CLDR_SERVICES_DIR := $(IMAGES_OUTPUTDIR)/cldrmetainfo

CLDR_METAINF_SERVICES := $(CLDR_SERVICES_DIR)/META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo

$(CLDR_METAINF_SERVICES): $(JDK_TOPDIR)/src/jdk.localedata/META-INF/cldrdata-services/sun.util.locale.provider.LocaleDataMetaInfo
	$(install-file)

$(eval $(call SetupArchive,BUILD_CLDRDATA_JAR, \
    $(CLDR_METAINF_SERVICES), \
    SRCS := $(JDK_OUTPUTDIR)/modules/jdk.localedata \
        $(JDK_OUTPUTDIR)/modules/java.base \
        $(CLDR_SERVICES_DIR), \
    SUFFIXES := .class, \
    INCLUDES := sun/text/resources/cldr \
        sun/util/cldr/CLDRLocaleDataMetaInfo.class \
        sun/util/resources/cldr, \
    EXTRA_FILES := META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo, \
    JAR := $(CLDRDATA_JAR_DST), \
    EXTRA_MANIFEST_ATTR := CLDR-Version: $(CLDRVERSION), \
    SKIP_METAINF := true))

##########################################################################################

TOOLS_JAR_INCLUDES := \
    com/sun/codemodel \
    com/sun/istack/internal/tools \
    com/sun/jarsigner \
    com/sun/javadoc \
    com/sun/jdi \
    com/sun/source \
    com/sun/tools/attach \
    com/sun/tools/classfile \
    com/sun/tools/corba \
    com/sun/tools/doclets \
    com/sun/tools/doclint \
    com/sun/tools/example/debug/expr \
    com/sun/tools/example/debug/tty \
    com/sun/tools/extcheck \
    com/sun/tools/hat \
    com/sun/tools/internal/jxc \
    com/sun/tools/internal/jxc/ap \
    com/sun/tools/internal/ws \
    com/sun/tools/internal/ws/wscompile/plugin/at_generated \
    com/sun/tools/internal/xjc \
    com/sun/tools/javac \
    com/sun/tools/javadoc \
    com/sun/tools/javah \
    com/sun/tools/javap \
    com/sun/tools/jdeps \
    com/sun/tools/jdi \
    com/sun/tools/script/shell \
    com/sun/xml/internal/dtdparser \
    com/sun/xml/internal/rngom \
    com/sun/xml/internal/xsom \
    org/relaxng/datatype \
    sun/applet \
    sun/jvmstat \
    sun/rmi/rmic \
    sun/security/tools/jarsigner \
    sun/tools/asm \
    sun/tools/attach \
    sun/tools/jar \
    sun/tools/java \
    sun/tools/javac \
    sun/tools/jcmd \
    sun/tools/jinfo \
    sun/tools/jmap \
    sun/tools/jps \
    sun/tools/jstack \
    sun/tools/jstat \
    sun/tools/jstatd \
    sun/tools/native2ascii \
    sun/tools/serialver \
    sun/tools/tree \
    sun/tools/util

# The sjavac tools is not ready for public consumption.
TOOLS_JAR_EXCLUDES = com/sun/tools/sjavac

TOOLS_JAR_SRC := $(addprefix $(JDK_OUTPUTDIR)/modules/,\
    java.corba \
    java.desktop \
    jdk.attach \
    jdk.compiler \
    jdk.dev \
    jdk.javadoc \
    jdk.jconsole \
    jdk.jcmd \
    jdk.jdi \
    jdk.jvmstat \
    jdk.rmic \
    jdk.runtime \
    jdk.xml.bind \
    jdk.xml.ws \
    )
    #

$(eval $(call SetupArchive,BUILD_TOOLS_JAR, , \
    SRCS := $(TOOLS_JAR_SRC), \
    SUFFIXES := .class .prp .gif .properties .xml .css .xsd .js .html .txt .java \
        Tool aliasmap options, \
    INCLUDES := $(TOOLS_JAR_INCLUDES), \
    EXCLUDES := $(TOOLS_JAR_EXCLUDES), \
    EXTRA_FILES := \
        $(JDK_OUTPUTDIR)/modules/jdk.jdi/META-INF/services/com.sun.jdi.connect.Connector \
        META-INF/services/com.sun.jdi.connect.spi.TransportService \
        META-INF/services/com.sun.tools.attach.spi.AttachProvider \
        META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \
        META-INF/services/com.sun.tools.internal.xjc.Plugin, \
    JAR := $(IMAGES_OUTPUTDIR)/lib/tools.jar, \
    SKIP_METAINF := true, \
    CHECK_COMPRESS_JAR := true))


##########################################################################################

include CORE_PKGS.gmk
include NON_CORE_PKGS.gmk

# The compiler should not issue a "Proprietary" warning when compiling
# classes in the com.sun.java.swing.plaf packages, since we've always
# allowed, and even advocated, extending them (see bug 6476749).
#
# This approach is NOT to be used as a general purpose way to avoid such
# compiler warnings for non-core packages. The correct way is to document
# the packages in NON_CORE_PKGS.gmk, and include them in the NON_CORE_PKGS
# definition.
#
# Swing has taken this approach only as a temporary measure to avoid
# the compiler warnings until we can properly document these packages.
# This is covered under 6491853.
EXCLUDE_PROPWARN_PKGS = com.sun.java.swing.plaf.windows \
    com.sun.java.swing.plaf.motif \
    com.sun.java.swing.plaf.gtk

#
# Include the exported private packages in ct.sym.
# This is an interim solution until the ct.sym is replaced
# with a new module system (being discussed for JDK 8).
#
EXPORTED_PRIVATE_PKGS = com.oracle.net \
    com.oracle.nio

$(IMAGES_OUTPUTDIR)/symbols/_the.symbols: $(IMAGES_OUTPUTDIR)/lib/rt.jar
	$(RM) -r $(IMAGES_OUTPUTDIR)/symbols/META-INF/sym
	$(MKDIR) -p $(IMAGES_OUTPUTDIR)/symbols/META-INF/sym
	$(JAVA) $(NEW_JAVAC) \
	    -bootclasspath "$(IMAGES_OUTPUTDIR)/lib/rt.jar" \
	    -XDprocess.packages -proc:only \
	    -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) $@

$(eval $(call MakeDir, $(IMAGES_OUTPUTDIR)/symbols))
$(eval $(call SetupArchive,BUILD_CT_SYM, $(IMAGES_OUTPUTDIR)/symbols/_the.symbols, \
    SRCS := $(IMAGES_OUTPUTDIR)/symbols, \
    INCLUDES := META-INF/sym, \
    JAR := $(IMAGES_OUTPUTDIR)/lib/ct.sym, \
    CHECK_COMPRESS_JAR := true))


##########################################################################################

ifdef OPENJDK
    SRC_ZIP_INCLUDES = \
        com \
        java \
        javax \
        jdk \
        org \
        sun \
        #
    SRC_ZIP_EXCLUDES =
else
    SRC_ZIP_INCLUDES = \
        com/sun/corba \
        com/sun/image/codec/jpeg \
        com/sun/imageio \
        com/sun/java_cup \
        com/sun/javadoc \
        com/sun/java/swing \
        com/sun/jmx \
        com/sun/naming \
        com/sun/org/apache \
        com/sun/security/auth \
        com/sun/security/jgss \
        com/sun/source \
        java \
        javax/accessibility \
        javax/annotation \
        javax/imageio \
        javax/lang \
        javax/management \
        javax/naming \
        javax/print \
        javax/rmi \
        javax/script \
        javax/security \
        javax/sound \
        javax/sql \
        javax/swing \
        javax/tools \
        javax/xml \
        org/ietf \
        org/omg \
        org/w3c/dom \
        org/xml/sax \
        #
    SRC_ZIP_EXCLUDES = javax/swing/beaninfo
endif

SRC_ZIP_SRCS := $(wildcard \
    $(JDK_TOPDIR)/src/*/share/classes \
    $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS)/classes \
    $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS_API_DIR)/classes \
    $(LANGTOOLS_TOPDIR)/src/*/share/classes \
    $(CORBA_TOPDIR)/src/*/share/classes \
    $(JAXP_TOPDIR)/src/*/share/classes \
    $(JAXWS_TOPDIR)/src/*/share/classes \
    $(JDK_OUTPUTDIR)/gensrc/j* \
    $(JDK_OUTPUTDIR)/gendocsrc_rmic \
    $(CORBA_OUTPUTDIR)/gensrc/j* \
    ) \
    #
ifndef OPENJDK
  SRC_ZIP_SRCS += $(wildcard $(JDK_TOPDIR)/src/closed/*/share/classes)
endif

# Need to copy launcher src files into desired directory structure
# before zipping the sources.
$(eval $(call SetupCopyFiles,COPY_LAUNCHER_SRC, \
    SRC := $(JDK_TOPDIR)/src/java.base, \
    DEST := $(IMAGES_OUTPUTDIR)/src/launcher, \
    FLATTEN := true, \
    FILES := $(wildcard \
        $(JDK_TOPDIR)/src/java.base/share/native/launcher/* \
        $(JDK_TOPDIR)/src/java.base/share/native/libjli/* \
        $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjli/java_md*)))

LAUNCHER_ZIP_SRC := $(COPY_LAUNCHER_SRC)

$(IMAGES_OUTPUTDIR)/src.zip: $(LAUNCHER_ZIP_SRC)

# This dir needs to exist before macro is evaluated to avoid warning from find.
$(eval $(call MakeDir, $(IMAGES_OUTPUTDIR)/src))
$(eval $(call SetupZipArchive,BUILD_SRC_ZIP, \
    SRC := $(SRC_ZIP_SRCS) $(IMAGES_OUTPUTDIR)/src, \
    INCLUDES := $(SRC_ZIP_INCLUDES) launcher, \
    EXCLUDES := $(SRC_ZIP_EXCLUDES), \
    SUFFIXES := .java .c .h, \
    ZIP := $(IMAGES_OUTPUTDIR)/src.zip, \
    EXTRA_DEPS := $(LAUNCHER_ZIP_SRC)))

##########################################################################################

# This file is imported from hotspot in Import.gmk. Copying it into images/lib so that
# all jars can be found in one place when creating images in Images.gmk. It needs to be
# done here so that clean targets can be simple and accurate.
$(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar: $(HOTSPOT_DIST)/lib/sa-jdi.jar
	$(install-file)

##########################################################################################
#
# sec-bin.zip is used by builds where the corresponding sources are not available
#
$(eval $(call SetupZipArchive,BUILD_SEC_BIN_ZIP, \
    SRC := $(JDK_OUTPUTDIR), \
    INCLUDES := modules/java.base/javax/net \
        modules/java.base/javax/security/cert \
        modules/java.base/com/sun/net/ssl \
        modules/java.base/com/sun/security/cert \
        modules/java.base/sun/net/www/protocol/https \
        modules/java.base/sun/security/pkcs12 \
        modules/java.base/sun/security/ssl \
        modules/java.security.jgss/sun/security/krb5 \
        modules/java.security.jgss/sun/security/krb5/internal \
        modules/java.security.jgss/sun/security/krb5/internal/ccache \
        modules/java.security.jgss/sun/security/krb5/internal/crypto \
        modules/java.security.jgss/sun/security/krb5/internal/ktab \
        modules/java.security.jgss/sun/security/krb5/internal/rcache \
        modules/java.security.jgss/sun/security/krb5/internal/util, \
    INCLUDE_FILES := modules/java.security.jgss/sun/security/jgss/spi/GSSContextSpi.class, \
    EXCLUDES := modules/java.security.jgss/sun/security/krb5/internal/tools, \
    ZIP := $(IMAGES_OUTPUTDIR)/sec-bin.zip))

JARS += $(IMAGES_OUTPUTDIR)/sec-bin.zip

##########################################################################################
#
# Windows specific binary security packages.
#
ifeq ($(OPENJDK_TARGET_OS), windows)
  # sec-windows-bin.zip is used by builds where the corresponding sources are not available
  $(eval $(call SetupZipArchive,BUILD_SEC_WINDOWS_BIN_ZIP, \
      SRC := $(JDK_OUTPUTDIR), \
      INCLUDES := modules/java.security.jgss/sun/security/krb5/internal/tools, \
      ZIP := $(IMAGES_OUTPUTDIR)/sec-windows-bin.zip))

  JARS += $(IMAGES_OUTPUTDIR)/sec-windows-bin.zip

  # JGSS files contain the native Kerberos library
  ifeq ($(OPENJDK_TARGET_CPU), x86_64)
    JGSS_ZIP_NAME = jgss-windows-x64-bin.zip
  else
    JGSS_ZIP_NAME = jgss-windows-i586-bin.zip
  endif

  $(eval $(call SetupZipArchive,BUILD_JGSS_BIN_ZIP, \
      SRC := $(JDK_OUTPUTDIR), \
      INCLUDE_FILES := bin/w2k_lsa_auth.dll \
          bin/w2k_lsa_auth.map \
          bin/w2k_lsa_auth.pdb, \
      ZIP := $(IMAGES_OUTPUTDIR)/$(JGSS_ZIP_NAME)))

  JARS += $(IMAGES_OUTPUTDIR)/$(JGSS_ZIP_NAME)
endif

##########################################################################################

# This rule copies all jars from jdk/lib/... to images/lib/... to avoid having to track 
# which jars are where
$(IMAGES_OUTPUTDIR)/lib/%: $(JDK_OUTPUTDIR)/lib/%
	$(install-file)

##########################################################################################

# Import nashorn.jar from nashorn dist dir.
$(IMAGES_OUTPUTDIR)/lib/ext/nashorn.jar: $(NASHORN_DIST)/nashorn.jar
	$(install-file)

##########################################################################################

# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, jdk, CreateJars.gmk))

##########################################################################################

all: $(JARS)

.PHONY: default all