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