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