Profiles.gmk 12.3 KB
Newer Older
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
#
# 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
43 44
# included in this profile. They have the jar name relative to the lib
# directory. We have to turn these into targets by adding the
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
# $(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)

PROFILE_3_JARS := \
    $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_3_JRE_JAR_FILES)) \
    $(PROFILE_2_JARS)

72 73 74 75
ifneq ($(ENABLE_JFR), true)
  FULL_JRE_JAR_FILES :=  $(filter-out jfr.jar, $(FULL_JRE_JAR_FILES))
endif

76 77
FULL_JRE_JARS := \
    $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(FULL_JRE_JAR_FILES)) \
78 79 80 81 82
    $(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.
83
# rt.jar and resources.jar that we filtered out above
84

85
ALL_JARS := $(FULL_JRE_JARS) \
86 87 88 89 90 91
        $(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 \
92 93 94 95 96
        $(IMAGES_OUTPUTDIR)/src.zip

ifeq ($(INCLUDE_SA),true)
    ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar
endif
97 98 99 100 101 102 103 104 105

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
106
endif
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

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) \
141
   $(FULL_JRE_BIN_FILES)
142 143 144 145 146 147 148 149

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) \
150
        $(FULL_JRE_BIN_FILES)
151 152 153 154 155
endif

ifeq ($(PROFILE), profile_2)
    NOT_JRE_BIN_FILES += \
        $(PROFILE_3_JRE_BIN_FILES) \
156
        $(FULL_JRE_BIN_FILES)
157 158 159 160
endif

ifeq ($(PROFILE), profile_3)
    NOT_JRE_BIN_FILES += \
161
        $(FULL_JRE_BIN_FILES)
162 163 164 165 166 167 168 169 170 171 172 173
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) \
174
   $(FULL_JRE_LIB_FILES)
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189

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) \
190
        $(FULL_JRE_LIB_FILES)
191 192 193 194 195
endif

ifeq ($(PROFILE), profile_2)
    NOT_JRE_LIB_FILES += \
        $(PROFILE_3_JRE_LIB_FILES) \
196
        $(FULL_JRE_LIB_FILES)
197 198 199 200
endif

ifeq ($(PROFILE), profile_3)
    NOT_JRE_LIB_FILES += \
201
        $(FULL_JRE_LIB_FILES)
202 203 204 205 206 207 208
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
209
# These are expressed as exclusions from everything found in the
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
# 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:
230 231
# - individual types in a package that is otherwise excluded at this
#   profile level. The only arises if there are split packages.
232 233 234 235 236 237 238 239 240 241 242 243 244 245
#
# - 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
246
# for all profiles above it, together with any explicitly excluded types.
247 248 249 250 251 252 253 254 255
# 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.
#
256
# Need a way to express:
257 258 259 260 261 262 263 264 265
#  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
266
# classes in rt.jar and everything else in resources.jar).Hence the
267 268 269 270 271 272 273 274 275 276 277 278 279
# 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 += \
280
    $(call class_list, $(PROFILE_1_RTJAR_EXCLUDE_TYPES)) \
281 282 283 284
    $(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)) \
285 286
    $(FULL_JRE_RTJAR_INCLUDE_PACKAGES) \
    $(call class_list, $(FULL_JRE_RTJAR_INCLUDE_TYPES))
287 288 289 290 291 292 293
  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 += \
294
    $(call class_list, $(PROFILE_2_RTJAR_EXCLUDE_TYPES)) \
295 296
    $(PROFILE_3_RTJAR_INCLUDE_PACKAGES) \
    $(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES)) \
297 298
    $(FULL_JRE_RTJAR_INCLUDE_PACKAGES) \
    $(call class_list, $(FULL_JRE_RTJAR_INCLUDE_TYPES))
299 300 301 302 303 304 305 306 307
  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 += \
308 309 310
    $(call class_list, $(PROFILE_3_RTJAR_EXCLUDE_TYPES)) \
    $(FULL_JRE_RTJAR_INCLUDE_PACKAGES) \
    $(call class_list, $(FULL_JRE_RTJAR_INCLUDE_TYPES))
311 312 313 314 315 316 317 318 319 320 321 322
  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
323
  EXCLUDED_SERVICES := META-INF/services/javax.script.ScriptEngineFactory
324 325 326 327 328 329
  PROFILE_INCLUDE_METAINF_SERVICES := $(filter-out $(EXCLUDED_SERVICES),$(PROFILE_INCLUDE_METAINF_SERVICES))
endif


endif # profile