jdk/make/common/Release.gmk
author duke
Wed, 05 Jul 2017 17:15:25 +0200
changeset 5670 1086a4300e1e
parent 5631 cfb4f43485f3
child 5801 8008ed6e4a37
permissions -rw-r--r--
Merge

#
# Copyright (c) 1997, 2009, 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 $(JDK_TOPDIR)/make/docs/CORE_PKGS.gmk
include $(JDK_TOPDIR)/make/docs/NON_CORE_PKGS.gmk

#
# Perform release engineering tasks.
#
# images    An image is what the product looks like when it is
#           installed.
#

IMAGE_BINDIR = bin

# The compiler should not issue a "Sun Propietary" 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

# This is a stopgap until 6839872 is fixed.
EXCLUDE_PROPWARN_PKGS += sun.dyn

# 64-bit solaris has a few special cases. We define the variable
# SOLARIS64 for use in this Makefile to easily test those cases
ifeq ($(PLATFORM), solaris)
  ifeq ($(ARCH_DATA_MODEL), 64)
    SOLARIS64 = true
    IMAGE_BINDIR = bin/$(ARCH)
  endif
endif

JTG_DOCS            = $(JDK_TOPDIR)/src/solaris/doc

#We use this for man page header
jdkversion := $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)

# Text documents on windows use this suffix
ifeq ($(PLATFORM), windows)
  TEXT_SUFFIX = .txt
endif

# The base names of all the license and document files for the jdk and jre
#   (These files get placed in the jdk and jre install images)
ifdef OPENJDK
  # Where to find these files
  SHARE_JDK_DOC_SRC = $(JDK_TOPDIR)
  SHARE_JRE_DOC_SRC = $(JDK_TOPDIR)
  # Same files for jdk and jre, no name changes
  LICENSE_DOCLIST_JDK = LICENSE     ASSEMBLY_EXCEPTION
  LICENSE_DOCLIST_JRE = LICENSE     ASSEMBLY_EXCEPTION
  OTHER_DOCLIST_JDK   = THIRD_PARTY_README
  OTHER_DOCLIST_JRE   = THIRD_PARTY_README
else
  # Where to find these files
  SHARE_JDK_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jdk
  SHARE_JRE_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jre
  # Select the pre-release or FCS license version based on the build milestone.
  LICENSE_VERSION=.pre
  ifeq ($(MILESTONE), fcs)
    LICENSE_VERSION=.fcs
  endif
  ifeq ($(PLATFORM), windows)
    LICENSE_DOCLIST_JDK = $(subst $(LICENSE_VERSION),,\
		   $(shell $(CD) $(SHARE_JDK_DOC_SRC) && \
		           $(LS) *LICENSE*$(LICENSE_VERSION)))
    LICENSE_DOCLIST_JRE = $(subst $(LICENSE_VERSION),,\
		   $(shell $(CD) $(SHARE_JRE_DOC_SRC) && \
		           $(LS) *LICENSE*$(LICENSE_VERSION)))
  else
    LICENSE_DOCLIST_JDK = $(subst $(LICENSE_VERSION),,\
	         $(shell $(CD) $(SHARE_JDK_DOC_SRC) && \
		         $(LS) *LICENSE*$(LICENSE_VERSION) | $(GREP) -v rtf))
    LICENSE_DOCLIST_JRE = $(subst $(LICENSE_VERSION),,\
	         $(shell $(CD) $(SHARE_JRE_DOC_SRC) && \
		         $(LS) *LICENSE*$(LICENSE_VERSION) | $(GREP) -v rtf))
  endif
  OTHER_DOCLIST_JDK = COPYRIGHT README.html README_ja.html README_zh_CN.html
  OTHER_DOCLIST_JRE = COPYRIGHT Welcome.html
  JRE_NAMECHANGE_DOCLIST = README
endif

# Paths to these files we need
JDK_LICENSES   = $(LICENSE_DOCLIST_JDK:%=$(JDK_IMAGE_DIR)/%)
JDK64_LICENSES = $(LICENSE_DOCLIST_JDK:%=$(JDK_IMAGE_DIR)/%64)
JDK_DOCFILES   = $(OTHER_DOCLIST_JDK:%=$(JDK_IMAGE_DIR)/%)

JRE_LICENSES   = $(LICENSE_DOCLIST_JRE:%=$(JRE_IMAGE_DIR)/%)
JRE64_LICENSES = $(LICENSE_DOCLIST_JRE:%=$(JRE_IMAGE_DIR)/%64)
JRE_DOCFILES   = $(OTHER_DOCLIST_JRE:%=$(JRE_IMAGE_DIR)/%)
JRE_DOCFILES  += $(JRE_NAMECHANGE_DOCLIST:%=$(JRE_IMAGE_DIR)/%$(TEXT_SUFFIX))

