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