1 # 2 # Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. Oracle designates this 8 # particular file as subject to the "Classpath" exception as provided 9 # by Oracle in the LICENSE file that accompanied this code. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 default: all 27 28 include $(SPEC) 29 include MakeBase.gmk 30 31 PRODUCT_TARGETS := 32 LEGACY_TARGETS := 33 TEST_TARGETS := 34 DOCS_TARGETS := 35 36 # On Windows tar frequently complains that "file changed as we read it" for 37 # some random source files. This seems to be cause by anti virus scanners and 38 # is most likely safe to ignore. When it happens, tar returns '1'. 39 ifeq ($(call isBuildOs, windows), true) 40 TAR_IGNORE_EXIT_VALUE := || test "$$$$?" = "1" 41 endif 42 43 # Hook to include the corresponding custom file, if present. 44 $(eval $(call IncludeCustomExtension, Bundles-pre.gmk)) 45 ################################################################################ 46 # BUNDLE : Name of bundle to create 47 # FILES : Files in BASE_DIRS to add to bundle 48 # SPECIAL_INCLUDES : List of directories inside BASE_DIRS to look for additional 49 # files in. These files will not get proper dependency handling. Use when 50 # files or directories may contain spaces. 51 # BASE_DIRS : Base directories for the root dir in the bundle. 52 # SUBDIR : Optional name of root dir in bundle. 53 # OUTPUTDIR : Optionally override output dir 54 SetupBundleFile = $(NamedParamsMacroTemplate) 55 define SetupBundleFileBody 56 57 $$(foreach d, $$($1_BASE_DIRS), \ 58 $$(eval $1_$$d_RELATIVE_FILES := $$$$(patsubst $$d/%, %, \ 59 $$$$(filter $$d/%, $$$$($1_FILES)))) \ 60 $$(eval $1_$$d_LIST_FILE := \ 61 $(SUPPORT_OUTPUTDIR)/bundles/_$1_$$$$(subst /,_,$$$$(patsubst $(OUTPUTDIR)/%,%,$$d)_files)) \ 62 ) 63 64 ifneq ($$(filter %.tar.gz, $$($1_BUNDLE_NAME)), ) 65 $1_TYPE := tar.gz 66 else ifneq ($$(filter %.zip, $$($1_BUNDLE_NAME)), ) 67 $1_TYPE := zip 68 else 69 $$(error Unknown bundle type $$($1_BUNDLE_NAME)) 70 endif 71 72 $$(call SetIfEmpty, $1_UNZIP_DEBUGINFO, false) 73 74 $$(call SetIfEmpty, $1_OUTPUTDIR, $$(BUNDLES_OUTPUTDIR)) 75 76 $$($1_OUTPUTDIR)/$$($1_BUNDLE_NAME): $$($1_FILES) 77 $$(call MakeTargetDir) 78 $$(call LogWarn, Creating $$($1_BUNDLE_NAME)) 79 # If any of the files contain a space in the file name, FindFiles 80 # will have replaced it with ?. Tar does not accept that so need to 81 # switch it back. 82 $$(foreach d, $$($1_BASE_DIRS), \ 83 $$(eval $$(call ListPathsSafely, \ 84 $1_$$d_RELATIVE_FILES, $$($1_$$d_LIST_FILE))) \ 85 $$(CAT) $$($1_$$d_LIST_FILE) | $$(TR) '?' ' ' > $$($1_$$d_LIST_FILE).tmp \ 86 && $(MV) $$($1_$$d_LIST_FILE).tmp $$($1_$$d_LIST_FILE) $$(NEWLINE) \ 87 ) 88 ifneq ($$($1_SPECIAL_INCLUDES), ) 89 $$(foreach i, $$($1_SPECIAL_INCLUDES), \ 90 $$(foreach d, $$($1_BASE_DIRS), \ 91 ($(CD) $$d && $(FIND) $$i >> $$($1_$$d_LIST_FILE)) ; )) 92 endif 93 ifeq ($$($1_SUBDIR)-$$($1_TYPE)-$$($1_UNZIP_DEBUGINFO), .-zip-false) 94 # If no subdir is specified, zip can be done directly from BASE_DIRS. 95 $$(foreach d, $$($1_BASE_DIRS), \ 96 ( $(CD) $$d \ 97 && $(ZIPEXE) -qru $$@ . -i@$$($1_$$d_LIST_FILE) \ 98 || test "$$$$?" = "12" )$$(NEWLINE)) 99 else ifeq ($$($1_SUBDIR)-$$($1_TYPE)-$$($1_UNZIP_DEBUGINFO)-$$(words $$($1_BASE_DIRS)), \ 100 .-tar.gz-false-1) 101 # If no subdir is specified and only one BASE_DIR, tar.gz can be done 102 # directly from BASE_DIR. 103 $(CD) $$($1_BASE_DIRS) \ 104 && ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) \ 105 -$(TAR_INCLUDE_PARAM) $$($1_$$($1_BASE_DIRS)_LIST_FILE) \ 106 $(TAR_IGNORE_EXIT_VALUE) ) \ 107 | $(GZIP) > $$@ 108 else ifeq ($$($1_TYPE)-$(TAR_SUPPORTS_TRANSFORM)-$$($1_UNZIP_DEBUGINFO)-$$(words $$($1_BASE_DIRS)), \ 109 tar.gz-true-false-1) 110 # If only one BASE_DIR, but with a SUBDIR set, tar.gz can use the 111 # transform option to create bundle directly from the BASE_DIR. 112 $(CD) $$($1_BASE_DIRS) \ 113 && ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) \ 114 -$(TAR_INCLUDE_PARAM) $$($1_$$($1_BASE_DIRS)_LIST_FILE) \ 115 $$(if $$($1_SUBDIR), --transform 's|^|$$($1_SUBDIR)/|S') \ 116 $(TAR_IGNORE_EXIT_VALUE) ) \ 117 | $(GZIP) > $$@ 118 else 119 # In all other cases, need to copy all files into a temporary location 120 # before creation bundle. 121 $(RM) -r $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) 122 $(MKDIR) -p $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) 123 $$(foreach d, $$($1_BASE_DIRS), \ 124 ( $(CD) $$d \ 125 && $(TAR) cf - -$(TAR_INCLUDE_PARAM) $$($1_$$d_LIST_FILE) \ 126 $(TAR_IGNORE_EXIT_VALUE) ) \ 127 | ( $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) && $(TAR) xf - )$$(NEWLINE) ) 128 # Unzip any zipped debuginfo files 129 ifeq ($$($1_UNZIP_DEBUGINFO), true) 130 for f in `$(FIND) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) -name "*.diz"`; do \ 131 $(CD) $$$${f%/*} && $(UNZIP) -q $$$${f} && $(RM) $$$${f}; \ 132 done 133 endif 134 ifeq ($$($1_TYPE), tar.gz) 135 $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && \ 136 ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) \ 137 $$(if $$($1_SUBDIR), $$($1_SUBDIR), .) $(TAR_IGNORE_EXIT_VALUE) ) \ 138 | $(GZIP) > $$@ 139 else ifeq ($$($1_TYPE), zip) 140 $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && $(ZIPEXE) -qr $$@ . 141 endif 142 endif 143 144 $1 += $$($1_OUTPUTDIR)/$$($1_BUNDLE_NAME) 145 146 endef 147 148 ################################################################################ 149 150 # On Macosx, we bundle up the macosx specific images which already have the 151 # correct base directories. 152 ifeq ($(call isTargetOs, macosx)+$(DEBUG_LEVEL), true+release) 153 JDK_IMAGE_DIR := $(JDK_MACOSX_BUNDLE_DIR) 154 JRE_IMAGE_DIR := $(JRE_MACOSX_BUNDLE_DIR) 155 JDK_IMAGE_HOMEDIR := $(JDK_MACOSX_CONTENTS_DIR)/Home 156 JRE_IMAGE_HOMEDIR := $(JRE_MACOSX_CONTENTS_DIR)/Home 157 JDK_BUNDLE_SUBDIR := 158 JRE_BUNDLE_SUBDIR := 159 # In certain situations, the JDK_IMAGE_DIR points to an image without the 160 # the symbols and demos. If so, the symobls and demos can be found in a 161 # separate image. These variables allow for overriding from a custom makefile. 162 JDK_SYMBOLS_IMAGE_DIR ?= $(JDK_IMAGE_DIR) 163 JDK_DEMOS_IMAGE_DIR ?= $(JDK_IMAGE_DIR) 164 JDK_DEMOS_IMAGE_HOMEDIR ?= $(JDK_DEMOS_IMAGE_DIR)/$(JDK_MACOSX_CONTENTS_SUBDIR)/Home 165 else 166 JDK_IMAGE_HOMEDIR := $(JDK_IMAGE_DIR) 167 JRE_IMAGE_HOMEDIR := $(JRE_IMAGE_DIR) 168 JDK_BUNDLE_SUBDIR := jdk-$(VERSION_NUMBER) 169 JRE_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER) 170 ifneq ($(DEBUG_LEVEL), release) 171 JDK_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) 172 JRE_BUNDLE_SUBDIR := $(JRE_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) 173 endif 174 # In certain situations, the JDK_IMAGE_DIR points to an image without the 175 # the symbols and demos. If so, the symobls and demos can be found in a 176 # separate image. These variables allow for overriding from a custom makefile. 177 JDK_SYMBOLS_IMAGE_DIR ?= $(JDK_IMAGE_DIR) 178 JDK_DEMOS_IMAGE_DIR ?= $(JDK_IMAGE_DIR) 179 JDK_DEMOS_IMAGE_HOMEDIR ?= $(JDK_DEMOS_IMAGE_DIR) 180 endif 181 182 ################################################################################ 183 184 ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), ) 185 186 SYMBOLS_EXCLUDE_PATTERN := %.debuginfo %.diz %.pdb %.map 187 188 # There may be files with spaces in the names, so use ShellFindFiles 189 # explicitly. 190 ALL_JDK_FILES := $(call ShellFindFiles, $(JDK_IMAGE_DIR)) 191 ifneq ($(JDK_IMAGE_DIR), $(JDK_SYMBOLS_IMAGE_DIR)) 192 ALL_JDK_SYMBOLS_FILES := $(call ShellFindFiles, $(JDK_SYMBOLS_IMAGE_DIR)) 193 else 194 ALL_JDK_SYMBOLS_FILES := $(ALL_JDK_FILES) 195 endif 196 ifneq ($(JDK_IMAGE_DIR), $(JDK_DEMOS_IMAGE_DIR)) 197 ALL_JDK_DEMOS_FILES := $(call ShellFindFiles, $(JDK_DEMOS_IMAGE_DIR)) 198 else 199 ALL_JDK_DEMOS_FILES := $(ALL_JDK_FILES) 200 endif 201 202 # Create special filter rules when dealing with unzipped .dSYM directories on 203 # macosx 204 ifeq ($(call isTargetOs, macosx), true) 205 ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), false) 206 JDK_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ 207 $(call containing, .dSYM/, $(patsubst $(JDK_IMAGE_DIR)/%, %, \ 208 $(ALL_JDK_SYMBOLS_FILES)))) 209 endif 210 endif 211 212 JDK_BUNDLE_FILES := \ 213 $(filter-out \ 214 $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ 215 $(JDK_EXTRA_EXCLUDES) \ 216 $(SYMBOLS_EXCLUDE_PATTERN) \ 217 $(JDK_IMAGE_HOMEDIR)/demo/% \ 218 , \ 219 $(ALL_JDK_FILES) \ 220 ) 221 JDK_SYMBOLS_BUNDLE_FILES := \ 222 $(filter \ 223 $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ 224 $(SYMBOLS_EXCLUDE_PATTERN) \ 225 , \ 226 $(filter-out \ 227 $(JDK_IMAGE_HOMEDIR)/demo/% \ 228 , \ 229 $(ALL_JDK_SYMBOLS_FILES) \ 230 ) \ 231 ) \ 232 $(call FindFiles, $(SYMBOLS_IMAGE_DIR)) 233 234 TEST_DEMOS_BUNDLE_FILES := $(filter $(JDK_DEMOS_IMAGE_HOMEDIR)/demo/%, \ 235 $(ALL_JDK_DEMOS_FILES)) 236 237 ALL_JRE_FILES := $(call ShellFindFiles, $(JRE_IMAGE_DIR)) 238 239 # Create special filter rules when dealing with unzipped .dSYM directories on 240 # macosx 241 ifeq ($(OPENJDK_TARGET_OS), macosx) 242 ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), false) 243 JRE_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ 244 $(call containing, .dSYM/, $(patsubst $(JRE_IMAGE_DIR)/%, %, $(ALL_JRE_FILES)))) 245 endif 246 endif 247 248 JRE_BUNDLE_FILES := $(filter-out \ 249 $(JRE_SYMBOLS_EXCLUDE_PATTERN) \ 250 $(SYMBOLS_EXCLUDE_PATTERN), \ 251 $(ALL_JRE_FILES)) 252 253 $(eval $(call SetupBundleFile, BUILD_JDK_BUNDLE, \ 254 BUNDLE_NAME := $(JDK_BUNDLE_NAME), \ 255 FILES := $(JDK_BUNDLE_FILES), \ 256 SPECIAL_INCLUDES := $(JDK_SPECIAL_INCLUDES), \ 257 BASE_DIRS := $(JDK_IMAGE_DIR), \ 258 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 259 )) 260 261 PRODUCT_TARGETS += $(BUILD_JDK_BUNDLE) 262 263 $(eval $(call SetupBundleFile, BUILD_JRE_BUNDLE, \ 264 BUNDLE_NAME := $(JRE_BUNDLE_NAME), \ 265 FILES := $(JRE_BUNDLE_FILES), \ 266 BASE_DIRS := $(JRE_IMAGE_DIR), \ 267 SUBDIR := $(JRE_BUNDLE_SUBDIR), \ 268 )) 269 270 LEGACY_TARGETS += $(BUILD_JRE_BUNDLE) 271 272 ifeq ($(COPY_DEBUG_SYMBOLS), true) 273 $(eval $(call SetupBundleFile, BUILD_JDK_SYMBOLS_BUNDLE, \ 274 BUNDLE_NAME := $(JDK_SYMBOLS_BUNDLE_NAME), \ 275 FILES := $(JDK_SYMBOLS_BUNDLE_FILES), \ 276 BASE_DIRS := $(JDK_SYMBOLS_IMAGE_DIR) $(wildcard $(SYMBOLS_IMAGE_DIR)), \ 277 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 278 UNZIP_DEBUGINFO := true, \ 279 )) 280 281 PRODUCT_TARGETS += $(BUILD_JDK_SYMBOLS_BUNDLE) 282 endif 283 284 # The demo bundle is only created to support client tests. Ideally it should 285 # be built with the main test bundle, but since the prerequisites match 286 # better with the product build, it makes more sense to keep it there for now. 287 $(eval $(call SetupBundleFile, BUILD_TEST_DEMOS_BUNDLE, \ 288 BUNDLE_NAME := $(TEST_DEMOS_BUNDLE_NAME), \ 289 FILES := $(TEST_DEMOS_BUNDLE_FILES), \ 290 BASE_DIRS := $(JDK_DEMOS_IMAGE_DIR), \ 291 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 292 )) 293 294 PRODUCT_TARGETS += $(BUILD_TEST_DEMOS_BUNDLE) 295 endif 296 297 ################################################################################ 298 299 ifneq ($(filter test-bundles, $(MAKECMDGOALS)), ) 300 TEST_BUNDLE_FILES := $(call FindFiles, $(TEST_IMAGE_DIR)) 301 302 $(eval $(call SetupBundleFile, BUILD_TEST_BUNDLE, \ 303 BUNDLE_NAME := $(TEST_BUNDLE_NAME), \ 304 FILES := $(TEST_BUNDLE_FILES), \ 305 BASE_DIRS := $(TEST_IMAGE_DIR), \ 306 )) 307 308 TEST_TARGETS += $(BUILD_TEST_BUNDLE) 309 endif 310 311 ################################################################################ 312 313 ifneq ($(filter docs-bundles, $(MAKECMDGOALS)), ) 314 DOCS_BUNDLE_FILES := $(call FindFiles, $(DOCS_IMAGE_DIR)) 315 316 $(eval $(call SetupBundleFile, BUILD_DOCS_BUNDLE, \ 317 BUNDLE_NAME := $(DOCS_BUNDLE_NAME), \ 318 FILES := $(DOCS_BUNDLE_FILES), \ 319 BASE_DIRS := $(DOCS_IMAGE_DIR), \ 320 SUBDIR := docs, \ 321 )) 322 323 DOCS_TARGETS += $(BUILD_DOCS_BUNDLE) 324 endif 325 326 ################################################################################ 327 328 ifneq ($(filter jcov-bundles, $(MAKECMDGOALS)), ) 329 JCOV_BUNDLE_FILES := $(call FindFiles, $(JCOV_IMAGE_DIR)) 330 331 $(eval $(call SetupBundleFile, BUILD_JCOV_BUNDLE, \ 332 BUNDLE_NAME := $(JCOV_BUNDLE_NAME), \ 333 FILES := $(JCOV_BUNDLE_FILES), \ 334 BASE_DIRS := $(JCOV_IMAGE_DIR), \ 335 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 336 )) 337 338 JCOV_TARGETS += $(BUILD_JCOV_BUNDLE) 339 endif 340 341 ################################################################################ 342 343 ifneq ($(filter static-libs-bundles, $(MAKECMDGOALS)), ) 344 STATIC_LIBS_BUNDLE_FILES := $(call FindFiles, $(STATIC_LIBS_IMAGE_DIR)) 345 346 ifeq ($(OPENJDK_TARGET_OS)-$(DEBUG_LEVEL), macosx-release) 347 STATIC_LIBS_BUNDLE_SUBDIR := $(JDK_MACOSX_CONTENTS_SUBDIR)/Home 348 else 349 STATIC_LIBS_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR) 350 endif 351 352 $(eval $(call SetupBundleFile, BUILD_STATIC_LIBS_BUNDLE, \ 353 BUNDLE_NAME := $(STATIC_LIBS_BUNDLE_NAME), \ 354 FILES := $(STATIC_LIBS_BUNDLE_FILES), \ 355 BASE_DIRS := $(STATIC_LIBS_IMAGE_DIR), \ 356 SUBDIR := $(STATIC_LIBS_BUNDLE_SUBDIR), \ 357 )) 358 359 STATIC_LIBS_TARGETS += $(BUILD_STATIC_LIBS_BUNDLE) 360 endif 361 362 ################################################################################ 363 364 # Hook to include the corresponding custom file, if present. 365 $(eval $(call IncludeCustomExtension, Bundles.gmk)) 366 367 ################################################################################ 368 369 product-bundles: $(PRODUCT_TARGETS) 370 legacy-bundles: $(LEGACY_TARGETS) 371 test-bundles: $(TEST_TARGETS) 372 docs-bundles: $(DOCS_TARGETS) 373 static-libs-bundles: $(STATIC_LIBS_TARGETS) 374 jcov-bundles: $(JCOV_TARGETS) 375 376 .PHONY: all default product-bundles test-bundles docs-bundles \ 377 static-libs-bundles jcov-bundles