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