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 := bin/java$(EXE_SUFFIX)
  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           $(JDK_IMAGE_DIR)/bin/java$(EXE_SUFFIX) -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO)
 103         endif
 104         $(TOUCH) $@
 105 
 106 $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
 107     $(call DependOnVariable, JRE_MODULES_LIST) $(BASE_RELEASE_FILE)
 108         $(call LogWarn, Creating legacy jre image)
 109         $(RM) -r $(JRE_IMAGE_DIR)
 110         $(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre, \
 111             $(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \
 112                 $(JLINK_JRE_EXTRA_OPTS) \
 113                 --output $(JRE_IMAGE_DIR) \
 114         )
 115         ifeq ($(BUILD_CDS_ARCHIVE), true)
 116           $(call LogWarn, Creating CDS archive for jre image)
 117           $(JRE_IMAGE_DIR)/bin/java$(EXE_SUFFIX) -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO)
 118         endif
 119         $(TOUCH) $@
 120 
 121 TOOL_JRE_TARGETS := $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
 122 TOOL_JDK_TARGETS := $(JDK_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
 123 
 124 ################################################################################
 125 # /man dir
 126 #
 127 # All variables in this section are assigned with simple =, without :, to enable
 128 # more selective overriding from the custom version of this file.
 129 #
 130 # Avoid evaluating this whole section on windows for speed and stability
 131 ifneq ($(OPENJDK_TARGET_OS), windows)
 132   ifeq ($(BUILD_MANPAGES), true)
 133     JRE_MAN_PAGES += \
 134         java.1 \
 135         jjs.1 \
 136         keytool.1 \
 137         orbd.1 \
 138         pack200.1 \
 139         rmid.1 \
 140         rmiregistry.1 \
 141         servertool.1 \
 142         unpack200.1
 143 
 144     JDK_MAN_PAGES += \
 145         $(JRE_MAN_PAGES) \
 146         idlj.1 \
 147         jar.1 \
 148         jarsigner.1 \
 149         javac.1 \
 150         javadoc.1 \
 151         javap.1 \
 152         jconsole.1 \
 153         jcmd.1 \
 154         jdb.1 \
 155         jdeps.1 \
 156         jinfo.1 \
 157         jmap.1 \
 158         jps.1 \
 159         jrunscript.1 \
 160         jstack.1 \
 161         jstat.1 \
 162         jstatd.1 \
 163         rmic.1 \
 164         serialver.1
 165 
 166     # This variable is potentially overridden in the closed makefile.
 167     MAN_SRC_BASEDIR ?= $(TOPDIR)/src
 168 
 169     ifeq ($(OPENJDK_TARGET_OS), linux)
 170       MAN_SRC_DIR = $(MAN_SRC_BASEDIR)/linux/doc
 171       MAN1_SUBDIR = man
 172     endif
 173     ifeq ($(OPENJDK_TARGET_OS), solaris)
 174       MAN_SRC_DIR = $(MAN_SRC_BASEDIR)/solaris/doc
 175       MAN1_SUBDIR = sun/man/man1
 176     endif
 177     ifeq ($(OPENJDK_TARGET_OS), macosx)
 178       MAN_SRC_DIR = $(MAN_SRC_BASEDIR)/bsd/doc
 179       MAN1_SUBDIR = man
 180     endif
 181 
 182     $(JRE_IMAGE_DIR)/man/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/%
 183         $(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%,%,$@))
 184         $(install-file)
 185 
 186     $(JDK_IMAGE_DIR)/man/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/%
 187         $(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%,%,$@))
 188         $(install-file)
 189 
 190     $(JRE_IMAGE_DIR)/man/ja_JP.UTF-8/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 191         $(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%,%,$@))
 192         $(install-file)
 193 
 194     $(JDK_IMAGE_DIR)/man/ja_JP.UTF-8/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 195         $(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%,%,$@))
 196         $(install-file)
 197 
 198     ifeq ($(OPENJDK_TARGET_OS), solaris)
 199       $(JRE_IMAGE_DIR)/man/ja/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 200         $(call LogInfo, Converting $(patsubst $(OUTPUTDIR)/%,%,$@))
 201         $(install-file)
 202 
 203       $(JDK_IMAGE_DIR)/man/ja/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 204         $(call LogInfo, Converting $(patsubst $(OUTPUTDIR)/%,%,$@))
 205         $(install-file)
 206     endif
 207 
 208     ifneq ($(findstring $(OPENJDK_TARGET_OS), linux macosx), )
 209       $(JRE_IMAGE_DIR)/man/ja:
 210         $(call LogInfo, Creating $(patsubst $(OUTPUTDIR)/%,%,$@))
 211         $(CD) $(@D) && $(RM) ja && $(LN) -s ja_JP.UTF-8 ja
 212 
 213       $(JDK_IMAGE_DIR)/man/ja:
 214         $(call LogInfo, Creating $(patsubst $(OUTPUTDIR)/%,%,$@))
 215         $(CD) $(@D) && $(RM) ja && $(LN) -s ja_JP.UTF-8 ja
 216     endif
 217 
 218     ifeq ($(OPENJDK_TARGET_OS), solaris)
 219       JRE_MAN_PAGE_LIST = $(addprefix $(JRE_IMAGE_DIR)/man/man1/, $(JRE_MAN_PAGES)) \
 220           $(addprefix $(JRE_IMAGE_DIR)/man/ja/man1/, $(JRE_MAN_PAGES)) \
 221           $(addprefix $(JRE_IMAGE_DIR)/man/ja_JP.UTF-8/man1/, $(JRE_MAN_PAGES)) \
 222           $(addprefix $(JRE_IMAGE_DIR)/man/ja_JP.PCK/man1/, $(JRE_MAN_PAGES))
 223 
 224       JDK_MAN_PAGE_LIST = $(addprefix $(JDK_IMAGE_DIR)/man/man1/, $(JDK_MAN_PAGES)) \
 225           $(addprefix $(JDK_IMAGE_DIR)/man/ja/man1/, $(JDK_MAN_PAGES)) \
 226           $(addprefix $(JDK_IMAGE_DIR)/man/ja_JP.UTF-8/man1/, $(JDK_MAN_PAGES)) \
 227           $(addprefix $(JDK_IMAGE_DIR)/man/ja_JP.PCK/man1/, $(JDK_MAN_PAGES))
 228     endif
 229 
 230     ifneq ($(findstring $(OPENJDK_TARGET_OS), linux macosx), )
 231       JRE_MAN_PAGE_LIST = $(addprefix $(JRE_IMAGE_DIR)/man/man1/, $(JRE_MAN_PAGES)) \
 232           $(addprefix $(JRE_IMAGE_DIR)/man/ja_JP.UTF-8/man1/, $(JRE_MAN_PAGES)) \
 233           $(JRE_IMAGE_DIR)/man/ja
 234 
 235       JDK_MAN_PAGE_LIST = $(addprefix $(JDK_IMAGE_DIR)/man/man1/, $(JDK_MAN_PAGES)) \
 236           $(addprefix $(JDK_IMAGE_DIR)/man/ja_JP.UTF-8/man1/, $(JDK_MAN_PAGES)) \
 237           $(JDK_IMAGE_DIR)/man/ja
 238     endif
 239 
 240     JRE_TARGETS += $(JRE_MAN_PAGE_LIST)
 241     JDK_TARGETS += $(JDK_MAN_PAGE_LIST)
 242   endif # BUILD_MANPAGES
 243 endif # Windows
 244 
 245 ################################################################################
 246 # src.zip
 247 
 248 $(JDK_IMAGE_DIR)/lib/src.zip: $(SUPPORT_OUTPUTDIR)/src.zip
 249         $(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%,%,$@))
 250         $(install-file)
 251 
 252 JDK_TARGETS += $(JDK_IMAGE_DIR)/lib/src.zip
 253 
 254 ################################################################################
 255 # /demo dir
 256 # Avoid doing the expensive find unless called with "jdk" as target.
 257 ifneq ($(filter jdk, $(MAKECMDGOALS)), )
 258 
 259   DEMO_FILES := \
 260       $(if $(wildcard $(SUPPORT_OUTPUTDIR)/demos/image), \
 261         $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/demos/image \
 262             -type f -a ! \( -name "_the*" -o -name "javac_state" \) ) \
 263       )
 264 
 265   ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
 266     ifeq ($(OPENJDK_TARGET_OS), macosx)
 267       DEMO_FILES := $(call not-containing, .dSYM, $(DEMO_FILES))
 268     else
 269       DEMO_FILES := $(filter-out %.debuginfo %.pdb %.map, $(DEMO_FILES))
 270     endif
 271   endif
 272 
 273   $(eval $(call SetupCopyFiles, JDK_COPY_DEMOS, \
 274       SRC := $(SUPPORT_OUTPUTDIR)/demos/image, \
 275       DEST := $(JDK_IMAGE_DIR)/demo, \
 276       FILES := $(DEMO_FILES), \
 277   ))
 278 
 279   JDK_TARGETS += $(JDK_COPY_DEMOS)
 280 endif
 281 
 282 ################################################################################
 283 # Code coverage data files
 284 
 285 ifeq ($(GCOV_ENABLED), true)
 286 
 287   GCOV_FIND_EXPR := -type f -name "*.gcno"
 288 
 289   $(eval $(call SetupCopyFiles,COPY_HOTSPOT_GCOV_GCNO, \
 290       SRC := $(OUTPUTDIR), \
 291       DEST := $(SYMBOLS_IMAGE_DIR)/gcov, \
 292       FILES := $(shell $(FIND) $(HOTSPOT_OUTPUTDIR) $(GCOV_FIND_EXPR))))
 293 
 294   SYMBOLS_TARGETS += $(COPY_HOTSPOT_GCOV_GCNO)
 295 
 296   $(eval $(call SetupCopyFiles,COPY_JDK_GCOV_GCNO, \
 297       SRC := $(OUTPUTDIR), \
 298       DEST := $(SYMBOLS_IMAGE_DIR)/gcov, \
 299       FILES := $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/native $(GCOV_FIND_EXPR))))
 300 
 301   SYMBOLS_TARGETS += $(COPY_JDK_GCOV_GCNO)
 302 
 303 endif
 304 
 305 ################################################################################
 306 # Debug symbols
 307 # Since debug symbols are not included in the jmod files, they need to be copied
 308 # in manually after generating the images.
 309 
 310 ALL_JDK_MODULES := $(JDK_MODULES)
 311 ALL_JRE_MODULES := $(sort $(JRE_MODULES), $(foreach m, $(JRE_MODULES), \
 312     $(call FindTransitiveDepsForModule, $m)))
 313 
 314 ifeq ($(OPENJDK_TARGET_OS), windows)
 315   LIBS_TARGET_SUBDIR := bin
 316 else
 317   LIBS_TARGET_SUBDIR := lib
 318 endif
 319 
 320 # Param 1 - dir to find debuginfo files in
 321 FindDebuginfoFiles = \
 322     $(wildcard $(addprefix $1/*, $(DEBUGINFO_SUFFIXES)) \
 323         $(addprefix $1/*/*, $(DEBUGINFO_SUFFIXES)) \
 324         $(addprefix $1/*/*/*, $(DEBUGINFO_SUFFIXES)))
 325 
 326 # Pick the correct debug info files to copy, either zipped or not.
 327 ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
 328   DEBUGINFO_SUFFIXES += .diz
 329 else
 330   DEBUGINFO_SUFFIXES := .debuginfo .pdb .map
 331   # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM
 332   # dirs.
 333   ifeq ($(OPENJDK_TARGET_OS), macosx)
 334     $(eval $(call FillCacheFind, \
 335         $(SUPPORT_OUTPUTDIR)/modules_cmds $(SUPPORT_OUTPUTDIR)/modules_libs))
 336     FindDebuginfoFiles = \
 337         $(if $(wildcard $1), $(call containing, .dSYM/, $(call CacheFind, $1)))
 338   endif
 339 endif
 340 
 341 # Param 1 - either JDK or JRE
 342 SetupCopyDebuginfo = \
 343     $(foreach m, $(ALL_$1_MODULES), \
 344       $(eval $(call SetupCopyFiles, COPY_$1_LIBS_DEBUGINFO_$m, \
 345           SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$m, \
 346           DEST := $($1_IMAGE_DIR)/$(LIBS_TARGET_SUBDIR), \
 347           FILES := $(call FindDebuginfoFiles, \
 348               $(SUPPORT_OUTPUTDIR)/modules_libs/$m), \
 349       )) \
 350       $(eval $1_TARGETS += $$(COPY_$1_LIBS_DEBUGINFO_$m)) \
 351     )
 352 
 353 # No space before argument to avoid having to put $(strip ) everywhere in
 354 # implementation above.
 355 $(call SetupCopyDebuginfo,JDK)
 356 $(call SetupCopyDebuginfo,JRE)
 357 
 358 ################################################################################
 359 
 360 # Include custom post hook here to make it possible to augment the target lists
 361 # before actual target prerequisites are declared.
 362 $(eval $(call IncludeCustomExtension, Images-post.gmk))
 363 
 364 ################################################################################
 365 
 366 $(JRE_TARGETS): $(TOOL_JRE_TARGETS)
 367 $(JDK_TARGETS): $(TOOL_JDK_TARGETS)
 368 
 369 jdk: $(TOOL_JDK_TARGETS) $(JDK_TARGETS)
 370 jre: $(TOOL_JRE_TARGETS) $(JRE_TARGETS)
 371 symbols: $(SYMBOLS_TARGETS)
 372 
 373 all: jdk jre symbols
 374 
 375 .PHONY: default all jdk jre symbols