1 #
  2 # Copyright (c) 2014, 2020, 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 Execute.gmk
 31 include Modules.gmk
 32 
 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) jdk.jdwp.agent)
 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 JLINK_ORDER_RESOURCES := **module-info.class
 60 JLINK_JLI_CLASSES :=
 61 ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
 62   JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/link_opt/classlist
 63   JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/link_opt/default_jli_trace.txt
 64 endif
 65 JLINK_ORDER_RESOURCES += \
 66     /java.base/java/** \
 67     /java.base/jdk/** \
 68     /java.base/sun/** \
 69     /java.base/com/** \
 70     /jdk.localedata/** \
 71     #
 72 
 73 JLINK_TOOL := $(JLINK) -J-Djlink.debug=true \
 74     --module-path $(IMAGES_OUTPUTDIR)/jmods \
 75     --endian $(OPENJDK_TARGET_CPU_ENDIAN) \
 76     --release-info $(BASE_RELEASE_FILE) \
 77     --order-resources=$(call CommaList, $(JLINK_ORDER_RESOURCES)) \
 78     --dedup-legal-notices=error-if-not-same-content \
 79     $(JLINK_JLI_CLASSES) \
 80     #
 81 
 82 JLINK_JRE_EXTRA_OPTS := --no-man-pages --no-header-files --strip-debug
 83 
 84 ifeq ($(JLINK_KEEP_PACKAGED_MODULES), true)
 85   JLINK_JDK_EXTRA_OPTS := --keep-packaged-modules $(JDK_IMAGE_DIR)/jmods
 86 endif
 87 
 88 JLINK_DISABLE_WARNINGS := | ( $(GREP) -v -e "WARNING: Using incubator module" || test "$$?" = "1" )
 89 
 90 $(eval $(call SetupExecute, jlink_jdk, \
 91     WARN := Creating jdk image, \
 92     DEPS := $(JMODS) $(BASE_RELEASE_FILE) \
 93         $(call DependOnVariable, JDK_MODULES_LIST), \
 94     OUTPUT_DIR := $(JDK_IMAGE_DIR), \
 95     SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jdk, \
 96     PRE_COMMAND := $(RM) -r $(JDK_IMAGE_DIR), \
 97     COMMAND := $(JLINK_TOOL) --add-modules $(JDK_MODULES_LIST) \
 98         $(JLINK_JDK_EXTRA_OPTS) --output $(JDK_IMAGE_DIR) \
 99         $(JLINK_DISABLE_WARNINGS), \
100 ))
101 
102 JLINK_JDK_TARGETS := $(jlink_jdk)
103 
104 $(eval $(call SetupExecute, jlink_jre, \
105     WARN := Creating legacy jre image, \
106     DEPS := $(JMODS) $(BASE_RELEASE_FILE) \
107         $(call DependOnVariable, JDK_MODULES_LIST), \
108     OUTPUT_DIR := $(JRE_IMAGE_DIR), \
109     SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jre, \
110     PRE_COMMAND := $(RM) -r $(JRE_IMAGE_DIR), \
111     COMMAND := $(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \
112         $(JLINK_JRE_EXTRA_OPTS) --output $(JRE_IMAGE_DIR), \
113 ))
114 
115 JLINK_JRE_TARGETS := $(jlink_jre)
116 
117 ifeq ($(BUILD_CDS_ARCHIVE), true)
118   ifeq ($(OPENJDK_TARGET_OS), windows)
119     CDS_ARCHIVE := bin/server/classes.jsa
120     CDS_NOCOOPS_ARCHIVE := bin/server/classes_nocoops.jsa
121   else
122     CDS_ARCHIVE := lib/server/classes.jsa
123     CDS_NOCOOPS_ARCHIVE := lib/server/classes_nocoops.jsa
124   endif
125 
126   $(eval $(call SetupExecute, gen_cds_archive_jdk, \
127       WARN := Creating CDS archive for jdk image, \
128       DEPS := $(jlink_jdk), \
129       OUTPUT_FILE := $(JDK_IMAGE_DIR)/$(CDS_ARCHIVE), \
130       SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jdk, \
131       COMMAND := $(FIXPATH) $(JDK_IMAGE_DIR)/bin/java -Xshare:dump \
132           -XX:SharedArchiveFile=$(JDK_IMAGE_DIR)/$(CDS_ARCHIVE) \
133           -Xmx128M -Xms128M $(LOG_INFO), \
134   ))
135 
136   JDK_TARGETS += $(gen_cds_archive_jdk)
137 
138   $(eval $(call SetupExecute, gen_cds_archive_jre, \
139       WARN := Creating CDS archive for jre image, \
140       DEPS := $(jlink_jre), \
141       OUTPUT_FILE := $(JRE_IMAGE_DIR)/$(CDS_ARCHIVE), \
142       SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jre, \
143       COMMAND := $(FIXPATH) $(JRE_IMAGE_DIR)/bin/java -Xshare:dump \
144           -XX:SharedArchiveFile=$(JRE_IMAGE_DIR)/$(CDS_ARCHIVE) \
145           -Xmx128M -Xms128M $(LOG_INFO), \
146   ))
147 
148   JRE_TARGETS += $(gen_cds_archive_jre)
149 
150   ifeq ($(call isTargetCpuBits, 64), true)
151     $(eval $(call SetupExecute, gen_cds_nocoops_archive_jdk, \
152         WARN := Creating CDS-NOCOOPS archive for jdk image, \
153         DEPS := $(jlink_jdk), \
154         OUTPUT_FILE := $(JDK_IMAGE_DIR)/$(CDS_NOCOOPS_ARCHIVE), \
155         SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jdk, \
156         COMMAND := $(FIXPATH) $(JDK_IMAGE_DIR)/bin/java -Xshare:dump \
157             -XX:SharedArchiveFile=$(JDK_IMAGE_DIR)/$(CDS_NOCOOPS_ARCHIVE) \
158             -XX:-UseCompressedOops \
159             -Xmx128M -Xms128M $(LOG_INFO), \
160     ))
161 
162     JDK_TARGETS += $(gen_cds_nocoops_archive_jdk)
163 
164     $(eval $(call SetupExecute, gen_cds_nocoops_archive_jre, \
165         WARN := Creating CDS-NOCOOPS archive for jre image, \
166         DEPS := $(jlink_jre), \
167         OUTPUT_FILE := $(JRE_IMAGE_DIR)/$(CDS_NOCOOPS_ARCHIVE), \
168         SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jre, \
169         COMMAND := $(FIXPATH) $(JRE_IMAGE_DIR)/bin/java -Xshare:dump \
170             -XX:SharedArchiveFile=$(JRE_IMAGE_DIR)/$(CDS_NOCOOPS_ARCHIVE) \
171             -XX:-UseCompressedOops \
172             -Xmx128M -Xms128M $(LOG_INFO), \
173     ))
174 
175     JRE_TARGETS += $(gen_cds_nocoops_archive_jre)
176   endif
177 
178 endif
179 
180 ################################################################################
181 # src.zip
182 
183 $(JDK_IMAGE_DIR)/lib/src.zip: $(SUPPORT_OUTPUTDIR)/src.zip
184 	$(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%,%,$@))
185 	$(install-file)
186 
187 JDK_TARGETS += $(JDK_IMAGE_DIR)/lib/src.zip
188 
189 ################################################################################
190 # /demo dir
191 # Avoid doing the expensive find unless called with "jdk" as target.
192 ifneq ($(filter jdk, $(MAKECMDGOALS)), )
193 
194   DEMO_FILES := \
195       $(if $(wildcard $(SUPPORT_OUTPUTDIR)/demos/image), \
196         $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/demos/image \
197             -type f -a ! \( -name "_the*" -o -name "javac_state" \) ) \
198       )
199 
200   ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
201     ifeq ($(call isTargetOs, macosx), true)
202       DEMO_FILES := $(call not-containing, .dSYM, $(DEMO_FILES))
203     else
204       DEMO_FILES := $(filter-out %.debuginfo %.pdb %.map, $(DEMO_FILES))
205     endif
206   endif
207 
208   $(eval $(call SetupCopyFiles, JDK_COPY_DEMOS, \
209       SRC := $(SUPPORT_OUTPUTDIR)/demos/image, \
210       DEST := $(JDK_IMAGE_DIR)/demo, \
211       FILES := $(DEMO_FILES), \
212   ))
213 
214   JDK_TARGETS += $(JDK_COPY_DEMOS)
215 endif
216 
217 ################################################################################
218 # Code coverage data files
219 
220 ifeq ($(GCOV_ENABLED), true)
221 
222   $(eval $(call SetupCopyFiles,COPY_GCOV_GCNO, \
223       SRC := $(OUTPUTDIR), \
224       DEST := $(SYMBOLS_IMAGE_DIR)/gcov, \
225       FILES := $(call FindFiles, $(HOTSPOT_OUTPUTDIR) \
226           $(SUPPORT_OUTPUTDIR)/native, *.gcno) \
227   ))
228 
229   SYMBOLS_TARGETS += $(COPY_GCOV_GCNO)
230 
231 endif
232 
233 ################################################################################
234 # Debug symbols
235 # Since debug symbols are not included in the jmod files, they need to be copied
236 # in manually after generating the images.
237 
238 ALL_JDK_MODULES := $(JDK_MODULES)
239 ALL_JRE_MODULES := $(sort $(JRE_MODULES), $(foreach m, $(JRE_MODULES), \
240     $(call FindTransitiveDepsForModule, $m)))
241 ALL_SYMBOLS_MODULES := $(JDK_MODULES)
242 
243 ifeq ($(call isTargetOs, windows), true)
244   LIBS_TARGET_SUBDIR := bin
245 else
246   LIBS_TARGET_SUBDIR := lib
247 endif
248 CMDS_TARGET_SUBDIR := bin
249 
250 # Param 1 - dir to find debuginfo files in
251 FindDebuginfoFiles = \
252     $(wildcard $(addprefix $1/*, $(DEBUGINFO_SUFFIXES)) \
253         $(addprefix $1/*/*, $(DEBUGINFO_SUFFIXES)) \
254         $(addprefix $1/*/*/*, $(DEBUGINFO_SUFFIXES)))
255 
256 # Pick the correct debug info files to copy, either zipped or not.
257 ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
258   DEBUGINFO_SUFFIXES += .diz
259 else
260   DEBUGINFO_SUFFIXES := .debuginfo .pdb .map
261   # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM
262   # dirs.
263   ifeq ($(call isTargetOs, macosx), true)
264     $(call FillFindCache, \
265         $(SUPPORT_OUTPUTDIR)/modules_libs $(SUPPORT_OUTPUTDIR)/modules_cmds)
266     FindDebuginfoFiles = \
267         $(if $(wildcard $1), $(call containing, .dSYM/, $(call FindFiles, $1)))
268   endif
269 endif
270 
271 FILTERED_PDBS := %jimage.stripped.pdb %jpackage.stripped.pdb %java.stripped.pdb \
272     %jimage.pdb %jpackage.pdb %java.pdb %jimage.map %jpackage.map %java.map
273 
274 # Param 1 - either JDK or JRE
275 SetupCopyDebuginfo = \
276     $(foreach m, $(ALL_$1_MODULES), \
277       $(eval $(call SetupCopyFiles, COPY_$1_LIBS_DEBUGINFO_$m, \
278           SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$m, \
279           DEST := $($1_IMAGE_DIR)/$(LIBS_TARGET_SUBDIR), \
280           FILES := $(call FindDebuginfoFiles, \
281               $(SUPPORT_OUTPUTDIR)/modules_libs/$m), \
282       )) \
283       $(eval $1_TARGETS += $$(COPY_$1_LIBS_DEBUGINFO_$m)) \
284       $(eval $(call SetupCopyFiles, COPY_$1_CMDS_DEBUGINFO_$m, \
285           SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds/$m, \
286           DEST := $($1_IMAGE_DIR)/$(CMDS_TARGET_SUBDIR), \
287           FILES := $(filter-out $(FILTERED_PDBS), $(call FindDebuginfoFiles, \
288               $(SUPPORT_OUTPUTDIR)/modules_cmds/$m)), \
289       )) \
290       $(eval $1_TARGETS += $$(COPY_$1_CMDS_DEBUGINFO_$m)) \
291     )
292 
293 # No space before argument to avoid having to put $(strip ) everywhere in
294 # implementation above.
295 $(call SetupCopyDebuginfo,JDK)
296 $(call SetupCopyDebuginfo,JRE)
297 $(call SetupCopyDebuginfo,SYMBOLS)
298 
299 ################################################################################
300 
301 # Include custom post hook here to make it possible to augment the target lists
302 # before actual target prerequisites are declared.
303 $(eval $(call IncludeCustomExtension, Images-post.gmk))
304 
305 ################################################################################
306 
307 $(JRE_TARGETS): $(JLINK_JRE_TARGETS)
308 $(JDK_TARGETS): $(JLINK_JDK_TARGETS)
309 
310 jdk: $(JLINK_JDK_TARGETS) $(JDK_TARGETS)
311 jre: $(JLINK_JRE_TARGETS) $(JRE_TARGETS)
312 symbols: $(SYMBOLS_TARGETS)
313 
314 all: jdk jre symbols
315 
316 .PHONY: default all jdk jre symbols
--- EOF ---