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