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