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