1 #
   2 # Copyright (c) 2011, 2022, 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 ################################################################################
  27 # This is the main makefile containing most actual top level targets. It needs
  28 # to be called with a SPEC file defined.
  29 ################################################################################
  30 
  31 # Declare default target
  32 default:
  33 
  34 ifeq ($(wildcard $(SPEC)),)
  35   $(error Main.gmk needs SPEC set to a proper spec.gmk)
  36 endif
  37 
  38 # Now load the spec
  39 include $(SPEC)
  40 
  41 # Load the vital tools for all the makefiles.
  42 include $(TOPDIR)/make/common/MakeBase.gmk
  43 include $(TOPDIR)/make/common/Modules.gmk
  44 include $(TOPDIR)/make/common/FindTests.gmk
  45 
  46 include $(TOPDIR)/make/MainSupport.gmk
  47 
  48 # Are we requested to ignore dependencies?
  49 ifneq ($(findstring -only, $(MAKECMDGOALS)), )
  50   DEPS := none
  51 endif
  52 
  53 # Declare ALL_TARGETS as an immediate variable. This variable is a list of all
  54 # valid top level targets. It's used to declare them all as PHONY and to
  55 # generate the -only targets.
  56 ALL_TARGETS :=
  57 
  58 # Hook to include the corresponding custom file, if present.
  59 $(eval $(call IncludeCustomExtension, Main.gmk))
  60 
  61 # All modules for the current target platform.
  62 ALL_MODULES := $(call FindAllModules)
  63 
  64 ################################################################################
  65 ################################################################################
  66 #
  67 # Recipes for all targets. Only recipes, dependencies are declared later.
  68 #
  69 ################################################################################
  70 
  71 ################################################################################
  72 # Interim/build tools targets, compiling tools used during the build
  73 
  74 $(eval $(call SetupTarget, buildtools-langtools, \
  75     MAKEFILE := ToolsLangtools, \
  76 ))
  77 
  78 $(eval $(call SetupTarget, interim-langtools, \
  79     MAKEFILE := CompileInterimLangtools, \
  80 ))
  81 
  82 $(eval $(call SetupTarget, interim-tzdb, \
  83     MAKEFILE := CopyInterimTZDB, \
  84 ))
  85 
  86 $(eval $(call SetupTarget, buildtools-jdk, \
  87     MAKEFILE := CompileToolsJdk, \
  88     DEPS := interim-langtools interim-tzdb, \
  89 ))
  90 
  91 $(eval $(call SetupTarget, buildtools-modules, \
  92     MAKEFILE := CompileModuleTools, \
  93 ))
  94 
  95 $(eval $(call SetupTarget, buildtools-hotspot, \
  96     MAKEFILE := CompileToolsHotspot, \
  97 ))
  98 
  99 ################################################################################
 100 # Special targets for certain modules
 101 
 102 $(eval $(call SetupTarget, generate-exported-symbols, \
 103     MAKEFILE := BuildStatic, \
 104     DEPS := java.base-libs jdk.jdwp.agent-libs, \
 105 ))
 106 
 107 ################################################################################
 108 # Gensrc targets, generating source before java compilation can be done
 109 #
 110 $(eval $(call DeclareRecipesForPhase, GENSRC, \
 111     TARGET_SUFFIX := gensrc-src, \
 112     FILE_PREFIX := Gensrc, \
 113     CHECK_MODULES := $(ALL_MODULES), \
 114 ))
 115 
 116 $(foreach m, $(GENSRC_MODULES), $(eval $m-gensrc: $m-gensrc-src))
 117 
 118 LANGTOOLS_GENSRC_TARGETS := $(filter $(addsuffix -%, $(LANGTOOLS_MODULES)), $(GENSRC_TARGETS))
 119 INTERIM_LANGTOOLS_GENSRC_TARGETS := $(filter $(addsuffix -%, \
 120     $(INTERIM_LANGTOOLS_BASE_MODULES)), $(GENSRC_TARGETS))
 121 HOTSPOT_GENSRC_TARGETS := $(filter $(addsuffix -%, $(HOTSPOT_MODULES)), $(GENSRC_TARGETS))
 122 JDK_GENSRC_TARGETS := $(filter-out $(LANGTOOLS_GENSRC_TARGETS) \
 123     $(HOTSPOT_GENSRC_TARGETS), $(GENSRC_TARGETS))
 124 
 125 GENSRC_MODULEINFO_MODULES := $(ALL_MODULES)
 126 GENSRC_MODULEINFO_TARGETS := $(addsuffix -gensrc-moduleinfo, \
 127     $(GENSRC_MODULEINFO_MODULES))
 128 
 129 GENSRC_MODULES := $(GENSRC_MODULEINFO_MODULES)
 130 GENSRC_TARGETS += $(sort $(GENSRC_MODULEINFO_TARGETS) \
 131     $(addsuffix -gensrc, $(GENSRC_MODULES)))
 132 
 133 define DeclareModuleInfoRecipe
 134   $1-gensrc-moduleinfo:
 135 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
 136 	    -f common/modules/GensrcModuleInfo.gmk MODULE=$1)
 137 
 138   $1-gensrc: $1-gensrc-moduleinfo
 139 endef
 140 
 141 $(foreach m, $(GENSRC_MODULEINFO_MODULES), $(eval $(call DeclareModuleInfoRecipe,$m)))
 142 
 143 ALL_TARGETS += $(GENSRC_TARGETS)
 144 
 145 ################################################################################
 146 # Generate data targets
 147 $(eval $(call DeclareRecipesForPhase, GENDATA, \
 148     TARGET_SUFFIX := gendata, \
 149     FILE_PREFIX := Gendata, \
 150     CHECK_MODULES := $(ALL_MODULES), \
 151 ))
 152 
 153 ALL_TARGETS += $(GENDATA_TARGETS)
 154 
 155 ################################################################################
 156 # Copy files targets
 157 $(eval $(call DeclareRecipesForPhase, COPY, \
 158     TARGET_SUFFIX := copy, \
 159     FILE_PREFIX := Copy, \
 160     CHECK_MODULES := $(ALL_MODULES), \
 161 ))
 162 
 163 ALL_COPY_MODULES += $(COPY_MODULES)
 164 ALL_COPY_TARGETS += $(COPY_TARGETS)
 165 
 166 IMPORT_COPY_MODULES := $(call FindImportedModules)
 167 IMPORT_COPY_TARGETS := $(addsuffix -copy, $(IMPORT_COPY_MODULES))
 168 ALL_COPY_MODULES += $(IMPORT_COPY_MODULES)
 169 ALL_COPY_TARGETS += $(IMPORT_COPY_TARGETS)
 170 
 171 define DeclareImportCopyRecipe
 172   $1-copy:
 173 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
 174 	    -f CopyImportModules.gmk MODULE=$1)
 175 endef
 176 
 177 $(foreach m, $(IMPORT_COPY_MODULES), $(eval $(call DeclareImportCopyRecipe,$m)))
 178 
 179 ALL_TARGETS += $(ALL_COPY_TARGETS)
 180 
 181 ################################################################################
 182 # Targets for compiling all java modules.
 183 JAVA_MODULES := $(ALL_MODULES)
 184 JAVA_TARGETS := $(addsuffix -java, $(JAVA_MODULES))
 185 
 186 define DeclareCompileJavaRecipe
 187   $1-java:
 188 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
 189 	$(patsubst %,-I%/modules/$1,$(PHASE_MAKEDIRS)) \
 190 	    -f CompileJavaModules.gmk MODULE=$1)
 191 endef
 192 
 193 $(foreach m, $(JAVA_MODULES), $(eval $(call DeclareCompileJavaRecipe,$m)))
 194 
 195 ALL_TARGETS += $(JAVA_TARGETS)
 196 
 197 ################################################################################
 198 # Targets for compiling native libraries
 199 $(eval $(call DeclareRecipesForPhase, LIBS, \
 200     TARGET_SUFFIX := libs, \
 201     FILE_PREFIX := Lib, \
 202     CHECK_MODULES := $(ALL_MODULES), \
 203 ))
 204 
 205 ALL_TARGETS += $(LIBS_TARGETS)
 206 
 207 ################################################################################
 208 # Targets for compiling static versions of certain native libraries. These do
 209 # not end up in the jmods or the normal JDK image, but are instead bundled into
 210 # a special deliverable.
 211 $(eval $(call DeclareRecipesForPhase, STATIC_LIBS, \
 212     TARGET_SUFFIX := static-libs, \
 213     FILE_PREFIX := Lib, \
 214     CHECK_MODULES := $(ALL_MODULES), \
 215     EXTRA_ARGS := STATIC_LIBS=true, \
 216 ))
 217 
 218 ALL_TARGETS += $(STATIC_LIBS_TARGETS)
 219 
 220 ################################################################################
 221 # Targets for compiling native executables
 222 $(eval $(call DeclareRecipesForPhase, LAUNCHER, \
 223     TARGET_SUFFIX := launchers, \
 224     FILE_PREFIX := Launcher, \
 225     CHECK_MODULES := $(ALL_MODULES), \
 226 ))
 227 
 228 ALL_TARGETS += $(LAUNCHER_TARGETS)
 229 
 230 ################################################################################
 231 # Build hotspot target
 232 
 233 HOTSPOT_VARIANT_TARGETS := $(addprefix hotspot-, $(JVM_VARIANTS))
 234 HOTSPOT_VARIANT_GENSRC_TARGETS := $(addsuffix -gensrc, $(HOTSPOT_VARIANT_TARGETS))
 235 HOTSPOT_VARIANT_LIBS_TARGETS := $(addsuffix -libs, $(HOTSPOT_VARIANT_TARGETS))
 236 
 237 define DeclareHotspotGensrcRecipe
 238   hotspot-$1-gensrc:
 239 	$$(call LogInfo, Building JVM variant '$1' with features '$(JVM_FEATURES_$1)')
 240 	+($(CD) $(TOPDIR)/make/hotspot && $(MAKE) $(MAKE_ARGS) -f gensrc/GenerateSources.gmk \
 241 	    JVM_VARIANT=$1)
 242 endef
 243 
 244 $(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotGensrcRecipe,$v)))
 245 
 246 define DeclareHotspotLibsRecipe
 247   hotspot-$1-libs:
 248 	+($(CD) $(TOPDIR)/make/hotspot && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibraries.gmk \
 249 	    JVM_VARIANT=$1)
 250 endef
 251 
 252 $(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotLibsRecipe,$v)))
 253 
 254 $(eval $(call SetupTarget, hotspot-ide-project, \
 255     MAKEFILE := ide/visualstudio/hotspot/CreateVSProject, \
 256     DEPS := hotspot exploded-image, \
 257     ARGS := -I$(TOPDIR)/make/hotspot, \
 258 ))
 259 
 260 ALL_TARGETS += $(HOTSPOT_VARIANT_TARGETS) $(HOTSPOT_VARIANT_GENSRC_TARGETS) \
 261     $(HOTSPOT_VARIANT_LIBS_TARGETS)
 262 
 263 ################################################################################
 264 # Help and user support
 265 
 266 $(eval $(call SetupTarget, doctor, \
 267     MAKEFILE := Doctor, \
 268 ))
 269 
 270 ################################################################################
 271 # Generate libs and launcher targets for creating compile_commands.json fragments
 272 define DeclareCompileCommandsRecipe
 273   $1-compile-commands:
 274 	$$(call LogInfo, Generating compile_commands.json fragments for $1)
 275 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Main.gmk $1-only \
 276 	    GENERATE_COMPILE_COMMANDS_ONLY=true)
 277 
 278   COMPILE_COMMANDS_TARGETS_$2 += $1-compile-commands
 279 endef
 280 
 281 $(foreach t, $(HOTSPOT_VARIANT_LIBS_TARGETS), \
 282   $(eval $(call DeclareCompileCommandsRecipe,$t,HOTSPOT)) \
 283 )
 284 
 285 $(foreach t, $(LIBS_TARGETS) $(LAUNCHER_TARGETS), \
 286   $(eval $(call DeclareCompileCommandsRecipe,$t,JDK)) \
 287 )
 288 
 289 $(eval $(call SetupTarget, compile-commands, \
 290     MAKEFILE := CompileCommands, \
 291 ))
 292 
 293 $(eval $(call SetupTarget, compile-commands-hotspot, \
 294     MAKEFILE := CompileCommands, \
 295 ))
 296 
 297 ALL_TARGETS += $(COMPILE_COMMANDS_TARGETS_HOTSPOT) $(COMPILE_COMMANDS_TARGETS_JDK)
 298 
 299 ################################################################################
 300 # VS Code projects
 301 
 302 $(eval $(call SetupTarget, vscode-project, \
 303     MAKEFILE := ide/vscode/hotspot/CreateVSCodeProject, \
 304     ARGS := VSCODE_INDEXER=cpptools, \
 305     DEPS := compile-commands, \
 306 ))
 307 
 308 $(eval $(call SetupTarget, vscode-project-clangd, \
 309     MAKEFILE := ide/vscode/hotspot/CreateVSCodeProject, \
 310     ARGS := VSCODE_INDEXER=clangd, \
 311     DEPS := compile-commands, \
 312 ))
 313 
 314 $(eval $(call SetupTarget, vscode-project-rtags, \
 315     MAKEFILE := ide/vscode/hotspot/CreateVSCodeProject, \
 316     ARGS := VSCODE_INDEXER=rtags, \
 317     DEPS := compile-commands, \
 318 ))
 319 
 320 $(eval $(call SetupTarget, vscode-project-ccls, \
 321     MAKEFILE := ide/vscode/hotspot/CreateVSCodeProject, \
 322     ARGS := VSCODE_INDEXER=ccls, \
 323     DEPS := compile-commands, \
 324 ))
 325 
 326 ################################################################################
 327 # Build demos targets
 328 
 329 # The demos are currently linking to libjvm and libjava, just like all other
 330 # jdk libs, even though they don't need to. To avoid warnings, make sure they
 331 # aren't built until after libjava and libjvm are available to link to.
 332 $(eval $(call SetupTarget, demos-jdk, \
 333     MAKEFILE := CompileDemos, \
 334     DEPS := java.base-libs exploded-image buildtools-jdk, \
 335 ))
 336 
 337 $(eval $(call SetupTarget, test-image-demos-jdk, \
 338     MAKEFILE := CompileDemos, \
 339     TARGET := images, \
 340     DEPS := demos-jdk, \
 341 ))
 342 
 343 ################################################################################
 344 # Jigsaw specific data and analysis targets.
 345 
 346 $(eval $(call SetupTarget, generate-summary, \
 347     MAKEFILE := GenerateModuleSummary, \
 348     DEPS := jmods buildtools-modules runnable-buildjdk, \
 349 ))
 350 
 351 ################################################################################
 352 # Jmod targets
 353 
 354 JMOD_MODULES := $(ALL_MODULES)
 355 JMOD_TARGETS := $(addsuffix -jmod, $(JMOD_MODULES))
 356 
 357 define DeclareJmodRecipe
 358   $1-jmod:
 359 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
 360 	    MODULE=$1)
 361 endef
 362 
 363 $(foreach m, $(JMOD_MODULES), $(eval $(call DeclareJmodRecipe,$m)))
 364 
 365 ALL_TARGETS += $(JMOD_TARGETS)
 366 
 367 ################################################################################
 368 # Images targets
 369 
 370 $(eval $(call SetupTarget, store-source-revision, \
 371     MAKEFILE := SourceRevision, \
 372     TARGET := store-source-revision, \
 373 ))
 374 
 375 $(eval $(call SetupTarget, create-source-revision-tracker, \
 376     MAKEFILE := SourceRevision, \
 377     TARGET := create-source-revision-tracker, \
 378 ))
 379 
 380 BOOTCYCLE_TARGET := product-images
 381 bootcycle-images:
 382         ifneq ($(COMPILE_TYPE), cross)
 383 	  $(call LogWarn, Boot cycle build step 2: Building a new JDK image using previously built image)
 384 	  $(call MakeDir, $(OUTPUTDIR)/bootcycle-build)
 385 	  +$(MAKE) $(MAKE_ARGS) -f $(TOPDIR)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
 386 	      LOG_PREFIX="[bootcycle] " JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
 387         else
 388 	  $(call LogWarn, Boot cycle build disabled when cross compiling)
 389         endif
 390 
 391 $(eval $(call SetupTarget, zip-security, \
 392     MAKEFILE := ZipSecurity, \
 393     DEPS := buildtools-jdk java.base-java java.security.jgss-java java.security.jgss-libs, \
 394 ))
 395 
 396 $(eval $(call SetupTarget, zip-source, \
 397     MAKEFILE := ZipSource, \
 398     DEPS := buildtools-jdk gensrc, \
 399 ))
 400 
 401 $(eval $(call SetupTarget, jrtfs-jar, \
 402     MAKEFILE := JrtfsJar, \
 403     DEPS := interim-langtools, \
 404 ))
 405 
 406 $(eval $(call SetupTarget, jdk-image, \
 407     MAKEFILE := Images, \
 408     TARGET := jdk, \
 409     DEPS := jmods zip-source demos release-file, \
 410 ))
 411 
 412 $(eval $(call SetupTarget, legacy-jre-image, \
 413     MAKEFILE := Images, \
 414     TARGET := jre, \
 415     DEPS := jmods release-file, \
 416 ))
 417 
 418 $(eval $(call SetupTarget, symbols-image, \
 419     MAKEFILE := Images, \
 420     TARGET := symbols, \
 421 ))
 422 
 423 $(eval $(call SetupTarget, static-libs-image, \
 424     MAKEFILE := StaticLibsImage, \
 425 ))
 426 
 427 $(eval $(call SetupTarget, mac-jdk-bundle, \
 428     MAKEFILE := MacBundles, \
 429     TARGET := jdk-bundle, \
 430     DEPS := jdk-image, \
 431 ))
 432 
 433 $(eval $(call SetupTarget, mac-legacy-jre-bundle, \
 434     MAKEFILE := MacBundles, \
 435     TARGET := jre-bundle, \
 436     DEPS := legacy-jre-image, \
 437 ))
 438 
 439 $(eval $(call SetupTarget, release-file, \
 440     MAKEFILE := ReleaseFile, \
 441     DEPS := create-source-revision-tracker, \
 442 ))
 443 
 444 $(eval $(call SetupTarget, exploded-image-optimize, \
 445     MAKEFILE := ExplodedImageOptimize, \
 446     DEPS := java copy gendata java.base-libs java.base-launchers \
 447         buildtools-modules, \
 448 ))
 449 
 450 $(eval $(call SetupTarget, graal-builder-image, \
 451     MAKEFILE := GraalBuilderImage, \
 452     DEPS := jdk-image static-libs-image, \
 453 ))
 454 
 455 ifeq ($(JCOV_ENABLED), true)
 456   $(eval $(call SetupTarget, jcov-image, \
 457       MAKEFILE := Coverage, \
 458       TARGET := jcov-image, \
 459       DEPS := jdk-image, \
 460   ))
 461 endif
 462 
 463 ALL_TARGETS += bootcycle-images
 464 
 465 ################################################################################
 466 # Docs targets
 467 
 468 # If building full docs, to complete docs-*-api we need both the javadoc and
 469 # graphs targets.
 470 $(eval $(call SetupTarget, docs-jdk-api-javadoc, \
 471     MAKEFILE := Docs, \
 472     TARGET := docs-jdk-api-javadoc, \
 473 ))
 474 
 475 $(eval $(call SetupTarget, docs-jdk-api-graphs, \
 476     MAKEFILE := Docs, \
 477     TARGET := docs-jdk-api-graphs, \
 478     DEPS := buildtools-modules runnable-buildjdk, \
 479 ))
 480 
 481 $(eval $(call SetupTarget, docs-javase-api-javadoc, \
 482     MAKEFILE := Docs, \
 483     TARGET := docs-javase-api-javadoc, \
 484 ))
 485 
 486 $(eval $(call SetupTarget, docs-javase-api-graphs, \
 487     MAKEFILE := Docs, \
 488     TARGET := docs-javase-api-graphs, \
 489     DEPS := buildtools-modules runnable-buildjdk, \
 490 ))
 491 
 492 $(eval $(call SetupTarget, docs-reference-api-javadoc, \
 493     MAKEFILE := Docs, \
 494     TARGET := docs-reference-api-javadoc, \
 495 ))
 496 
 497 $(eval $(call SetupTarget, docs-reference-api-graphs, \
 498     MAKEFILE := Docs, \
 499     TARGET := docs-reference-api-graphs, \
 500     DEPS := buildtools-modules runnable-buildjdk, \
 501 ))
 502 
 503 # The gensrc steps for jdk.jdi create html spec files.
 504 $(eval $(call SetupTarget, docs-jdk-specs, \
 505     MAKEFILE := Docs, \
 506     TARGET := docs-jdk-specs, \
 507     DEPS := buildtools-jdk jdk.jdi-gensrc docs-jdk-index, \
 508 ))
 509 
 510 $(eval $(call SetupTarget, docs-jdk-index, \
 511     MAKEFILE := Docs, \
 512     TARGET := docs-jdk-index, \
 513 ))
 514 
 515 $(eval $(call SetupTarget, docs-zip, \
 516     MAKEFILE := Docs, \
 517     TARGET := docs-zip, \
 518     DEPS :=  docs-jdk buildtools-jdk, \
 519 ))
 520 
 521 $(eval $(call SetupTarget, docs-specs-zip, \
 522     MAKEFILE := Docs, \
 523     TARGET := docs-specs-zip, \
 524     DEPS := docs-jdk-specs buildtools-jdk, \
 525 ))
 526 
 527 $(eval $(call SetupTarget, update-build-docs, \
 528     MAKEFILE := UpdateBuildDocs, \
 529 ))
 530 
 531 $(eval $(call SetupTarget, update-x11wrappers, \
 532     MAKEFILE := UpdateX11Wrappers, \
 533     DEPS := java.base-copy buildtools-jdk, \
 534 ))
 535 
 536 ifneq ($(HSDIS_BACKEND), none)
 537   $(eval $(call SetupTarget, build-hsdis, \
 538       MAKEFILE := Hsdis, \
 539       TARGET := build, \
 540   ))
 541 
 542   $(eval $(call SetupTarget, install-hsdis, \
 543       MAKEFILE := Hsdis, \
 544       TARGET := install, \
 545       DEPS := jdk-image, \
 546   ))
 547 endif
 548 
 549 ################################################################################
 550 # Cross compilation support
 551 
 552 ifeq ($(CREATING_BUILDJDK), true)
 553   # This target is only called by the recursive call below.
 554   create-buildjdk-interim-image-helper: interim-image jdk.jlink-launchers \
 555       java.base-copy jdk.jdeps-launchers
 556 endif
 557 
 558 BUILDJDK_MODULES := $(sort $(foreach m, jdk.jlink $(INTERIM_IMAGE_MODULES), \
 559     $(call FindTransitiveDepsForModule, $m) $m))
 560 
 561 $(eval $(call SetupTarget, create-buildjdk-interim-image, \
 562     MAKEFILE := Main, \
 563     TARGET := create-buildjdk-interim-image-helper, \
 564     ARGS := SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
 565         HOTSPOT_SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
 566         CREATING_BUILDJDK=true \
 567         LOG_PREFIX="[buildjdk] " \
 568         JAVA_MODULES="$(BUILDJDK_MODULES)", \
 569 ))
 570 
 571 ################################################################################
 572 # The interim-image is a small jlinked image that is used to generate artifacts
 573 # at build time for use when linking the real images.
 574 
 575 INTERIM_JMOD_TARGETS := $(addsuffix -interim-jmod, $(INTERIM_IMAGE_MODULES))
 576 
 577 define DeclareInterimJmodRecipe
 578   $1-interim-jmod:
 579 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
 580 	    MODULE=$1 \
 581 	    JMODS_DIR=$(INTERIM_JMODS_DIR) \
 582 	    JMODS_SUPPORT_DIR=$(INTERIM_JMODS_DIR)/support \
 583 	    INTERIM_JMOD=true \
 584 	)
 585 endef
 586 
 587 $(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $(call DeclareInterimJmodRecipe,$m)))
 588 
 589 $(eval $(call SetupTarget, interim-image, \
 590     MAKEFILE := InterimImage, \
 591 ))
 592 
 593 ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
 594   $(eval $(call SetupTarget, generate-link-opt-data, \
 595       MAKEFILE := GenerateLinkOptData, \
 596   ))
 597 endif
 598 
 599 ################################################################################
 600 # Generate test names for all JTReg test groups
 601 #
 602 
 603 define DeclareRunTestRecipe
 604   test-$1:
 605 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk \
 606 	    TEST="$1")
 607 
 608   exploded-test-$1:
 609 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk \
 610 	    TEST="$1" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
 611 endef
 612 
 613 # ALL_NAMED_TESTS is defined in FindTests.gmk
 614 $(foreach t, $(ALL_NAMED_TESTS), $(eval $(call DeclareRunTestRecipe,$t)))
 615 ALL_TEST_TARGETS := $(addprefix test-, $(ALL_NAMED_TESTS))
 616 
 617 # We only support the "exploded-test-gtest" shortcut
 618 ALL_EXPLODED_TESTS := gtest
 619 ALL_EXPLODED_TEST_TARGETS := $(addprefix exploded-test-, $(ALL_EXPLODED_TESTS))
 620 
 621 ALL_TARGETS += $(ALL_TEST_TARGETS) $(ALL_EXPLODED_TEST_TARGETS)
 622 
 623 ################################################################################
 624 # Build tests and microbenchmarks
 625 #
 626 
 627 $(eval $(call SetupTarget, prepare-test-image, \
 628     MAKEFILE := TestImage, \
 629     TARGET := prepare-test-image, \
 630 ))
 631 
 632 $(eval $(call SetupTarget, build-test-hotspot-jtreg-native, \
 633     MAKEFILE := test/JtregNativeHotspot, \
 634     TARGET := build-test-hotspot-jtreg-native, \
 635     DEPS := buildtools-jdk, \
 636 ))
 637 
 638 $(eval $(call SetupTarget, test-image-hotspot-jtreg-native, \
 639     MAKEFILE := test/JtregNativeHotspot, \
 640     TARGET := test-image-hotspot-jtreg-native, \
 641     DEPS := build-test-hotspot-jtreg-native, \
 642 ))
 643 
 644 $(eval $(call SetupTarget, build-test-jdk-jtreg-native, \
 645     MAKEFILE := test/JtregNativeJdk, \
 646     TARGET := build-test-jdk-jtreg-native, \
 647     DEPS := buildtools-jdk java.base-libs, \
 648 ))
 649 
 650 $(eval $(call SetupTarget, test-image-jdk-jtreg-native, \
 651     MAKEFILE := test/JtregNativeJdk, \
 652     TARGET := test-image-jdk-jtreg-native, \
 653     DEPS := build-test-jdk-jtreg-native, \
 654 ))
 655 
 656 # Native files needed by the testlib
 657 $(eval $(call SetupTarget, build-test-lib-native, \
 658     MAKEFILE := test/BuildTestLibNative, \
 659     TARGET := build-test-lib-native, \
 660     DEPS := buildtools-jdk java.base-libs, \
 661 ))
 662 
 663 $(eval $(call SetupTarget, test-image-lib-native, \
 664     MAKEFILE := test/BuildTestLibNative, \
 665     TARGET := test-image-lib-native, \
 666     DEPS := build-test-lib-native, \
 667 ))
 668 
 669 # Native files needed when testing the testlib itself
 670 $(eval $(call SetupTarget, build-test-libtest-jtreg-native, \
 671     MAKEFILE := test/JtregNativeLibTest, \
 672     TARGET := build-test-libtest-jtreg-native, \
 673     DEPS := buildtools-jdk, \
 674 ))
 675 
 676 $(eval $(call SetupTarget, test-image-libtest-jtreg-native, \
 677     MAKEFILE := test/JtregNativeLibTest, \
 678     TARGET := test-image-libtest-jtreg-native, \
 679     DEPS := build-test-libtest-jtreg-native, \
 680 ))
 681 
 682 ifneq ($(GTEST_FRAMEWORK_SRC), )
 683   $(eval $(call SetupTarget, test-image-hotspot-gtest, \
 684       MAKEFILE := hotspot/test/GtestImage, \
 685       DEPS := hotspot, \
 686   ))
 687 endif
 688 
 689 $(eval $(call SetupTarget, build-test-lib, \
 690     MAKEFILE := test/BuildTestLib, \
 691     DEPS := exploded-image, \
 692 ))
 693 
 694 ifeq ($(BUILD_FAILURE_HANDLER), true)
 695   # Builds the failure handler jtreg extension
 696   $(eval $(call SetupTarget, build-test-failure-handler, \
 697       MAKEFILE := test/BuildFailureHandler, \
 698       TARGET := build, \
 699       DEPS := interim-langtools, \
 700   ))
 701 
 702   # Copies the failure handler jtreg extension into the test image
 703   $(eval $(call SetupTarget, test-image-failure-handler, \
 704       MAKEFILE := test/BuildFailureHandler, \
 705       TARGET := images, \
 706       DEPS := build-test-failure-handler, \
 707   ))
 708 endif
 709 
 710 ifeq ($(BUILD_JTREG_MAIN_WRAPPER), true)
 711   # Builds the main wrapper jtreg extension
 712   $(eval $(call SetupTarget, build-test-main-wrapper, \
 713       MAKEFILE := test/BuildJtregMainWrapper, \
 714       TARGET := build, \
 715       DEPS := interim-langtools, \
 716   ))
 717 
 718   # Copies the failure handler jtreg extension into the test image
 719   $(eval $(call SetupTarget, test-image-main-wrapper, \
 720       MAKEFILE := test/BuildJtregMainWrapper, \
 721       TARGET := images, \
 722       DEPS := build-test-main-wrapper, \
 723   ))
 724 endif
 725 
 726 
 727 $(eval $(call SetupTarget, build-microbenchmark, \
 728     MAKEFILE := test/BuildMicrobenchmark, \
 729     DEPS := interim-langtools exploded-image, \
 730 ))
 731 
 732 ################################################################################
 733 # Run tests
 734 
 735 $(eval $(call SetupTarget, test, \
 736     MAKEFILE := RunTests, \
 737     ARGS := TEST="$(TEST)", \
 738     DEPS := jdk-image test-image, \
 739 ))
 740 
 741 $(eval $(call SetupTarget, exploded-test, \
 742     MAKEFILE := RunTests, \
 743     ARGS := TEST="$(TEST)" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR), \
 744     DEPS := exploded-image test-image, \
 745 ))
 746 
 747 ifeq ($(JCOV_ENABLED), true)
 748   $(eval $(call SetupTarget, jcov-test, \
 749       MAKEFILE := RunTests, \
 750       ARGS := TEST="$(TEST)" TEST_OPTS_JCOV=true, \
 751       DEPS := jcov-image test-image, \
 752   ))
 753 endif
 754 
 755 ################################################################################
 756 # Bundles
 757 
 758 $(eval $(call SetupTarget, product-bundles, \
 759     MAKEFILE := Bundles, \
 760     TARGET := product-bundles, \
 761     DEPS := product-images, \
 762 ))
 763 
 764 $(eval $(call SetupTarget, legacy-bundles, \
 765     MAKEFILE := Bundles, \
 766     TARGET := legacy-bundles, \
 767     DEPS := legacy-images, \
 768 ))
 769 
 770 $(eval $(call SetupTarget, test-bundles, \
 771     MAKEFILE := Bundles, \
 772     TARGET := test-bundles, \
 773     DEPS := test-image, \
 774 ))
 775 
 776 $(eval $(call SetupTarget, docs-jdk-bundles, \
 777     MAKEFILE := Bundles, \
 778     TARGET := docs-jdk-bundles, \
 779     DEPS := docs-image, \
 780 ))
 781 
 782 $(eval $(call SetupTarget, docs-javase-bundles, \
 783     MAKEFILE := Bundles, \
 784     TARGET := docs-javase-bundles, \
 785     DEPS := docs-javase-image, \
 786 ))
 787 
 788 $(eval $(call SetupTarget, docs-reference-bundles, \
 789     MAKEFILE := Bundles, \
 790     TARGET := docs-reference-bundles, \
 791     DEPS := docs-reference-image, \
 792 ))
 793 
 794 $(eval $(call SetupTarget, static-libs-bundles, \
 795     MAKEFILE := Bundles, \
 796     TARGET := static-libs-bundles, \
 797     DEPS := static-libs-image, \
 798 ))
 799 
 800 ifeq ($(JCOV_ENABLED), true)
 801   $(eval $(call SetupTarget, jcov-bundles, \
 802       MAKEFILE := Bundles, \
 803       TARGET := jcov-bundles, \
 804       DEPS := jcov-image, \
 805   ))
 806 endif
 807 
 808 ################################################################################
 809 # Install targets
 810 
 811 $(eval $(call SetupTarget, install, \
 812     MAKEFILE := Install, \
 813     DEPS := product-images, \
 814 ))
 815 
 816 ################################################################################
 817 #
 818 # Dependency declarations between targets.
 819 #
 820 # These are declared in two groups. First all dependencies between targets that
 821 # have recipes above as these dependencies may be disabled. Then the aggregator
 822 # targets that do not have recipes of their own, which will never have their
 823 # dependencies disabled.
 824 #
 825 ################################################################################
 826 # Targets with recipes above
 827 
 828 # If running an *-only target, parallel execution and dependencies between
 829 # recipe targets are disabled. This makes it possible to run a select set of
 830 # recipe targets in order. It's the responsibility of the user to make sure
 831 # all prerequisites are fulfilled.
 832 ifeq ($(DEPS), none)
 833   .NOTPARALLEL:
 834 else
 835   $(LANGTOOLS_GENSRC_TARGETS): buildtools-langtools
 836 
 837   interim-langtools: $(INTERIM_LANGTOOLS_GENSRC_TARGETS)
 838 
 839   $(HOTSPOT_GENSRC_TARGETS): interim-langtools buildtools-hotspot
 840 
 841   $(JDK_GENSRC_TARGETS): interim-langtools buildtools-jdk
 842 
 843   $(GENSRC_MODULEINFO_TARGETS): buildtools-jdk
 844 
 845   $(GENDATA_TARGETS): interim-langtools buildtools-jdk
 846 
 847   $(JAVA_TARGETS): interim-langtools
 848 
 849   # Declare dependencies between hotspot-<variant>* targets
 850   $(foreach v, $(JVM_VARIANTS), \
 851       $(eval hotspot-$v-gensrc: java.base-copy buildtools-hotspot) \
 852       $(eval hotspot-$v-libs: hotspot-$v-gensrc java.base-copy) \
 853   )
 854 
 855   # If not already set, set the JVM variant target so that the JVM will be built.
 856   JVM_MAIN_LIB_TARGETS ?= hotspot-$(JVM_VARIANT_MAIN)-libs
 857   JVM_MAIN_GENSRC_TARGETS ?= hotspot-$(JVM_VARIANT_MAIN)-gensrc
 858 
 859   # Building one JVM variant is enough to start building the other libs
 860   $(LIBS_TARGETS): $(JVM_MAIN_LIB_TARGETS)
 861 
 862   # Static libs depend on hotspot gensrc
 863   $(STATIC_LIBS_TARGETS): $(JVM_MAIN_GENSRC_TARGETS)
 864 
 865   $(LAUNCHER_TARGETS): java.base-libs
 866 
 867   ifeq ($(STATIC_BUILD), true)
 868     $(LAUNCHER_TARGETS): generate-exported-symbols
 869   endif
 870 
 871   # Declare dependency from <module>-java to <module>-gensrc
 872   $(foreach m, $(GENSRC_MODULES), $(eval $m-java: $m-gensrc))
 873 
 874   # Declare dependencies between java modules
 875   $(foreach m, $(JAVA_MODULES), \
 876       $(eval $m-java: $(addsuffix -java, $(filter $(JAVA_MODULES), \
 877       $(call FindDepsForModule,$m)))))
 878   # Declare dependencies between the module meta targets
 879   $(foreach m, $(ALL_MODULES), $(eval $m: $(call FindDepsForModule,$m)))
 880 
 881   # Declare dependencies from <module>-lib to <module>-java
 882   # Skip modules that do not have java source.
 883   $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs: $m-java))
 884 
 885   # Declare dependencies from all other <module>-lib to java.base-lib
 886   $(foreach t, $(filter-out java.base-libs, $(LIBS_TARGETS)), \
 887       $(eval $t: java.base-libs))
 888 
 889   ifeq ($(ENABLE_HSDIS_BUNDLING), true)
 890     java.base-copy: build-hsdis
 891   endif
 892 
 893   # jdk.accessibility depends on java.desktop
 894   jdk.accessibility-libs: java.desktop-libs
 895 
 896   # This dependency needs to be explicitly declared. jdk.jdi-gensrc generates a
 897   # header file used by jdk.jdwp.agent-libs. The jdk.jdwp.agent-gensrc is a
 898   # virtual target.
 899   jdk.jdwp.agent-libs: jdk.jdwp.agent-gensrc
 900 
 901   # jdk.jfr-gendata uses TOOL_JFR_GEN from buildtools-hotspot
 902   jdk.jfr-gendata: buildtools-hotspot
 903 
 904   # The swing beans need to have java base properly generated to avoid errors
 905   # in javadoc. The X11 wrappers need the java.base include files to have been
 906   # copied and processed.
 907   java.desktop-gensrc-src: java.base-gensrc java.base-copy
 908 
 909   jdk.jdeps-gendata: java
 910 
 911   # The ct.sym generation uses all the moduleinfos as input
 912   jdk.compiler-gendata: $(GENSRC_MODULEINFO_TARGETS)
 913 
 914   # Declare dependencies between jmod targets.
 915   # java.base jmod needs jrt-fs.jar and access to the other jmods to be built.
 916   # When creating the BUILDJDK, we don't need to add hashes to java.base, thus
 917   # we don't need to depend on all other jmods
 918   ifneq ($(CREATING_BUILDJDK), true)
 919     java.base-jmod: jrtfs-jar $(filter-out java.base-jmod, $(JMOD_TARGETS))
 920   endif
 921 
 922   # If not already set, set the JVM target so that the JVM will be built.
 923   JVM_MAIN_TARGETS ?= hotspot
 924 
 925   # Building java.base-jmod requires all of VM (ie hotspot) to be built.
 926   java.base-jmod: $(JVM_MAIN_TARGETS)
 927 
 928   # Declare dependencies from <module>-jmod to all other module targets
 929   $(foreach m, $(JAVA_MODULES), $(eval $m_JMOD_DEPS += $m-java))
 930   $(foreach m, $(GENDATA_MODULES), $(eval $m_JMOD_DEPS += $m-gendata))
 931   $(foreach m, $(LIBS_MODULES), $(eval $m_JMOD_DEPS += $m-libs))
 932   $(foreach m, $(LAUNCHER_MODULES), $(eval $m_JMOD_DEPS += $m-launchers))
 933   $(foreach m, $(COPY_MODULES), $(eval $m_JMOD_DEPS += $m-copy))
 934   $(foreach m, $(ALL_MODULES), $(eval $m-jmod: $($(m)_JMOD_DEPS)))
 935   $(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $m-interim-jmod: $($(m)_JMOD_DEPS)))
 936 
 937   # Setup the minimal set of generated native source dependencies for hotspot
 938   $(foreach v, $(JVM_VARIANTS), \
 939     $(eval hotspot-$v-libs-compile-commands: hotspot-$v-gensrc) \
 940     $(foreach m, $(filter java.desktop jdk.hotspot.agent, $(GENSRC_MODULES)), \
 941       $(eval hotspot-$v-libs-compile-commands: $m-gensrc)) \
 942   )
 943 
 944   # For the full JDK compile commands, create all possible generated sources
 945   $(foreach m, $(GENSRC_MODULES), $(eval $m-libs-compile-commands: $m-gensrc))
 946   $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs-compile-commands: $m-java))
 947 
 948   $(COMPILE_COMMANDS_TARGETS_HOTSPOT): clean-compile-commands
 949   $(COMPILE_COMMANDS_TARGETS_JDK): clean-compile-commands
 950   compile-commands-hotspot: $(COMPILE_COMMANDS_TARGETS_HOTSPOT)
 951   compile-commands: $(COMPILE_COMMANDS_TARGETS_HOTSPOT) $(COMPILE_COMMANDS_TARGETS_JDK)
 952 
 953   # The -static-libs targets depend on -java as well as java.base-copy.
 954   $(foreach m, $(filter $(JAVA_MODULES), $(STATIC_LIBS_MODULES)), \
 955     $(eval $m-static-libs: $m-java java.base-copy))
 956 
 957   # Jmods cannot be created until we have the jmod tool ready to run. During
 958   # a normal build we run it from the exploded image, but when cross compiling
 959   # it's run from the buildjdk, which is either created at build time or user
 960   # supplied.
 961   ifeq ($(CREATE_BUILDJDK), true)
 962     ifneq ($(CREATING_BUILDJDK), true)
 963       # When cross compiling and buildjdk is to be created, simply depend on
 964       # creating the buildjdk.
 965       $(JMOD_TARGETS): create-buildjdk
 966       buildtools-modules: create-buildjdk
 967     else
 968       # While actually creating the buildjdk, we need to list the bare
 969       # minimum dependencies needed before running jmod, to avoid building
 970       # more than necessary. This includes:
 971       # * all java modules
 972       # * jdk.jlink-launchers
 973       # * copy jvm.cfg (done in java.base-copy)
 974       # * tzdb.dat (done in java.base-gendata)
 975       # Without all of these jimage, jlink and jmod won't start.
 976       $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): java.base-libs java.base-copy \
 977           java.base-gendata jdk.jlink-launchers java
 978     endif
 979   else ifeq ($(EXTERNAL_BUILDJDK), false)
 980     # The normal non cross compilation usecase needs to wait for the full
 981     # exploded-image to avoid a race with the optimize target.
 982     $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): exploded-image
 983     # The buildtools-modules are used for the exploded-image-optimize target,
 984     # but can be built either using the exploded-image or an external BUILDJDK.
 985     buildtools-modules: exploded-image-base
 986   endif
 987 
 988   # All modules include the main license files from java.base.
 989   $(JMOD_TARGETS): java.base-copy
 990 
 991   zip-security: $(filter jdk.crypto%, $(JAVA_TARGETS))
 992 
 993   ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
 994     ifeq ($(CREATE_BUILDJDK), true)
 995       # If creating a buildjdk, the interim image needs to be based on that.
 996       generate-link-opt-data: create-buildjdk
 997     else ifeq ($(EXTERNAL_BUILDJDK), false)
 998       # If an external buildjdk has been provided, we skip generating an
 999       # interim-image and just use the external buildjdk for generating
