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