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