1000       # classlist.
1001       generate-link-opt-data: interim-image
1002     endif
1003     generate-link-opt-data: buildtools-jdk
1004 
1005     # The generated classlist needs to go into java.base-jmod.
1006     java.base-jmod jdk.jlink-jmod jdk-image legacy-jre-image: generate-link-opt-data
1007   endif
1008 
1009   symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS)
1010 
1011   static-libs-image: $(STATIC_LIBS_TARGETS)
1012 
1013   bootcycle-images: jdk-image
1014 
1015   docs-jdk-api-javadoc: $(GENSRC_TARGETS)
1016 
1017   docs-javase-api-javadoc: $(GENSRC_TARGETS)
1018 
1019   docs-reference-api-javadoc: $(GENSRC_TARGETS)
1020 
1021   # If not already set, then set the JVM specific docs targets
1022   JVM_DOCS_TARGETS ?= hotspot-$(JVM_VARIANT_MAIN)-gensrc
1023 
1024   # The gensrc steps for hotspot create html spec files.
1025   docs-jdk-specs: $(JVM_DOCS_TARGETS)
1026 
1027   # Tests
1028   test-make: clean-test-make compile-commands
1029 
1030   test-make-compile-commands: compile-commands
1031 
1032   # Declare dependency for all generated test targets
1033   $(foreach t, $(filter-out test-make%, $(ALL_TEST_TARGETS)), $(eval $t: jdk-image test-image))
1034   $(foreach t, $(ALL_EXPLODED_TEST_TARGETS), $(eval $t: exploded-image test-image))
1035 
1036   interim-image: $(INTERIM_JMOD_TARGETS)
1037 
1038   build-test-hotspot-jtreg-native: hotspot-$(JVM_VARIANT_MAIN)-libs
1039   build-test-libtest-jtreg-native: hotspot-$(JVM_VARIANT_MAIN)-libs
1040 
1041 endif
1042 
1043 ################################################################################
1044 # Virtual targets without recipes
1045 
1046 # If not already set, set the JVM specific tools targets
1047 JVM_TOOLS_TARGETS ?= buildtools-hotspot
1048 buildtools: buildtools-langtools interim-langtools \
1049     buildtools-jdk $(JVM_TOOLS_TARGETS)
1050 
1051 # Declare dependencies from hotspot-<variant> targets
1052 $(foreach v, $(JVM_VARIANTS), \
1053   $(eval hotspot-$v: hotspot-$v-gensrc hotspot-$v-libs) \
1054 )
1055 hotspot: $(HOTSPOT_VARIANT_TARGETS)
1056 
1057 # Create targets hotspot-libs and hotspot-gensrc.
1058 $(foreach v, $(JVM_VARIANTS), \
1059   $(eval hotspot-libs: hotspot-$v-libs) \
1060   $(eval hotspot-gensrc: hotspot-$v-gensrc) \
1061 )
1062 
1063 gensrc: $(GENSRC_TARGETS)
1064 
1065 gendata: $(GENDATA_TARGETS)
1066 
1067 copy: $(ALL_COPY_TARGETS)
1068 
1069 java: $(JAVA_TARGETS)
1070 
1071 libs: $(LIBS_TARGETS)
1072 
1073 static-libs: $(STATIC_LIBS_TARGETS)
1074 
1075 launchers: $(LAUNCHER_TARGETS)
1076 
1077 jmods: $(JMOD_TARGETS)
1078 
1079 # Explicitly declare dependency for virtual target jdk.jdwp.agent-gensrc which
1080 # is actually handled by jdk.jdi-gensrc
1081 jdk.jdwp.agent-gensrc: jdk.jdi-gensrc
1082 
1083 # Declare dependencies from <module> to all the individual targets specific
1084 # to that module <module>-*, that are needed for the exploded image.
1085 $(foreach m, $(GENSRC_MODULES), $(eval $m: $m-gensrc))
1086 $(foreach m, $(JAVA_MODULES), $(eval $m: $m-java))
1087 $(foreach m, $(GENDATA_MODULES), $(eval $m: $m-gendata))
1088 $(foreach m, $(LIBS_MODULES), $(eval $m: $m-libs))
1089 $(foreach m, $(LAUNCHER_MODULES), $(eval $m: $m-launchers))
1090 $(foreach m, $(ALL_COPY_MODULES), $(eval $m: $m-copy))
1091 
1092 # Building java.base includes building all of hotspot.
1093 java.base: $(JVM_MAIN_TARGETS)
1094 
1095 demos: demos-jdk
1096 
1097 # The "exploded image" is a locally runnable JDK in $(OUTPUTDIR)/jdk.
1098 exploded-image-base: $(ALL_MODULES)
1099 exploded-image: exploded-image-base release-file
1100 # When cross compiling, no need to optimize the exploded image since it won't
1101 # be runnable on the host platform anyway.
1102 ifneq ($(COMPILE_TYPE), cross)
1103   exploded-image: exploded-image-optimize
1104 endif
1105 
1106 # The runnable-buildjdk target guarantees that the buildjdk is done
1107 # building and ready to be used. The exact set of dependencies it needs
1108 # depends on what kind of buildjdk is used for the current configuration.
1109 runnable-buildjdk:
1110 ifeq ($(CREATE_BUILDJDK), true)
1111   ifneq ($(CREATING_BUILDJDK), true)
1112     runnable-buildjdk: create-buildjdk
1113   endif
1114 else ifeq ($(EXTERNAL_BUILDJDK), false)
1115   runnable-buildjdk: exploded-image
1116 endif
1117 
1118 create-buildjdk: create-buildjdk-interim-image
1119 
1120 docs-jdk-api: docs-jdk-api-javadoc
1121 docs-javase-api: docs-javase-api-javadoc
1122 docs-reference-api: docs-reference-api-javadoc
1123 
1124 # If we're building full docs, we must also generate the module graphs to
1125 # get non-broken api documentation.
1126 ifeq ($(ENABLE_FULL_DOCS), true)
1127   docs-jdk-api: docs-jdk-api-graphs
1128   docs-javase-api: docs-javase-api-graphs
1129   docs-reference-api: docs-reference-api-graphs
1130 
1131   # We must generate javadoc first so we know what graphs are needed
1132   docs-jdk-api-graphs: docs-jdk-api-javadoc
1133   docs-javase-api-graphs: docs-javase-api-javadoc
1134   docs-reference-api-graphs: docs-reference-api-javadoc
1135 endif
1136 
1137 docs-jdk: docs-jdk-api docs-jdk-specs docs-jdk-index
1138 docs-javase: docs-javase-api
1139 docs-reference: docs-reference-api
1140 
1141 # alias for backwards compatibility
1142 docs-javadoc: docs-jdk-api
1143 
1144 mac-bundles: mac-jdk-bundle
1145 
1146 # The $(OUTPUTDIR)/images directory contain the resulting deliverables,
1147 # and in line with this, our targets for creating these are named *-image[s].
1148 
1149 # This target builds the product images, e.g. the JDK image
1150 # (and possibly other, more specific versions)
1151 product-images: jdk-image symbols-image exploded-image
1152 
1153 # This target builds the legacy images, e.g. the legacy JRE image
1154 legacy-images: legacy-jre-image
1155 
1156 # zip-security is actually a bundle, but for now it needs to be considered
1157 # an image until this can be cleaned up properly.
1158 product-images: zip-security
1159 
1160 # The module summary cannot be run when:
1161 # * Cross compiling and building a partial BUILDJDK for the build host
1162 # * An external buildjdk has been supplied since it may not match the
1163 #   module selection of the target jdk
1164 ifneq ($(CREATE_BUILDJDK), true)
1165   ifeq ($(EXTERNAL_BUILDJDK), false)
1166     product-images: generate-summary
1167   endif
1168 endif
1169 
1170 ifeq ($(call isTargetOs, macosx), true)
1171   product-images: mac-jdk-bundle
1172 
1173   legacy-images: mac-legacy-jre-bundle
1174 endif
1175 
1176 # These targets build the various documentation images
1177 docs-jdk-image: docs-jdk
1178 docs-javase-image: docs-javase
1179 docs-reference-image: docs-reference
1180 # The docs-jdk-image is what most users expect to be built
1181 docs-image: docs-jdk-image
1182 all-docs-images: docs-jdk-image docs-javase-image docs-reference-image
1183 
1184 docs-bundles: docs-jdk-bundles
1185 all-docs-bundles: docs-jdk-bundles docs-javase-bundles docs-reference-bundles
1186 
1187 # This target builds the test image
1188 test-image: prepare-test-image test-image-jdk-jtreg-native \
1189     test-image-demos-jdk test-image-libtest-jtreg-native \
1190     test-image-lib-native
1191 
1192 ifneq ($(JVM_TEST_IMAGE_TARGETS), )
1193   # If JVM_TEST_IMAGE_TARGETS is externally defined, use it instead of the
1194   # standard hotspot set of tests.
1195   test-image: $(JVM_TEST_IMAGE_TARGETS)
1196 else
1197   test-image: test-image-hotspot-jtreg-native
1198   ifneq ($(GTEST_FRAMEWORK_SRC), )
1199     test-image: test-image-hotspot-gtest
1200   endif
1201 endif
1202 
1203 ifeq ($(BUILD_FAILURE_HANDLER), true)
1204   test-image: test-image-failure-handler
1205 endif
1206 
1207 ifeq ($(BUILD_JTREG_MAIN_WRAPPER), true)
1208   test-image: test-image-main-wrapper
1209 endif
1210 
1211 ifneq ($(JMH_CORE_JAR), )
1212   test-image: build-microbenchmark
1213 endif
1214 
1215 ################################################################################
1216 
1217 # all-images builds all our deliverables as images.
1218 all-images: product-images test-image all-docs-images
1219 
1220 # all-bundles packages all our deliverables as tar.gz bundles.
1221 all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles
1222 
1223 ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-gensrc gensrc gendata \
1224     copy java libs static-libs launchers jmods \
1225     jdk.jdwp.agent-gensrc $(ALL_MODULES) demos \
1226     exploded-image-base exploded-image runnable-buildjdk \
1227     create-buildjdk docs-jdk-api docs-javase-api docs-reference-api docs-jdk \
1228     docs-javase docs-reference docs-javadoc mac-bundles product-images legacy-images \
1229     docs-image docs-javase-image docs-reference-image all-docs-images \
1230     docs-bundles all-docs-bundles test-image all-images \
1231     all-bundles
1232 
1233 ################################################################################
1234 
1235 # Traditional targets typically run by users.
1236 # These can be considered aliases for the targets now named by a more
1237 # "modern" naming scheme.
1238 default: $(DEFAULT_MAKE_TARGET)
1239 jdk: exploded-image
1240 images: product-images
1241 docs: docs-image
1242 bundles: all-bundles
1243 all: all-images
1244 
1245 ALL_TARGETS += default jdk images docs bundles all
1246 
1247 # Aliases used for running tests.
1248 
1249 # Let "run-test" be an alias for "test"
1250 $(foreach t, $(ALL_NAMED_TESTS), $(eval run-test-$t: test-$t))
1251 RUN_TEST_TARGETS := $(addprefix run-test-, $(ALL_NAMED_TESTS))
1252 
1253 run-test: test
1254 exploded-run-test: exploded-test
1255 
1256 # "make check" is a common idiom for running basic testing
1257 check: test-tier1
1258 
1259 # Keep some old names as aliases
1260 test-hotspot-jtreg: test-hotspot_all
1261 test-hotspot-jtreg-native: test-hotspot_native_sanity
1262 test-hotspot-gtest: exploded-test-gtest
1263 test-jdk-jtreg-native: test-jdk_native_sanity
1264 
1265 ALL_TARGETS += $(RUN_TEST_TARGETS) run-test exploded-run-test check \
1266     test-hotspot-jtreg test-hotspot-jtreg-native test-hotspot-gtest \
1267     test-jdk-jtreg-native
1268 
1269 ################################################################################
1270 ################################################################################
1271 #
1272 # Clean targets
1273 #
1274 ################################################################################
1275 # Clean targets are automatically run serially by the Makefile calling this
1276 # file.
1277 
1278 CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
1279     images make-support test-make bundles buildjdk test-results test-support \
1280     support/images
1281 CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
1282 CLEAN_SUPPORT_DIRS += demos
1283 CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
1284 CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
1285 CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
1286 CLEAN_PHASES := gensrc java native include
1287 CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
1288 CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
1289 # Construct targets of the form clean-$module-$phase
1290 CLEAN_MODULE_PHASE_TARGETS := $(addprefix clean-, $(foreach m, $(ALL_MODULES), \
1291     $(addprefix $m-, $(CLEAN_PHASES))))
1292 
1293 # Remove everything, except the output from configure.
1294 clean: $(CLEAN_DIR_TARGETS)
1295 	($(CD) $(OUTPUTDIR) && $(RM) -r build*.log* compile_commands.json)
1296 	$(ECHO) Cleaned all build artifacts.
1297 
1298 clean-docs:
1299 	$(call CleanDocs)
1300 
1301 clean-compile-commands:
1302 	$(call CleanMakeSupportDir,compile-commands)
1303 
1304 $(CLEAN_DIR_TARGETS):
1305 	$(call CleanDir,$(patsubst clean-%, %, $@))
1306 
1307 $(CLEAN_SUPPORT_DIR_TARGETS):
1308 	$(call CleanSupportDir,$(patsubst clean-%, %, $@))
1309 
1310 $(CLEAN_TEST_TARGETS):
1311 	$(call CleanTest,$(patsubst clean-test-%, %, $@))
1312 
1313 $(CLEAN_PHASE_TARGETS):
1314 	$(call Clean-$(patsubst clean-%,%, $@))
1315 
1316 $(CLEAN_MODULE_TARGETS):
1317 	$(call CleanModule,$(patsubst clean-%, %, $@))
1318 
1319 $(CLEAN_MODULE_PHASE_TARGETS):
1320 	$(call Clean-$(word 3, $(subst -,$(SPACE),$@)), \
1321 	    $(word 2, $(subst -,$(SPACE),$@)))
1322 
1323 # When removing the support dir, we must also remove jdk. Building classes has
1324 # the side effect of generating native headers. The headers end up in support
1325 # while classes and touch files end up in jdk.
1326 clean-support: clean-jdk
1327 
1328 clean-test: clean-test-results clean-test-support
1329 
1330 # When cleaning images, also clean the support/images directory.
1331 clean-images: clean-support/images
1332 
1333 # Remove everything, including configure configuration. If the output
1334 # directory was created by configure and now becomes empty, remove it as well.
1335 dist-clean: clean
1336 	($(CD) $(OUTPUTDIR) && \
1337 	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide \
1338 	    configure.log* build.log*)
1339 	$(if $(filter $(CONF_NAME),$(notdir $(OUTPUTDIR))), \
1340 	  if test "x`$(LS) $(OUTPUTDIR)`" != x; then \
1341 	    $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
1342 	  else \
1343 	    ($(CD) $(TOPDIR) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" \
1344 	        && $(RM) -r $(OUTPUTDIR)) \
1345 	  fi \
1346 	)
1347 	$(ECHO) Cleaned everything, you will have to re-run configure.
1348 
1349 ALL_TARGETS += clean clean-docs clean-compile-commands dist-clean $(CLEAN_DIR_TARGETS) \
1350     $(CLEAN_SUPPORT_DIR_TARGETS) $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) \
1351     $(CLEAN_MODULE_TARGETS) $(CLEAN_MODULE_PHASE_TARGETS)
1352 
1353 ################################################################################
1354 # Declare *-only targets for each normal target
1355 $(foreach t, $(ALL_TARGETS), $(eval $(t)-only: $(t)))
1356 
1357 ALL_TARGETS += $(addsuffix -only, $(filter-out dist-clean clean%, $(ALL_TARGETS)))
1358 
1359 ################################################################################
1360 
1361 # The following targets are intentionally not added to ALL_TARGETS since they
1362 # are internal only, to support Init.gmk.
1363 
1364 print-targets:
1365 	  @$(ECHO) $(sort $(ALL_TARGETS))
1366 
1367 print-modules:
1368 	  @$(ECHO) $(sort $(ALL_MODULES))
1369 
1370 print-tests:
1371 	  @$(ECHO) $(sort $(ALL_NAMED_TESTS))
1372 
1373 create-main-targets-include:
1374 	  $(call LogInfo, Generating main target list)
1375 	  @$(ECHO) ALL_MAIN_TARGETS := $(sort $(ALL_TARGETS)) > \
1376 	      $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk
1377 
1378 ################################################################################
1379 # Hook to include the corresponding custom file, if present.
1380 $(eval $(call IncludeCustomExtension, Main-post.gmk))
1381 
1382 .PHONY: $(ALL_TARGETS)
1383 
1384 FRC: # Force target