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