#
# Copyright (c) 1997, 2008, 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.
#
# JDK jars where component classes come from as second choice
JDK_RT_JAR = $(JDK_IMPORT_PATH)/jre/lib/rt.jar
JDK_TOOLS_JAR = $(JDK_IMPORT_PATH)/lib/tools.jar
JDK_RESOURCES_JAR = $(JDK_IMPORT_PATH)/jre/lib/resources.jar
# The specific packages that come from or go to rt.jar and tools.jar
# IF the component deliverables are not available.
IMPORT_TOOLS_PACKAGES =
IMPORT_RT_PACKAGES =
# The following will add to IMPORT_TOOLS_PACKAGES and/or IMPORT_RT_PACKAGES
ifndef LANGTOOLS_DIST
include $(BUILDDIR)/common/internal/Defs-langtools.gmk
endif
ifndef CORBA_DIST
include $(BUILDDIR)/common/internal/Defs-corba.gmk
endif
ifndef JAXP_DIST
include $(BUILDDIR)/common/internal/Defs-jaxp.gmk
endif
ifndef JAXWS_DIST
include $(BUILDDIR)/common/internal/Defs-jaxws.gmk
endif
# Clean up these lists so empty lists are empty
IMPORT_TOOLS_PACKAGES := $(strip $(IMPORT_TOOLS_PACKAGES))
IMPORT_RT_PACKAGES := $(strip $(IMPORT_RT_PACKAGES))
# Relative paths to import component deliverables
CLASSES_JAR_FILE=lib/classes.jar
SRC_ZIP_FILE=lib/src.zip
BIN_ZIP_FILE=lib/bin.zip
DOC_ZIP_FILE=lib/doc.zip
#################################################################
# Macros:
# Importing component class files
define import-one-classes
@if [ "$($1)" != "" ] ; then \
$(ECHO) "Importing classes from component $1"; \
$(call Unjar,$2,$($1)/$(CLASSES_JAR_FILE),); \
fi
endef
# Importing optional component doc files (for man pages?)
define import-one-docs
@if [ "$($1)" != "" -a -f $($1)/$(DOC_ZIP_FILE) ] ; then \
$(ECHO) "Importing docs from component $1"; \
$(call Unzipper,$2,$($1)/$(DOC_ZIP_FILE)); \
fi
endef
# Importing optional component src files (for jdk src.zip and javadoc)
define import-one-sources
@if [ "$($1)" != "" ] ; then \
$(ECHO) "Importing sources from component $1"; \
$(call Unzipper,$2,$($1)/$(SRC_ZIP_FILE)); \
fi
endef
# Importing optional component bin files (for install image)
define import-one-binaries
@if [ "$($1)" != "" -a -f $($1)/$(BIN_ZIP_FILE) ] ; then \
$(ECHO) "Importing binaries from component $1"; \
$(call Unzipper,$2,$($1)/$(BIN_ZIP_FILE)); \
fi
endef
# Unzip zip file $2 into directory $1 (if $2 exists)
# Warning: $2 must be absolute path not relative
define Unzipper
( \
$(MKDIR) -p $1; \
$(ECHO) "( $(CD) $1 && $(UNZIP) -o $2 )"; \
( $(CD) $1 && $(UNZIP) -o $2 ) \
)
endef
# Unjar directories $3 from jar file $2 into directory $1 (if $2 exists)
# Warning: $2 must be absolute path not relative
define Unjar
( \
$(MKDIR) -p $1; \
$(ECHO) "( $(CD) $1 && $(BOOT_JAR_CMD) xfv $2 $3 $(BOOT_JAR_JFLAGS) )" ; \
( $(CD) $1 && $(BOOT_JAR_CMD) xfv $2 $3 $(BOOT_JAR_JFLAGS) ) && \
( $(CD) $1 && $(java-vm-cleanup) ) \
)
endef
# Import all component sources into directory $1
define import-component-sources
$(call import-one-sources,LANGTOOLS_DIST,$1)
$(call import-one-sources,CORBA_DIST,$1)
$(call import-one-sources,JAXP_DIST,$1)
$(call import-one-sources,JAXWS_DIST,$1)
endef
# Import all component docs into directory $1 (optional)
define import-component-docs
$(call import-one-docs,LANGTOOLS_DIST,$1)
$(call import-one-docs,CORBA_DIST,$1)
$(call import-one-docs,JAXP_DIST,$1)
$(call import-one-docs,JAXWS_DIST,$1)
endef
# Import all component bins into directory $1 (optional)
define import-component-binaries
$(call import-one-binaries,LANGTOOLS_DIST,$1)
$(call import-one-binaries,CORBA_DIST,$1)
$(call import-one-binaries,JAXP_DIST,$1)
$(call import-one-binaries,JAXWS_DIST,$1)
if [ "$(CORBA_DIST)" = "" ] ; then \
$(MKDIR) -p $(OUTPUTDIR)/lib ; \
( $(CD) $(JDK_IMPORT_PATH) && $(CP) $(IMPORT_CORBA_BINARIES) $(ABS_OUTPUTDIR)/lib ) ; \
fi
endef
# Import all component classes into directory $1
# Here we special case classes coming from JDK when component not supplied
define import-component-classes
$(ECHO) "Import classes from $(JDK_IMPORT_PATH)"
if [ "$(IMPORT_TOOLS_PACKAGES)" != "" ] ; then \
$(call Unjar,$1,$(JDK_RESOURCES_JAR),$(IMPORT_TOOLS_PACKAGES)); \
$(call Unjar,$1,$(JDK_TOOLS_JAR),$(IMPORT_TOOLS_PACKAGES)); \
fi
if [ "$(IMPORT_RT_PACKAGES)" != "" ] ; then \
$(call Unjar,$1,$(JDK_RESOURCES_JAR),$(IMPORT_RT_PACKAGES)); \
$(call Unjar,$1,$(JDK_RT_JAR),$(IMPORT_RT_PACKAGES)); \
fi
$(call import-one-classes,LANGTOOLS_DIST,$1)
$(call import-one-classes,CORBA_DIST,$1)
$(call import-one-classes,JAXP_DIST,$1)
$(call import-one-classes,JAXWS_DIST,$1)
endef
# Clean up import files
define import-component-sources-clean
$(RM) -r $1
endef
define import-component-docs-clean
$(RM) -r $1
endef
define import-component-classes-clean
$(RM) -r $(IMPORT_TOOLS_PACKAGES:%=$1/%)
$(RM) -r $(IMPORT_RT_PACKAGES:%=$1/%)
endef