# absolute directory names: note, these must exist prior to build
# time - they are created in the main Makefile.
JRE_IMAGE_BINDIR   = $(JRE_IMAGE_DIR)/bin
JRE_IMAGE_THREADIR = $(JRE_IMAGE_DIR)/bin/*/native_threads

MAINMANIFEST  = $(JDK_TOPDIR)/make/tools/manifest.mf
BEANMANIFEST  = $(JDK_TOPDIR)/make/javax/swing/beaninfo/manifest

#
# Man pages
#

JRE_MAN_PAGES =         \
	java.1		\
	keytool.1	\
	orbd.1          \
	pack200.1	\
	policytool.1    \
	rmid.1		\
	rmiregistry.1	\
	servertool.1    \
	tnameserv.1     \
	unpack200.1

ifeq ($(ARCH_DATA_MODEL),32)
  JRE_MAN_PAGES += javaws.1
endif

JDK_MAN_PAGES =            \
	$(JRE_MAN_PAGES)   \
	appletviewer.1     \
        apt.1              \
	extcheck.1         \
	idlj.1             \
	jar.1              \
	jarsigner.1        \
	javac.1            \
	javadoc.1          \
	javah.1            \
	javap.1            \
	jconsole.1         \
	jdb.1              \
	jhat.1             \
        jinfo.1            \
        jmap.1             \
        jps.1              \
	jrunscript.1       \
        jsadebugd.1        \
        jstack.1           \
        jstat.1            \
        jstatd.1           \
	native2ascii.1     \
	rmic.1             \
        schemagen.1        \
	serialver.1        \
        wsgen.1            \
        wsimport.1         \
        xjc.1

ifeq ($(PLATFORM), solaris)
  MANBASEDIRS=$(JDK_TOPDIR)/src/solaris/doc $(IMPORTDOCDIR)
  MAN1SUBDIR=sun/man/man1
endif # solaris

ifeq ($(PLATFORM), linux)
  MANBASEDIRS=$(JDK_TOPDIR)/src/linux/doc $(IMPORTDOCDIR)
  MAN1SUBDIR=man
  JA_DIRNAME=ja_JP.$(JA_SOURCE_ENCODING)
endif # linux

define copy-man-pages
$(MKDIR) -p $1/man/man1
for manbase in $(MANBASEDIRS:%=%/$(MAN1SUBDIR)) ; do \
  for manpage in $2; do \
    if [ -f $${manbase}/$${manpage} ] ; then \
      $(CP) $${manbase}/$${manpage} $1/man/man1 ; \
      for ja_encoding in $(JA_TARGET_ENCODINGS); do \
        ja_dir="ja"; \
        if [ "$${ja_encoding}" != "$(JA_SOURCE_ENCODING)" ]; then \
          ja_dir="ja_JP.$${ja_encoding}"; \
	fi; \
        $(MKDIR) -p $1/man/$${ja_dir}/man1; \
        $(CAT) $${manbase}/ja/$${manpage} \
          | $(NATIVE2ASCII) -encoding $(JA_SOURCE_ENCODING) \
          | $(SED) 's/@@VERSION@@/$(jdkversion)/g' \
          | $(NATIVE2ASCII) -reverse -encoding $${ja_encoding} \
            > $1/man/$${ja_dir}/man1/$${manpage}; \
      done; \
    fi; \
  done; \
done
$(java-vm-cleanup)
if [ "$(JA_DIRNAME)" != "" ] ; then \
  $(MV) $1/man/ja $1/man/$(JA_DIRNAME); \
  $(CD) $1/man && $(LN) -s $(JA_DIRNAME) ja; \
fi
endef

#
# Targets.
#
INITIAL_IMAGE_JRE=initial-image-jre
INITIAL_IMAGE_JDK=initial-image-jdk
ifeq ($(PLATFORM), solaris)
  ifeq ($(ARCH_DATA_MODEL), 64)
    INITIAL_IMAGE_JRE=initial-image-jre-sol64
    INITIAL_IMAGE_JDK=initial-image-jdk-sol64
  endif
endif

images images-clobber \
initial-image-jre initial-image-jdk \
initial-image-jre-sol64 initial-image-jdk-sol64 \
trim-image-jre trim-image-jdk \
process-image-jre process-image-jdk \
compare-image \
sec-files sec-files-win jgss-files ::
	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."

#
# Export binary plugs if not building OPENJDK
#
ifdef OPENJDK
  EXPORT_BINARY_PLUGS =
else # !OPENJDK
  EXPORT_BINARY_PLUGS = export-binary-plugs test-binary-plugs
endif # OPENJDK

# Order is important here, trim jre after jdk image is created
images:: sanity-images post-sanity-images  \
         $(EXPORT_BINARY_PLUGS) \
	 $(INITIAL_IMAGE_JRE) $(INITIAL_IMAGE_JDK) \
	 trim-image-jre trim-image-jdk \
	 process-image-jre process-image-jdk sec-files sec-files-win jgss-files

# Don't use these
image-jre:: initial-image-jre trim-image-jre process-image-jre
image-jdk:: initial-image-jdk trim-image-jdk process-image-jdk

#
# Sources we ship in the SDK.
#
SOURCES = \
	java/applet			\
	java/awt			\
	java/beans			\
	java/io				\
	java/lang			\
	java/math			\
	java/net			\
	java/nio			\
	java/rmi			\
	java/security			\
	java/sql			\
	java/text			\
	java/util			\
	com/sun/corba			\
	com/sun/image/codec/jpeg	\
	com/sun/imageio                 \
	com/sun/java/swing		\
	com/sun/javadoc			\
	com/sun/jmx			\
	com/sun/mirror			\
	com/sun/source			\
	com/sun/naming			\
	com/sun/security/auth		\
	com/sun/security/jgss		\
	javax/accessibility		\
	javax/annotation		\
	javax/script			\
	javax/imageio			\
	javax/lang			\
	javax/management		\
	javax/naming			\
	javax/print			\
	javax/rmi			\
	javax/security			\
	javax/sound			\
	javax/sql			\
	javax/swing			\
	javax/tools			\
	javax/xml			\
	com/sun/org/apache		\
	com/sun/java_cup		\
	com/sun/jlex	        	\
	org/ietf			\
	org/omg				\
	org/w3c/dom			\
	org/xml/sax			\
	sunw
#
# Directories where sources may be found.  If a file with the same path
# name exists in more than one of these places, the one found last on this
# list wins.
#
SOURCE_DIRS = $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes
SOURCE_DIRS += $(GENSRCDIR)
SOURCE_DIRS += $(IMPORTSRCDIR)
ifndef OPENJDK
  SOURCE_DIRS += $(CLOSED_SRC)/share/classes
endif


#
# Specific files and directories that will be filtered out from above areas.
#
SOURCE_FILTERs = $(SCM_DIRs) ',*'
SOURCE_FILES_filter = $(SOURCE_FILTERs:%=-name % -prune -o)

#
# Bug 4249883 - excluding some unnecessary packages from com.sun.tools
#
# Bug 5008685 - exclude jconsole from sun/tools
#
TOOLS = \
	META-INF/services/com.sun.jdi.connect.Connector \
	META-INF/services/com.sun.jdi.connect.spi.TransportService \
	sun/tools/asm		\
	sun/tools/jar		\
	sun/tools/java		\
	sun/tools/javac		\
	sun/tools/jps		\
	sun/tools/jstat		\
	sun/tools/jstatd	\
	sun/tools/native2ascii	\
	sun/tools/serialver	\
	sun/tools/tree		\
	sun/tools/util		\
	sun/security/tools/JarBASE64Encoder.class \
	sun/security/tools/JarSigner.class \
	sun/security/tools/JarSignerParameters.class \
	sun/security/tools/JarSignerResources.class \
	sun/security/tools/JarSignerResources_ja.class \
	sun/security/tools/JarSignerResources_zh_CN.class \
	sun/security/tools/SignatureFile\$$Block.class \
	sun/security/tools/SignatureFile.class \
	sun/security/tools/TimestampedSigner.class \
	sun/rmi/rmic		\
	sun/applet		\
	sun/jvmstat		\
	com/sun/javadoc		\
	com/sun/jdi		\
	com/sun/jarsigner	\
	com/sun/mirror		\
	com/sun/source          \
	com/sun/tools/classfile \
	com/sun/tools/doclets   \
	com/sun/tools/example/debug/expr \
	com/sun/tools/example/debug/tty  \
	com/sun/tools/extcheck  \
	com/sun/tools/hat       \
	com/sun/tools/javac     \
	com/sun/tools/javadoc   \
	com/sun/tools/apt       \
	com/sun/tools/javah     \
	com/sun/tools/javap     \
	com/sun/tools/corba     \
	com/sun/tools/internal/xjc       \
	com/sun/tools/internal/ws       \
	META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory \
	META-INF/services/com.sun.tools.xjc.Plugin \
	com/sun/istack/internal/tools       \
	com/sun/istack/internal/ws       \
        com/sun/codemodel       \
        com/sun/tools/internal/jxc             \
        com/sun/xml/internal/rngom       \
        com/sun/xml/internal/xsom       \
        org/relaxng/datatype   \
	com/sun/xml/internal/dtdparser \
	com/sun/tools/jdi	\
	com/sun/tools/script/shell	\
	META-INF/services/com.sun.tools.attach.spi.AttachProvider \
	com/sun/tools/attach	\
	sun/tools/attach	\
	sun/tools/jstack        \
	sun/tools/jinfo         \
	sun/tools/jmap

# classes that go into jsse.jar
JSSE_CLASSES_DIRS = \
	sun/security/provider/Sun.class \
	sun/security/rsa/SunRsaSign.class \
	sun/security/ssl \
	com/sun/net/ssl/internal/ssl

# files under $(OUTPUTDIR) that need to go into sec-bin.zip for builds
# where the corresponding sources are not available
SEC_FILES_DIRS = \
	classes/javax/net \
	classes/javax/security/cert \
	classes/com/sun/net/ssl \
	classes/com/sun/security/cert \
	classes/sun/net/www/protocol/https \
	classes/sun/security/pkcs12 \
	classes/sun/security/ssl \
	classes/sun/security/krb5/*.class \
	classes/sun/security/krb5/internal/*.class \
	classes/sun/security/krb5/internal/ccache \
	classes/sun/security/krb5/internal/crypto \
	classes/sun/security/krb5/internal/ktab \
	classes/sun/security/krb5/internal/rcache \
	classes/sun/security/krb5/internal/util \
	classes/sun/security/jgss/spi/GSSContextSpi.class

# files under $(OUTPUTDIR) that need to go into sec-windows-win.zip for builds
# where the corresponding sources are not available
SEC_FILES_WIN_DIRS = \
	classes/sun/security/krb5/internal/tools

# files under $(BINDIR) that need to go into jgss_files.zip for builds
# where the corresponding sources are not available
JGSS_FILES_DIRS = \
	bin/w2k_lsa_auth.dll \
	bin/w2k_lsa_auth.map \
	bin/w2k_lsa_auth.pdb

# The following get removed from the SDK image.
NOTJDKTOOLS = \
	java_vm

# The following get removed from the JRE after the bulk-copy of BINDIR...
NOTJRETOOLS = \
	appletviewer$(EXE_SUFFIX) \
	extcheck$(EXE_SUFFIX) \
	idlj$(EXE_SUFFIX) \
	jar$(EXE_SUFFIX) \
	jarsigner$(EXE_SUFFIX) \
	java-rmi.cgi \
	javac$(EXE_SUFFIX) \
	javadoc$(EXE_SUFFIX) \
	apt$(EXE_SUFFIX) \
	javah$(EXE_SUFFIX) \
	javap$(EXE_SUFFIX) \
	jdb$(EXE_SUFFIX) \
	jps$(EXE_SUFFIX) \
	jrunscript$(EXE_SUFFIX) \
	jstat$(EXE_SUFFIX) \
	jstatd$(EXE_SUFFIX) \
	jstack$(EXE_SUFFIX) \
	packagebean$(SCRIPT_SUFFIX) \
	rmic$(EXE_SUFFIX) \
	serialver$(EXE_SUFFIX) \
	unregbean$(EXE_SUFFIX) \
	jconsole$(EXE_SUFFIX) \
	jinfo$(EXE_SUFFIX) \
	jmap$(EXE_SUFFIX) \
	native2ascii$(EXE_SUFFIX) \
	xjc$(EXE_SUFFIX) \
	wsgen$(EXE_SUFFIX) \
	wsimport$(EXE_SUFFIX) \
        schemagen$(EXE_SUFFIX) \
	jsadebugd$(EXE_SUFFIX) \
	jhat$(EXE_SUFFIX)

# The following get removed from the JRE after the bulk-copy of LIBDIR...
NOTJRELIBS = tools.jar \
        jconsole.jar

ifeq ($(INCLUDE_SA), true)
  NOTJRELIBS += sa-jdi.jar

  # The following get removed from the JRE after the bulk-copy of LIBDIR...
  NOTJRE_SHARED_LIBS = $(SALIB_NAME)
else
  NOTJRE_SHARED_LIBS =
endif

# Attach library is JDK only
NOTJRE_SHARED_LIBS += $(LIB_PREFIX)attach.$(LIBRARY_SUFFIX)

#
###### RULES

# Processing license files from source area to image area
#    These will be modified to have the platform specific EOL chars.
define process-doc-file
$(prep-target)
$(SED) 's/$$//g' $< > $@
$(CHMOD) 444 $@
endef

# JDK files
$(JDK_IMAGE_DIR)/%: $(SHARE_JDK_DOC_SRC)/%
	$(process-doc-file)
# Removes LICENSE_VERSION or not
ifdef LICENSE_VERSION
$(JDK_IMAGE_DIR)/%: $(SHARE_JDK_DOC_SRC)/%$(LICENSE_VERSION)
	$(process-doc-file)
$(JDK_IMAGE_DIR)/%64: $(SHARE_JDK_DOC_SRC)/%$(LICENSE_VERSION)
	$(process-doc-file)
else
$(JDK_IMAGE_DIR)/%64: $(SHARE_JDK_DOC_SRC)/%
	$(process-doc-file)
endif

# JRE files 
$(JRE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/%
	$(process-doc-file)
# Add $(TEXT_SUFFIX) suffix
ifdef TEXT_SUFFIX
$(JRE_IMAGE_DIR)/%$(TEXT_SUFFIX): $(SHARE_JRE_DOC_SRC)/%
	$(process-doc-file)
endif
# Removes LICENSE_VERSION or not
ifdef LICENSE_VERSION
$(JRE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/%$(LICENSE_VERSION)
	$(process-doc-file)
$(JRE_IMAGE_DIR)/%64: $(SHARE_JRE_DOC_SRC)/%$(LICENSE_VERSION)
	$(process-doc-file)
else
$(JRE_IMAGE_DIR)/%64: $(SHARE_JRE_DOC_SRC)/%
	$(process-doc-file)
endif

# Differences tool
DIRDIFF_JARFILE = $(BUILDTOOLJARDIR)/dirdiff.jar

######################################################
# List of directories in classes directory that should NOT be in rt.jar
######################################################

NOT_RT_JAR_LIST = $(ABS_TEMPDIR)/not_rt_jar.list

$(NOT_RT_JAR_LIST): FRC
	$(prep-target)
	$(ECHO) "#\n" >> $@
	$(ECHO) "# List of subdirectories not in include in rt.jar" >> $@
	$(ECHO) "# Directories must contain trailing '/'." >> $@
	$(ECHO) "com/sun/javadoc/" >> $@
	$(ECHO) "com/sun/jdi/" >> $@
	$(ECHO) "com/sun/jarsigner/" >> $@
	$(ECHO) "com/sun/mirror/" >> $@
	$(ECHO) "com/sun/source/" >> $@
	$(ECHO) "com/sun/istack/internal/tools/" >> $@
	$(ECHO) "com/sun/istack/internal/ws/" >> $@
	$(ECHO) "META-INF/services/com.sun.jdi.connect.Connector" >> $@
	$(ECHO) "META-INF/services/com.sun.jdi.connect.spi.TransportService" >> $@
	$(ECHO) "META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory" >> $@
	$(ECHO) "META-INF/services/com.sun.tools.xjc.Plugin" >> $@
	$(ECHO) "com/sun/tools/" >> $@
	$(ECHO) "sun/jvmstat/" >> $@
	$(ECHO) "sun/rmi/rmic/" >> $@
	$(ECHO) "sun/tools/asm/" >> $@
	$(ECHO) "sun/tools/java/" >> $@
	$(ECHO) "sun/tools/javac/" >> $@
	$(ECHO) "com/sun/tools/classfile/" >> $@
	$(ECHO) "com/sun/tools/javap/" >> $@
	$(ECHO) "sun/tools/jconsole/" >> $@
	$(ECHO) "sun/tools/jps/" >> $@
	$(ECHO) "sun/tools/jstat/" >> $@
	$(ECHO) "sun/tools/jstatd/" >> $@
	$(ECHO) "sun/tools/native2ascii/" >> $@
	$(ECHO) "sun/tools/serialver/" >> $@
	$(ECHO) "sun/tools/tree/" >> $@
	$(ECHO) "sun/tools/util/" >> $@
	$(ECHO) "sun/security/tools/JarBASE64Encoder.class" >> $@
	$(ECHO) "sun/security/tools/JarSigner.class" >> $@
	$(ECHO) "sun/security/tools/JarSignerParameters.class" >> $@
	$(ECHO) "sun/security/tools/JarSignerResources.class" >> $@
	$(ECHO) "sun/security/tools/JarSignerResources_ja.class" >> $@
	$(ECHO) "sun/security/tools/JarSignerResources_zh_CN.class" >> $@
	$(ECHO) "sun/security/tools/SignatureFile\$$Block.class" >> $@
	$(ECHO) "sun/security/tools/SignatureFile.class" >> $@
	$(ECHO) "sun/security/tools/TimestampedSigner.class" >> $@
	$(ECHO) "sun/security/provider/Sun.class" >> $@
	$(ECHO) "sun/security/rsa/SunRsaSign.class" >> $@
	$(ECHO) "sun/security/ssl/" >> $@
	$(ECHO) "com/sun/net/ssl/internal/ssl/" >> $@
	$(ECHO) "javax/crypto/" >> $@
	$(ECHO) "sun/security/internal/" >> $@
	$(ECHO) "com/sun/crypto/provider/" >> $@
	$(ECHO) "META-INF/services/com.sun.tools.attach.spi.AttachProvider" >> $@
	$(ECHO) "com/sun/tools/attach/" >> $@
	$(ECHO) "org/relaxng/datatype/" >> $@
	$(ECHO) "com/sun/codemodel/" >> $@
	$(ECHO) "com/sun/xml/internal/dtdparser/" >> $@
	$(ECHO) "com/sun/xml/internal/rngom/" >> $@
	$(ECHO) "com/sun/xml/internal/xsom/" >> $@
	$(ECHO) "com/sun/tools/script/shell/" >> $@
	$(ECHO) "sun/tools/attach/" >> $@
	$(ECHO) "sun/tools/jstack/" >> $@
	$(ECHO) "sun/tools/jinfo/" >> $@
	$(ECHO) "sun/tools/jmap/" >> $@


# File order list for rt.jar
#     - sun.applet is included, till hotjava stops relying on it.
#     - sun.tools.jar is included, needs cleanup.
#
REORDER_TEMPDIR=$(ABS_TEMPDIR)/reorder
TOTAL_JAR_FILELIST=$(REORDER_TEMPDIR)/file_list

JARFILELISTS_TEMPDIR=$(ABS_TEMPDIR)/jarfilelists
RT_JAR_FILELIST=$(JARFILELISTS_TEMPDIR)/rt_jar_list
RES_JAR_FILELIST=$(JARFILELISTS_TEMPDIR)/resources_jar_list

JARREORDER_JARFILE = $(ABS_BUILDTOOLJARDIR)/jarreorder.jar

$(TOTAL_JAR_FILELIST): $(JARREORDER_JARFILE) $(NOT_RT_JAR_LIST)
	$(prep-target)
	$(RM) $@.temp
	($(CD) $(CLASSBINDIR) && \
	    $(BOOT_JAVA_CMD) -jar $(JARREORDER_JARFILE) \
		-o  $@.temp $(ABS_LIBDIR)/classlist $(NOT_RT_JAR_LIST) . )
	$(MV) $@.temp $@
	@($(CD) $(CLASSBINDIR) && $(java-vm-cleanup))

# Create the rt.jar file list & non-class files list

JARSPLIT_JARFILE = $(BUILDTOOLJARDIR)/jarsplit.jar

$(RT_JAR_FILELIST) + $(RES_JAR_FILELIST): \
    $(TOTAL_JAR_FILELIST) $(JARSPLIT_JARFILE)
	@$(RM) $(RT_JAR_FILELIST) $(RES_JAR_FILELIST)
	$(MKDIR) -p $(JARFILELISTS_TEMPDIR)
	$(BOOT_JAVA_CMD) -jar $(JARSPLIT_JARFILE) \
		$(TOTAL_JAR_FILELIST) \
		-o  $(RT_JAR_FILELIST) $(RES_JAR_FILELIST)
	@$(java-vm-cleanup)

# Create the manifest file.
JAR_MANIFEST_FILE=$(ABS_TEMPDIR)/manifest.tmp
$(JAR_MANIFEST_FILE): $(MAINMANIFEST) $(BEANMANIFEST)
	$(prep-target)
	$(SED) -e "s#@@RELEASE@@#$(RELEASE)#" 		\
	       -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \
	       $(MAINMANIFEST) >> $@
	$(ECHO) >> $@
	$(CAT) $(BEANMANIFEST) >> $@

# Create resources.jar containing non-class files
RESOURCES_JAR=$(ABS_TEMPDIR)/resources-orig.jar
$(RESOURCES_JAR): $(RES_JAR_FILELIST) $(JAR_MANIFEST_FILE)
	$(prep-target)
	$(CD) $(CLASSBINDIR) && \
	    $(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
	        @$(RES_JAR_FILELIST) $(BOOT_JAR_JFLAGS)
	@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)

# Create jsse.jar containing SunJSSE implementation classes
JSSE_JAR=$(ABS_TEMPDIR)/jsse-orig.jar
$(JSSE_JAR): $(JAR_MANIFEST_FILE)
	$(prep-target)
	$(CD) $(CLASSBINDIR) && \
	    $(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
		$(JSSE_CLASSES_DIRS) $(BOOT_JAR_JFLAGS)
	@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)

# Create sec-bin.zip
SEC_FILES_ZIP=$(ABS_TEMPDIR)/sec-bin.zip
sec-files::
	$(prep-target)
	$(RM) $(SEC_FILES_ZIP)
	$(CD) $(OUTPUTDIR) && \
		$(ZIPEXE) -rq9 $(SEC_FILES_ZIP) $(SEC_FILES_DIRS)
	@$(java-vm-cleanup)

# Create sec-windows-bin.zip
SEC_FILES_WIN_ZIP=$(ABS_TEMPDIR)/sec-windows-bin.zip
sec-files-win::
ifeq ($(PLATFORM), windows)
	$(prep-target)
	$(RM) $(SEC_FILES_WIN_ZIP)
	$(CD) $(OUTPUTDIR) && \
		$(ZIPEXE) -rq9 $(SEC_FILES_WIN_ZIP) $(SEC_FILES_WIN_DIRS)
	@$(java-vm-cleanup)
endif

# Create JGSS files that contains the native Kerberos library
JGSS_WIN32_FILES_ZIP=$(ABS_TEMPDIR)/jgss-windows-i586-bin.zip
JGSS_WIN64_FILES_ZIP=$(ABS_TEMPDIR)/jgss-windows-x64-bin.zip
jgss-files::
ifeq ($(PLATFORM), windows)
	$(prep-target)
  ifeq ($(ARCH_DATA_MODEL), 32)
	$(RM) $(JGSS_WIN32_FILES_ZIP)
	$(CD) $(OUTPUTDIR) && \
		$(ZIPEXE) -rq9 $(JGSS_WIN32_FILES_ZIP) $(JGSS_FILES_DIRS)
  else
	$(RM) $(JGSS_WIN64_FILES_ZIP)
	$(CD) $(OUTPUTDIR) && \
		$(ZIPEXE) -rq9 $(JGSS_WIN64_FILES_ZIP) $(JGSS_FILES_DIRS)
  endif
	@$(java-vm-cleanup)
endif

# Create rt.jar
RT_JAR=$(ABS_TEMPDIR)/rt-orig.jar
$(RT_JAR): $(RT_JAR_FILELIST) $(JAR_MANIFEST_FILE)
	$(prep-target)
	$(CD) $(CLASSBINDIR) && \
	    $(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
	        @$(RT_JAR_FILELIST) $(BOOT_JAR_JFLAGS)
	@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)

# Meta-index construction to make core class loaders lazier

BUILDMETAINDEX_JARFILE = $(ABS_BUILDTOOLJARDIR)/buildmetaindex.jar

######################################################
# JRE Image
######################################################

initial-image-jre-setup:
	$(RM) -r $(JRE_IMAGE_DIR)
	$(MKDIR) -p $(JRE_IMAGE_DIR)

# 64-bit solaris jre image contains only the 64-bit add-on files.
initial-image-jre-sol64:: initial-image-jre-setup \
			  $(JRE_LICENSES) $(JRE64_LICENSES)
	@# Use tar instead of cp to preserve the symbolic links
	for dir in bin lib ; do \
	  ( $(CD) $(OUTPUTDIR) && \
		$(TAR) cf - `$(FIND) $$dir -name '$(ARCH)' -print` | \
		($(CD) $(JRE_IMAGE_DIR) && $(TAR) xf -) ) ; \
	done
	@# Remove some files from the jre area
	for t in $(NOTJRETOOLS) ; do \
	    $(RM) $(JRE_IMAGE_DIR)/bin$(ISA_DIR)/$$t ; \
	done
	for l in $(NOTJRELIBS) ; do \
	    $(RM) $(JRE_IMAGE_DIR)/lib/$$l ; \
	done
	$(RM) `$(FIND) $(JRE_IMAGE_DIR)/lib -name 'orb.idl'`
	$(RM) `$(FIND) $(JRE_IMAGE_DIR)/lib -name 'ir.idl'`

# Construct an initial jre image (initial jdk jre) no trimming or stripping
# See "initial-image-jdk-setup" for an explanation of the rm of
# drive names like C:
initial-image-jre:: initial-image-jre-setup \
		    $(JRE_LICENSES) $(JRE_DOCFILES) \
		    $(RT_JAR) $(RESOURCES_JAR) $(JSSE_JAR) \
		    $(BUILDMETAINDEX_JARFILE)
	@# Copy in bin directory
	$(CD) $(OUTPUTDIR) && $(FIND) bin -depth | $(CPIO) -pdum $(JRE_IMAGE_DIR)
	@# CTE plugin security change require new empty directory lib/applet
	$(MKDIR) -p $(JRE_IMAGE_DIR)/lib/applet
	@# Copy in lib directory
	$(CD) $(OUTPUTDIR) && $(FIND) lib -depth | $(CPIO) -pdum $(JRE_IMAGE_DIR)
  ifeq ($(USING_CYGWIN),true)
	  $(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]:
	  $(RM) -rf $(OUTPUTDIR)/[A-Za-z]:
  endif
	@# Make sure all directories are read/execute for everyone
	$(CHMOD) a+rx `$(FIND) $(JRE_IMAGE_DIR) -type d`
	@# Remove some files from the jre area
	for t in $(NOTJRETOOLS) ; do \
	    $(RM) $(JRE_IMAGE_DIR)/bin$(ISA_DIR)/$$t ; \
	done
	for l in $(NOTJRELIBS) ; do \
	    $(RM) $(JRE_IMAGE_DIR)/lib/$$l ; \
	done
	@# Remove orb.idl and ir.idl from jre
	$(FIND) $(JRE_IMAGE_DIR)/lib -name 'orb.idl' -exec $(RM) \{} \;
	$(FIND) $(JRE_IMAGE_DIR)/lib -name 'ir.idl' -exec $(RM) \{} \;
	@# Copy in rt.jar & resources.jar file
	$(CP) $(RT_JAR) $(JRE_IMAGE_DIR)/lib/rt.jar
	$(CP) $(RESOURCES_JAR) $(JRE_IMAGE_DIR)/lib/resources.jar
	$(CP) $(JSSE_JAR) $(JRE_IMAGE_DIR)/lib/jsse.jar
	@# Generate meta-index to make boot and extension class loaders lazier
	$(CD) $(JRE_IMAGE_DIR)/lib && \
	    $(BOOT_JAVA_CMD) -jar $(BUILDMETAINDEX_JARFILE) \
		-o meta-index *.jar
	@$(CD) $(JRE_IMAGE_DIR)/lib && $(java-vm-cleanup)
	$(CD) $(JRE_IMAGE_DIR)/lib/ext && \
	    $(BOOT_JAVA_CMD) -jar $(BUILDMETAINDEX_JARFILE) \
		-o meta-index *.jar
	@$(CD) $(JRE_IMAGE_DIR)/lib/ext && $(java-vm-cleanup)
ifeq ($(PLATFORM), windows)
	@# Remove certain *.lib files
	$(CD) $(JRE_IMAGE_DIR)/lib && \
            $(RM) java.$(LIB_SUFFIX) jvm.$(LIB_SUFFIX) \
                  hpi.$(LIB_SUFFIX) awt.$(LIB_SUFFIX) jawt.$(LIB_SUFFIX)
  ifeq ($(ARCH_DATA_MODEL), 32)
	@# The Java Kernel JRE image ships with a special VM.  It is not included
	@# in the full JRE image, so remove it.  Also, is it only for 32-bit windows.
	$(CD) $(JRE_IMAGE_DIR)/bin && $(RM) -r kernel
  endif
endif # Windows
ifneq ($(PLATFORM), windows)
	$(call copy-man-pages,$(JRE_IMAGE_DIR),$(JRE_MAN_PAGES))
endif # !windows

# Trim out any extra files not for the jre shipment but wanted in the jdk jre.
#   (Note the jdk WILL want the jre image before this trimming)
#   Removes server VM on Windows 32bit.
#   Remove certain shared libraries that should not be in the jre image
#      but should be in the jdk jre image.
trim-image-jre::
ifeq ($(PLATFORM), windows)
  ifeq ($(ARCH_DATA_MODEL), 32)
	$(RM) -r $(JRE_IMAGE_DIR)/bin/server
  endif
  ifdef NOTJRE_SHARED_LIBS
	for l in $(NOTJRE_SHARED_LIBS) ; do \
	    $(RM) $(JRE_IMAGE_DIR)/bin/$$l ; \
	done ;
  endif
else # PLATFORM
  ifdef NOTJRE_SHARED_LIBS
	for l in $(NOTJRE_SHARED_LIBS) ; do \
	    $(RM) $(JRE_IMAGE_DIR)/lib/$(LIBARCH)/$$l ; \
	done ;
  endif
endif # PLATFORM

# Get list of all Elf files in the jre
JRE_ELF_LIST=$(TEMPDIR)/jre-elf-files.list
$(JRE_ELF_LIST):
ifneq ($(PLATFORM), windows)
	$(RM) $@
	$(FIND) $(JRE_IMAGE_DIR)/lib -type f -name \*.$(LIB_SUFFIX) >> $@
	$(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
endif

# Post process the image (strips and mcs on Elf files we are shipping)
#   (Note the jdk WILL want the jre image before this processing)
process-image-jre:: $(JRE_ELF_LIST)
ifneq ($(POST_STRIP_PROCESS), )
	for f in `$(CAT) $(JRE_ELF_LIST)`; do \
	  $(CHMOD) u+w $${f}; \
	  $(ECHO) $(POST_STRIP_PROCESS) $${f}; \
	  $(POST_STRIP_PROCESS) $${f}; \
	  $(CHMOD) go-w $${f}; \
	done
endif
ifneq ($(POST_MCS_PROCESS), )
	for f in `$(CAT) $(JRE_ELF_LIST)`; do \
	  $(CHMOD) u+w $${f}; \
	  $(ECHO) $(POST_MCS_PROCESS) $${f}; \
	  $(POST_MCS_PROCESS) $${f}; \
	  $(CHMOD) go-w $${f}; \
	done
endif
	$(RM) $(JRE_ELF_LIST)

######################################################
# JDK Image
######################################################
# Note: cpio ($(CPIO)) sometimes leaves directories without rx access.

# REMIND: the $(RM) calls for patterns like c:, d: following $(CPIO)
# are because the 1.7.x versions of cygwin's cpio command drops these
# in the working directory if the output path begins with that pattern
# The one for the output jre subdirectory gets there because cpio sees its
# own dropping in the input jre subdirectory. Need to remove both of these.
# We can remove these RM's if someone figures out how to stop cpio from
# leaving these there.
# Note that its a real problem not because this directory can end up in the
# bundle (I think it won't since it not in bin or lib and those are the
# only places from which we copy everything), but because the presence
# of this file causes cygwin's find to bomb out, thus breaking the build
# in "install".
initial-image-jdk-setup:
	$(RM) -r $(JDK_IMAGE_DIR)
	$(MKDIR) -p $(JDK_IMAGE_DIR)/jre
	($(CD) $(JRE_IMAGE_DIR) && $(FIND) . -depth -print \
	      | $(CPIO) -pdum $(JDK_IMAGE_DIR)/jre )
  ifeq ($(USING_CYGWIN),true)
	  $(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]:
	  $(RM) -rf $(JDK_IMAGE_DIR)/jre/[A-Za-z]:
  endif
	$(RM) -rf $(JDK_IMAGE_DIR)/jre/man
	$(CHMOD) a+rx `$(FIND) $(JDK_IMAGE_DIR) -type d`

initial-image-jdk64-bindemos:
	for dir in bin demo ; do \
	  ( $(CD) $(OUTPUTDIR) && \
		$(TAR) cf - `$(FIND) $$dir -name '$(LIBARCH)' -print` | \
		($(CD) $(JDK_IMAGE_DIR) && $(TAR) xf -) ) ; \
        done

# Solaris 64 bit image is special
initial-image-jdk-sol64:: initial-image-jdk-setup \
			  initial-image-jdk64-bindemos \
			  $(JDK_LICENSES) $(JDK64_LICENSES)

# DB files to add
ifdef OPENJDK

initial-image-jdk-db:

else

# Create the list of db *.zip files to bundle with jdk
ABS_DB_PATH  :=$(call FullPath,$(CLOSED_SHARE_SRC)/db)
DB_ZIP_LIST = $(shell $(LS) $(ABS_DB_PATH)/*.zip 2>/dev/null)

initial-image-jdk-db: $(DB_ZIP_LIST)
	$(MKDIR) -p $(JDK_IMAGE_DIR)/db
	for d in $(DB_ZIP_LIST); do \
          ($(CD) $(JDK_IMAGE_DIR)/db && $(UNZIP) -o $$d); \
	done

endif

# Standard jdk image
initial-image-jdk:: initial-image-jdk-setup \
		    initial-image-jdk-db \
		    $(JDK_LICENSES) $(JDK_DOCFILES)
	$(MKDIR) $(JDK_IMAGE_DIR)/lib
	@#
	@# Copy in the jars in lib that only belong in the JDK
	@#
	for l in $(NOTJRELIBS); do \
	    if [ -r $(LIBDIR)/$$l ]; then \
	        $(CP) $(LIBDIR)/$$l $(JDK_IMAGE_DIR)/lib; \
	    fi; \
	done
  ifeq ($(PLATFORM), windows)
	@#
	@# lib/
	@#
	$(CP) $(LIBDIR)/$(LIB_PREFIX)jvm.$(LIB_SUFFIX) $(JDK_IMAGE_DIR)/lib
	$(CP) $(LIBDIR)/$(LIB_PREFIX)jawt.$(LIB_SUFFIX) $(JDK_IMAGE_DIR)/lib
	@#
	@# bin/
	@#
	@# copy all EXE files and only certain DLL files from BINDIR
	$(MKDIR) -p $(JDK_IMAGE_DIR)/bin
	$(CP) $(BINDIR)/*$(EXE_SUFFIX) $(JDK_IMAGE_DIR)/bin
	$(CP) $(BINDIR)/jli.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin
    ifeq ($(COMPILER_VERSION), VS2010)
	$(CP) $(BINDIR)/msvc*100.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin
    endif
    ifeq ($(ARCH_DATA_MODEL), 32)
      ifeq ($(COMPILER_VERSION), VS2003)
	$(CP) $(BINDIR)/msvc*71.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin
      endif
    endif
  else # PLATFORM
	@#
	@# bin/
	@#
	($(CD) $(BINDIR)/.. && $(TAR) cf - \
	    `$(FIND) bin \( -type f -o -type l \) -print `) | \
	    ($(CD) $(JDK_IMAGE_DIR) && $(TAR) xf -)
  endif # PLATFORM
	@#
	@# files that might not exist need to be touched.
	@#
	$(TOUCH) $(CLASSBINDIR)/META-INF/services/com.sun.tools.xjc.Plugin
	@#
	@# lib/tools.jar
	@#
	$(CD) $(CLASSBINDIR) && \
	    $(BOOT_JAR_CMD) c0f $(ABS_LIBDIR)/tools.jar \
	        $(TOOLS) $(BOOT_JAR_JFLAGS)
	@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
	$(CP) $(LIBDIR)/tools.jar $(JDK_IMAGE_DIR)/lib/tools.jar
	@#
	@# lib/ct.sym
	@#
	$(MKDIR) -p $(OUTPUTDIR)/symbols/META-INF/sym
	$(JAVAC_CMD) -XDprocess.packages -proc:only \
	    -processor com.sun.tools.javac.sym.CreateSymbols \
	    -Acom.sun.tools.javac.sym.Jar=$(RT_JAR) \
	    -Acom.sun.tools.javac.sym.Dest=$(OUTPUTDIR)/symbols/META-INF/sym/rt.jar \
	    $(CORE_PKGS) $(NON_CORE_PKGS) $(EXCLUDE_PROPWARN_PKGS)
	$(BOOT_JAR_CMD) c0f $(LIBDIR)/ct.sym \
	    -C $(OUTPUTDIR)/symbols META-INF $(BOOT_JAR_JFLAGS)
	@$(java-vm-cleanup)
	$(CP) $(LIBDIR)/ct.sym $(JDK_IMAGE_DIR)/lib/ct.sym
	@#
	@# CORBA supported orb.idl and ir.idl should be copied to lib
	@#
	$(CP) $(LIBDIR)/orb.idl $(JDK_IMAGE_DIR)/lib/orb.idl
	$(CP) $(LIBDIR)/ir.idl $(JDK_IMAGE_DIR)/lib/ir.idl
  ifeq ($(PLATFORM), linux)
	@#
	@# on Linux copy jexec from jre/lib to /lib
	@#
	$(CP) $(LIBDIR)/jexec $(JDK_IMAGE_DIR)/lib/jexec
  endif # PLATFORM
	@#
	@# src.zip
	@#
	$(MKDIR) -p $(JDK_IMAGE_DIR)/src
	@#
	@# The '*-*' pattern in the find command excludes files named with dashes,
	@# such as the java.nio templates for generated classes
	@#
	@# The Linux 'tar' command cannot handle the huge command line argument
	@# generated by the more efficient solaris/windows method of copying files.
	@# So for Linux, make use of the -T option (like Solaris' -I option) of
	@# obtaining the list of files from a file. MKS tar has no such option.
  ifeq ($(PLATFORM), linux)
	for d in $(SOURCE_DIRS); do \
	  $(RM) $(ABS_TEMPDIR)/src-files.list; \
	  ($(CD) $$d &&  \
	    for sd in $(SOURCES) ; do \
              if [ -d $$sd ] ; then \
	        $(FIND) $$sd $(SOURCE_FILES_filter) \
		        -name '*.java' -print \
		        >> $(ABS_TEMPDIR)/src-files.list ; \
	      fi; \
	    done ; \
	  ) ; \
	  if [ -f  $(ABS_TEMPDIR)/src-files.list ] ; then \
	    ($(CD) $$d && $(TAR) cf - -T $(ABS_TEMPDIR)/src-files.list ) \
	       | ($(CD) $(JDK_IMAGE_DIR)/src && $(TAR) xf -); \
	  fi; \
	done
  else
	for d in $(SOURCE_DIRS); do \
	  $(RM) $(ABS_TEMPDIR)/src-files.list; \
	  ($(CD) $$d && \
	    for sd in $(SOURCES) ; do \
              if [ -d $$sd ] ; then \
	        $(FIND) $$sd $(SOURCE_FILES_filter) \
		        -name '*.java' -print \
		        >> $(ABS_TEMPDIR)/src-files.list ; \
	      fi; \
	    done ; \
	  ) ; \
	  if [ -f  $(ABS_TEMPDIR)/src-files.list ] ; then \
	    ($(CD) $$d && $(TAR) cf - `$(CAT) $(ABS_TEMPDIR)/src-files.list`) \
	      | ($(CD) $(JDK_IMAGE_DIR)/src && $(TAR) xf -); \
	  fi; \
	done
  endif
	$(RM) $(ABS_TEMPDIR)/src-files.list
	$(CHMOD) -R +w $(JDK_IMAGE_DIR)/src
	$(MKDIR) -p $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/java.c $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/java.h $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/manifest_info.h $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/parse_manifest.c $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/version_comp.c $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/version_comp.h $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/wildcard.h $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/wildcard.c $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/jli_util.h $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/jli_util.c $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/splashscreen_stubs.c $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(SHARE_SRC)/bin/splashscreen.h $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(PLATFORM_SRC)/bin/java_md.c $(JDK_IMAGE_DIR)/src/launcher
	$(CP) $(PLATFORM_SRC)/bin/java_md.h $(JDK_IMAGE_DIR)/src/launcher
	$(CD) $(JDK_IMAGE_DIR)/src && $(ZIPEXE) -qr ../src.zip *
	$(RM) -r $(JDK_IMAGE_DIR)/src
	@#
	@# demo, include
	@#
	$(CP) -r -f $(DEMODIR) $(JDK_IMAGE_DIR)
	$(CP) -r -f $(SAMPLEDIR) $(JDK_IMAGE_DIR)
	$(CP) -r $(INCLUDEDIR) $(JDK_IMAGE_DIR)
	@#
	@# Swing BeanInfo generation
	@#
	$(CD) javax/swing/beaninfo && $(MAKE) swing-1.2-beans
ifneq ($(PLATFORM), windows)
	$(call copy-man-pages,$(JDK_IMAGE_DIR),$(JDK_MAN_PAGES))
endif # !windows

# Trim out files we don't want to ship
trim-image-jdk::
	@# Remove tools that should not be part of SDK.
	for t in $(NOTJDKTOOLS); do \
	    $(RM) $(JDK_IMAGE_DIR)/bin/$${t}$(EXE_SUFFIX) \
		  $(JDK_IMAGE_DIR)/bin/*/native_threads/$${t}$(EXE_SUFFIX); \
	done

