1 # 2 # Copyright (c) 2014, 2018, 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 include Modules.gmk 31 32 TOOL_TARGETS := 33 JDK_TARGETS := 34 JRE_TARGETS := 35 36 # Hook to include the corresponding custom file, if present. 37 $(eval $(call IncludeCustomExtension, Images-pre.gmk)) 38 39 ################################################################################ 40 41 # All modules for the current target platform. 42 ALL_MODULES := $(call FindAllModules) 43 44 $(eval $(call ReadImportMetaData)) 45 46 JRE_MODULES += $(filter $(ALL_MODULES), $(BOOT_MODULES) \ 47 $(PLATFORM_MODULES) $(JRE_TOOL_MODULES)) 48 JDK_MODULES += $(ALL_MODULES) 49 50 JRE_MODULES_LIST := $(call CommaList, $(JRE_MODULES)) 51 JDK_MODULES_LIST := $(call CommaList, $(JDK_MODULES)) 52 53 ################################################################################ 54 55 BASE_RELEASE_FILE := $(JDK_OUTPUTDIR)/release 56 57 JMODS := $(wildcard $(IMAGES_OUTPUTDIR)/jmods/*.jmod) 58 59 # Use this file inside the image as target for make rule 60 JIMAGE_TARGET_FILE := release 61 62 JLINK_ORDER_RESOURCES := **module-info.class 63 JLINK_JLI_CLASSES := 64 ifeq ($(ENABLE_GENERATE_CLASSLIST), true) 65 JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/link_opt/classlist 66 JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/link_opt/default_jli_trace.txt 67 endif 68 JLINK_ORDER_RESOURCES += \ 69 /java.base/java/** \ 70 /java.base/jdk/** \ 71 /java.base/sun/** \ 72 /java.base/com/** \ 73 /jdk.localedata/** \ 74 # 75 76 JLINK_TOOL := $(JLINK) -J-Djlink.debug=true \ 77 --module-path $(IMAGES_OUTPUTDIR)/jmods \ 78 --endian $(OPENJDK_TARGET_CPU_ENDIAN) \ 79 --release-info $(BASE_RELEASE_FILE) \ 80 --order-resources=$(call CommaList, $(JLINK_ORDER_RESOURCES)) \ 81 --dedup-legal-notices=error-if-not-same-content \ 82 $(JLINK_JLI_CLASSES) \ 83 # 84 85 JLINK_JRE_EXTRA_OPTS := --no-man-pages --no-header-files --strip-debug 86 87 ifeq ($(JLINK_KEEP_PACKAGED_MODULES), true) 88 JLINK_JDK_EXTRA_OPTS := --keep-packaged-modules $(JDK_IMAGE_DIR)/jmods 89 endif 90 91 $(JDK_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ 92 $(call DependOnVariable, JDK_MODULES_LIST) $(BASE_RELEASE_FILE) 93 $(call LogWarn, Creating jdk image) 94 $(RM) -r $(JDK_IMAGE_DIR) 95 $(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jdk, \ 96 $(JLINK_TOOL) --add-modules $(JDK_MODULES_LIST) \ 97 $(JLINK_JDK_EXTRA_OPTS) \ 98 --output $(JDK_IMAGE_DIR) \ 99 ) 100 ifeq ($(BUILD_CDS_ARCHIVE), true) 101 $(call LogWarn, Creating CDS archive for jdk image) 102 $(FIXPATH) $(JDK_IMAGE_DIR)/bin/java \ 103 -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO) 104 endif 105 $(TOUCH) $@ 106 107 $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ 108 $(call DependOnVariable, JRE_MODULES_LIST) $(BASE_RELEASE_FILE) 109 $(call LogWarn, Creating legacy jre image) 110 $(RM) -r $(JRE_IMAGE_DIR) 111 $(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre, \ 112 $(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \ 113 $(JLINK_JRE_EXTRA_OPTS) \ 114 --output $(JRE_IMAGE_DIR) \ 115 ) 116 ifeq ($(BUILD_CDS_ARCHIVE), true) 117 $(call LogWarn, Creating CDS archive for jre image) 118 $(FIXPATH) $(JRE_IMAGE_DIR)/bin/java \ 119 -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO) 120 endif 121 $(TOUCH) $@ 122 123 TOOL_JRE_TARGETS := $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE) 124 TOOL_JDK_TARGETS := $(JDK_IMAGE_DIR)/$(JIMAGE_TARGET_FILE) 125 126 ################################################################################ 127 # src.zip 128 129 $(JDK_IMAGE_DIR)/lib/src.zip: $(SUPPORT_OUTPUTDIR)/src.zip 130 $(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%,%,$@)) 131 $(install-file) 132 133 JDK_TARGETS += $(JDK_IMAGE_DIR)/lib/src.zip 134 135 ################################################################################ 136 # /demo dir 137 # Avoid doing the expensive find unless called with "jdk" as target. 138 ifneq ($(filter jdk, $(MAKECMDGOALS)), ) 139 140 DEMO_FILES := \ 141 $(if $(wildcard $(SUPPORT_OUTPUTDIR)/demos/image), \ 142 $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/demos/image \ 143 -type f -a ! \( -name "_the*" -o -name "javac_state" \) ) \ 144 ) 145 146 ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true) 147 ifeq ($(OPENJDK_TARGET_OS), macosx) 148 DEMO_FILES := $(call not-containing, .dSYM, $(DEMO_FILES)) 149 else 150 DEMO_FILES := $(filter-out %.debuginfo %.pdb %.map, $(DEMO_FILES)) 151 endif 152 endif 153 154 $(eval $(call SetupCopyFiles, JDK_COPY_DEMOS, \ 155 SRC := $(SUPPORT_OUTPUTDIR)/demos/image, \ 156 DEST := $(JDK_IMAGE_DIR)/demo, \ 157 FILES := $(DEMO_FILES), \ 158 )) 159 160 JDK_TARGETS += $(JDK_COPY_DEMOS) 161 endif 162 163 ################################################################################ 164 # Code coverage data files 165 166 ifeq ($(GCOV_ENABLED), true) 167 168 GCOV_FIND_EXPR := -type f -name "*.gcno" 169 170 $(eval $(call SetupCopyFiles,COPY_HOTSPOT_GCOV_GCNO, \ 171 SRC := $(OUTPUTDIR), \ 172 DEST := $(SYMBOLS_IMAGE_DIR)/gcov, \ 173 FILES := $(shell $(FIND) $(HOTSPOT_OUTPUTDIR) $(GCOV_FIND_EXPR)))) 174 175 SYMBOLS_TARGETS += $(COPY_HOTSPOT_GCOV_GCNO) 176 177 $(eval $(call SetupCopyFiles,COPY_JDK_GCOV_GCNO, \ 178 SRC := $(OUTPUTDIR), \ 179 DEST := $(SYMBOLS_IMAGE_DIR)/gcov, \ 180 FILES := $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/native $(GCOV_FIND_EXPR)))) 181 182 SYMBOLS_TARGETS += $(COPY_JDK_GCOV_GCNO) 183 184 endif 185 186 ################################################################################ 187 # Debug symbols 188 # Since debug symbols are not included in the jmod files, they need to be copied 189 # in manually after generating the images. 190 191 ALL_JDK_MODULES := $(JDK_MODULES) 192 ALL_JRE_MODULES := $(sort $(JRE_MODULES), $(foreach m, $(JRE_MODULES), \ 193 $(call FindTransitiveDepsForModule, $m))) 194 195 ifeq ($(OPENJDK_TARGET_OS), windows) 196 LIBS_TARGET_SUBDIR := bin 197 else 198 LIBS_TARGET_SUBDIR := lib 199 endif 200 201 # Param 1 - dir to find debuginfo files in 202 FindDebuginfoFiles = \ 203 $(wildcard $(addprefix $1/*, $(DEBUGINFO_SUFFIXES)) \ 204 $(addprefix $1/*/*, $(DEBUGINFO_SUFFIXES)) \ 205 $(addprefix $1/*/*/*, $(DEBUGINFO_SUFFIXES))) 206 207 # Pick the correct debug info files to copy, either zipped or not. 208 ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true) 209 DEBUGINFO_SUFFIXES += .diz 210 else 211 DEBUGINFO_SUFFIXES := .debuginfo .pdb .map 212 # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM 213 # dirs. 214 ifeq ($(OPENJDK_TARGET_OS), macosx) 215 $(eval $(call FillCacheFind, \ 216 $(SUPPORT_OUTPUTDIR)/modules_cmds $(SUPPORT_OUTPUTDIR)/modules_libs)) 217 FindDebuginfoFiles = \ 218 $(if $(wildcard $1), $(call containing, .dSYM/, $(call CacheFind, $1))) 219 endif 220 endif 221 222 # Param 1 - either JDK or JRE 223 SetupCopyDebuginfo = \ 224 $(foreach m, $(ALL_$1_MODULES), \ 225 $(eval $(call SetupCopyFiles, COPY_$1_LIBS_DEBUGINFO_$m, \ 226 SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$m, \ 227 DEST := $($1_IMAGE_DIR)/$(LIBS_TARGET_SUBDIR), \ 228 FILES := $(call FindDebuginfoFiles, \ 229 $(SUPPORT_OUTPUTDIR)/modules_libs/$m), \ 230 )) \ 231 $(eval $1_TARGETS += $$(COPY_$1_LIBS_DEBUGINFO_$m)) \ 232 ) 233 234 # No space before argument to avoid having to put $(strip ) everywhere in 235 # implementation above. 236 $(call SetupCopyDebuginfo,JDK) 237 $(call SetupCopyDebuginfo,JRE) 238 239 ################################################################################ 240 241 # Include custom post hook here to make it possible to augment the target lists 242 # before actual target prerequisites are declared. 243 $(eval $(call IncludeCustomExtension, Images-post.gmk)) 244 245 ################################################################################ 246 247 $(JRE_TARGETS): $(TOOL_JRE_TARGETS) 248 $(JDK_TARGETS): $(TOOL_JDK_TARGETS) 249 250 jdk: $(TOOL_JDK_TARGETS) $(JDK_TARGETS) 251 jre: $(TOOL_JRE_TARGETS) $(JRE_TARGETS) 252 symbols: $(SYMBOLS_TARGETS) 253 254 all: jdk jre symbols 255 256 .PHONY: default all jdk jre symbols