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