aboutsummaryrefslogtreecommitdiff
path: root/make/common/internal/ImportComponents.gmk
blob: 743659407db5788d8b2093045784654eb558fecc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#
# Copyright 1997-2008 Sun Microsystems, Inc.  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.  Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.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