# Get list of Elf files in the jdk
JDK_ELF_LIST=$(TEMPDIR)/jdk-elf-files.list
$(JDK_ELF_LIST):
ifneq ($(PLATFORM), windows)
	$(RM) $@
	$(FIND) $(JDK_IMAGE_DIR)/jre/lib -type f -name \*.$(LIB_SUFFIX) >> $@
	$(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f -name \*$(EXE_SUFFIX)` \
	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
	file `$(FIND) $(JDK_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
endif

# Post process the image (strips and mcs on files we are shipping)
process-image-jdk:: $(JDK_ELF_LIST)
ifneq ($(POST_STRIP_PROCESS), )
	for f in `$(CAT) $(JDK_ELF_LIST)`; do \
	  $(CHMOD) u+w $${f}; \
	  $(ECHO) $(POST_STRIP_PROCESS) $${f}; \
	  $(POST_STRIP_PROCESS) $${f}; \
	  $(CHMOD) go-w $${f}; \
	done
endif
ifneq ($(POST_MCS_PROCESS), )
	for f in `$(CAT) $(JDK_ELF_LIST)`; do \
	  $(CHMOD) u+w $${f}; \
	  $(ECHO) $(POST_MCS_PROCESS) $${f}; \
	  $(POST_MCS_PROCESS) $${f}; \
	  $(CHMOD) go-w $${f}; \
	done
endif
	$(RM) $(JDK_ELF_LIST)

###################################################################
# What do we compare against
###################################################################

# The temporary files and areas created
TEMP_PREV_JRE_BASE_DIR=$(TEMPDIR)/previous_jre
TEMP_PREV_JDK_BASE_DIR=$(TEMPDIR)/previous_jdk
TEMP_PREV_JRE_COMPARISON=$(TEMP_PREV_JRE_BASE_DIR)/previous_jre_comparison.txt
TEMP_PREV_JDK_COMPARISON=$(TEMP_PREV_JDK_BASE_DIR)/previous_jdk_comparison.txt
TEMP_PREV_JRE_IMAGE_DIR=$(TEMP_PREV_JRE_BASE_DIR)/jre$(PREVIOUS_JDK_VERSION)
TEMP_PREV_JDK_IMAGE_DIR=$(TEMP_PREV_JDK_BASE_DIR)/jdk$(PREVIOUS_JDK_VERSION)

# unbundle(sourcedir,bundlename,destdir)
#    logic is slightly different if a .tar.gz file (linux)
define unbundle
$(RM) -r $3
$(MKDIR) -p $3
$(CP) $1 $3
if [ "`$(BASENAME) $2 .gz`" != "$2" ] ; then \
  ( $(CD) $3 && ( $(GUNZIP) -dc $2 | $(TAR) xf - ) && $(RM) $2 ); \
else \
  ( $(CD) $3 && $(TAR) xf $2 && $(RM) $2 ); \
fi
( $(CD) $3 && $(RM) $2 )
endef

# In general, ignore the fastdebug tree, and changes in the demo and sample area
COMPARE_FILTER = | $(EGREP) -v /fastdebug/ | $(EGREP) -v /demo/ | $(EGREP) -v /sample/

# If a previuous image is provided, no need to install it.
ifdef PREVIOUS_RELEASE_IMAGE

  # Just use the pre-installed images
  PREV_JRE_IMAGE_DIR=$(PREVIOUS_RELEASE_IMAGE)/jre
  PREV_JDK_IMAGE_DIR=$(PREVIOUS_RELEASE_IMAGE)

else

  # Use the temp images we will create
  PREV_JRE_IMAGE_DIR=$(TEMP_PREV_JRE_IMAGE_DIR)
  PREV_JDK_IMAGE_DIR=$(TEMP_PREV_JDK_IMAGE_DIR)

# Force the installation in this case
compare-image:: install-previous-sanity install-previous-jre install-previous-jdk

# Unbundle the jre
$(TEMP_PREV_JRE_IMAGE_DIR)/bin/java$(EXE_SUFFIX): $(PREVIOUS_JRE_BUNDLE)
	$(call unbundle,$(PREVIOUS_JRE_BUNDLE),$(PREVIOUS_JRE_FILE),$(TEMP_PREV_JRE_BASE_DIR))
	$(TOUCH) $@

# Unbundle the jdk
$(TEMP_PREV_JDK_IMAGE_DIR)/bin/java$(EXE_SUFFIX): $(PREVIOUS_JDK_BUNDLE)
	$(call unbundle,$(PREVIOUS_JDK_BUNDLE),$(PREVIOUS_JDK_FILE),$(TEMP_PREV_JDK_BASE_DIR))
	$(TOUCH) $@

endif

# Make sure all images have a java in them (used as the touch file)
install-previous-sanity:
	@if [ ! -f $(PREVIOUS_JRE_BUNDLE) ]; then \
          $(ECHO) "ERROR: You do not have access to the previous java release jre bundles. \n" \
            "      Please check your access to \n" \
            "          $(PREVIOUS_JRE_BUNDLE) \n" \
            "      and/or check your value of ALT_PREVIOUS_RELEASE_PATH or ALT_PREVIOUS_JRE_FILE \n" \
            "      This will affect you if you build the images target. \n" \
            "" >> $(ERROR_FILE) ; \
	fi
	@if [ ! -f $(PREVIOUS_JDK_BUNDLE) ]; then \
          $(ECHO) "ERROR: You do not have access to the previous java release sdk bundles. \n" \
          "      Please check your access to \n" \
          "          $(PREVIOUS_sdk_BUNDLE) \n" \
          "      and/or check your value of ALT_PREVIOUS_RELEASE_PATH or ALT_PREVIOUS_JDK_FILE. \n" \
          "      This will affect you if you build the images target. \n" \
          "" >> $(ERROR_FILE) ; \
	fi
install-previous-jre: $(PREV_JRE_IMAGE_DIR)/bin/java$(EXE_SUFFIX)
install-previous-jdk: $(PREV_JDK_IMAGE_DIR)/bin/java$(EXE_SUFFIX)

# Create the jre comparison report
$(TEMP_PREV_JRE_COMPARISON): install-previous-jre $(DIRDIFF_JARFILE)
	$(prep-target)
	$(BOOT_JAVA_CMD) -jar $(DIRDIFF_JARFILE) \
	   $(PREV_JRE_IMAGE_DIR) $(JRE_IMAGE_DIR) | $(SORT) > $@
	@$(java-vm-cleanup)

# Create the jdk comparison report
$(TEMP_PREV_JDK_COMPARISON): install-previous-jdk $(DIRDIFF_JARFILE)
	$(prep-target)
	$(BOOT_JAVA_CMD) -jar $(DIRDIFF_JARFILE) \
	   $(PREV_JDK_IMAGE_DIR) $(JDK_IMAGE_DIR) | $(SORT) > $@
	@$(java-vm-cleanup)

# Clean up names in the messages printed out
CAT_FILTER = $(SED) -e "s@$(JDK_IMAGE_DIR)@JDK_IMAGE@g" \
	            -e "s@$(JRE_IMAGE_DIR)@JRE_IMAGE@g"

# Report on the jre image comparison
compare-image-jre: $(TEMP_PREV_JRE_COMPARISON)
	@$(ECHO) "JRE Image Comparison to version $(PREVIOUS_JDK_VERSION)"
	@$(ECHO) "  Previous: $(PREV_JRE_IMAGE_DIR)"
	@$(ECHO) "  Current:  $(JRE_IMAGE_DIR)"
	@$(CAT) $< $(COMPARE_FILTER) | $(CAT_FILTER)
	( $(ECHO) " " ; $(CAT) $< | $(CAT_FILTER) ; $(ECHO) " " ) >> $(WARNING_FILE)

# Report on the jdk image comparison
compare-image-jdk: $(TEMP_PREV_JDK_COMPARISON)
	@$(ECHO) "JDK Image Comparison to version $(PREVIOUS_JDK_VERSION)"
	@$(ECHO) "  Previous: $(PREV_JDK_IMAGE_DIR)"
	@$(ECHO) "  Current:  $(JDK_IMAGE_DIR)"
	$(CAT) $< $(COMPARE_FILTER) | $(CAT_FILTER)
	( $(ECHO) " " ; $(CAT) $< | $(CAT_FILTER) ; $(ECHO) " " ) >> $(WARNING_FILE)

# Do both image comparisons
compare-image:: compare-image-jre compare-image-jdk

# Clean up any temp images and reports
compare-image-clobber:
	$(RM) -r $(TEMP_PREV_JRE_BASE_DIR)
	$(RM) -r $(TEMP_PREV_JDK_BASE_DIR)

######################################################
# clobber
######################################################
images-clobber::
	$(RM) -r $(REORDER_TEMPDIR)
	$(RM) -r $(JARFILELISTS_TEMPDIR)
ifeq ($(ARCH_DATA_MODEL), 32)
	$(CD) javax/swing/beaninfo && $(MAKE) swingbeans.clobber
	$(RM) -r $(CLASSBINDIR)/META-INF
	$(RM) $(TEMPDIR)/tmp.jar
endif
ifeq ($(PLATFORM), linux)
	$(RM) -r $(OUTPUTDIR)/$(ARCH)
endif
ifeq ($(PLATFORM), windows)
	$(RM) $(TEMPDIR)/rebase.input
endif
	$(RM) -r $(JDK_IMAGE_DIR)
	$(RM) -r $(JRE_IMAGE_DIR)

images images-clobber::
	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
	@$(java-vm-cleanup)

.PHONY: images image-jre image-jdk \
	initial-image-jre initial-image-jdk \
	initial-image-jre-sol64 initial-image-jdk-sol64 \
        initial-image-jdk-setup \
	initial-image-jdk-db \
        initial-image-jdk64-bindemos \
        initial-image-jre-setup \
	trim-image-jre trim-image-jdk \
	process-image-jre process-image-jdk \
	install-previous-jre install-previous-jdk \
	compare-image-jre compare-image-jdk \
	compare-image compare-image-clobber \
	images-clobber

# Force rule
FRC: