jdk

Форк
0
/
Main.gmk 
1450 строк · 47.6 Кб
1
#
2
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
#
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.  Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
10
#
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
16
#
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
#
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
23
# questions.
24
#
25

26
################################################################################
27
# This is the main makefile containing most actual top level targets. It needs
28
# to be called with a SPEC file defined.
29
################################################################################
30

31
# Declare default target
32
default:
33

34
ifeq ($(wildcard $(SPEC)),)
35
  $(error Main.gmk needs SPEC set to a proper spec.gmk)
36
endif
37

38
# Now load the spec
39
include $(SPEC)
40

41
# Load the vital tools for all the makefiles.
42
include $(TOPDIR)/make/common/MakeBase.gmk
43
include $(TOPDIR)/make/common/Modules.gmk
44
include $(TOPDIR)/make/common/FindTests.gmk
45

46
include $(TOPDIR)/make/MainSupport.gmk
47

48
# Are we requested to ignore dependencies?
49
ifneq ($(findstring -only, $(MAKECMDGOALS)), )
50
  DEPS := none
51
endif
52

53
# Declare ALL_TARGETS as an immediate variable. This variable is a list of all
54
# valid top level targets. It's used to declare them all as PHONY and to
55
# generate the -only targets.
56
ALL_TARGETS :=
57

58
# Hook to include the corresponding custom file, if present.
59
$(eval $(call IncludeCustomExtension, Main.gmk))
60

61
# All modules for the current target platform.
62
ALL_MODULES := $(call FindAllModules)
63

64
################################################################################
65
################################################################################
66
#
67
# Recipes for all targets. Only recipes, dependencies are declared later.
68
#
69
################################################################################
70

71
################################################################################
72
# Interim/build tools targets, compiling tools used during the build
73

74
$(eval $(call SetupTarget, buildtools-langtools, \
75
    MAKEFILE := ToolsLangtools, \
76
))
77

78
$(eval $(call SetupTarget, interim-langtools, \
79
    MAKEFILE := CompileInterimLangtools, \
80
))
81

82
$(eval $(call SetupTarget, interim-tzdb, \
83
    MAKEFILE := CopyInterimTZDB, \
84
))
85

86
$(eval $(call SetupTarget, buildtools-jdk, \
87
    MAKEFILE := CompileToolsJdk, \
88
    DEPS := interim-langtools interim-tzdb, \
89
))
90

91
$(eval $(call SetupTarget, buildtools-modules, \
92
    MAKEFILE := CompileModuleTools, \
93
))
94

95
$(eval $(call SetupTarget, buildtools-hotspot, \
96
    MAKEFILE := CompileToolsHotspot, \
97
))
98

99
################################################################################
100
# Gensrc targets, generating source before java compilation can be done
101
#
102
$(eval $(call DeclareRecipesForPhase, GENSRC, \
103
    TARGET_SUFFIX := gensrc-src, \
104
    FILE_PREFIX := Gensrc, \
105
    CHECK_MODULES := $(ALL_MODULES), \
106
))
107

108
$(foreach m, $(GENSRC_MODULES), $(eval $m-gensrc: $m-gensrc-src))
109

110
LANGTOOLS_GENSRC_TARGETS := $(filter $(addsuffix -%, $(LANGTOOLS_MODULES)), $(GENSRC_TARGETS))
111
INTERIM_LANGTOOLS_GENSRC_TARGETS := $(filter $(addsuffix -%, \
112
    $(INTERIM_LANGTOOLS_BASE_MODULES)), $(GENSRC_TARGETS))
113
HOTSPOT_GENSRC_TARGETS := $(filter $(addsuffix -%, $(HOTSPOT_MODULES)), $(GENSRC_TARGETS))
114
JDK_GENSRC_TARGETS := $(filter-out $(LANGTOOLS_GENSRC_TARGETS) \
115
    $(HOTSPOT_GENSRC_TARGETS), $(GENSRC_TARGETS))
116

117
GENSRC_MODULEINFO_MODULES := $(ALL_MODULES)
118
GENSRC_MODULEINFO_TARGETS := $(addsuffix -gensrc-moduleinfo, \
119
    $(GENSRC_MODULEINFO_MODULES))
120

121
GENSRC_MODULES := $(GENSRC_MODULEINFO_MODULES)
122
GENSRC_TARGETS += $(sort $(GENSRC_MODULEINFO_TARGETS) \
123
    $(addsuffix -gensrc, $(GENSRC_MODULES)))
124

125
define DeclareModuleInfoRecipe
126
  $1-gensrc-moduleinfo:
127
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
128
	    -f common/modules/GensrcModuleInfo.gmk MODULE=$1)
129

130
  $1-gensrc: $1-gensrc-moduleinfo
131
endef
132

133
$(foreach m, $(GENSRC_MODULEINFO_MODULES), $(eval $(call DeclareModuleInfoRecipe,$m)))
134

135
ALL_TARGETS += $(GENSRC_TARGETS)
136

137
################################################################################
138
# Generate data targets
139
$(eval $(call DeclareRecipesForPhase, GENDATA, \
140
    TARGET_SUFFIX := gendata, \
141
    FILE_PREFIX := Gendata, \
142
    CHECK_MODULES := $(ALL_MODULES), \
143
))
144

145
ALL_TARGETS += $(GENDATA_TARGETS)
146

147
################################################################################
148
# Copy files targets
149
$(eval $(call DeclareRecipesForPhase, COPY, \
150
    TARGET_SUFFIX := copy, \
151
    FILE_PREFIX := Copy, \
152
    CHECK_MODULES := $(ALL_MODULES), \
153
))
154

155
ALL_COPY_MODULES += $(COPY_MODULES)
156
ALL_COPY_TARGETS += $(COPY_TARGETS)
157

158
IMPORT_COPY_MODULES := $(call FindImportedModules)
159
IMPORT_COPY_TARGETS := $(addsuffix -copy, $(IMPORT_COPY_MODULES))
160
ALL_COPY_MODULES += $(IMPORT_COPY_MODULES)
161
ALL_COPY_TARGETS += $(IMPORT_COPY_TARGETS)
162

163
define DeclareImportCopyRecipe
164
  $1-copy:
165
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
166
	    -f CopyImportModules.gmk MODULE=$1)
167
endef
168

169
$(foreach m, $(IMPORT_COPY_MODULES), $(eval $(call DeclareImportCopyRecipe,$m)))
170

171
ALL_TARGETS += $(ALL_COPY_TARGETS)
172

173
################################################################################
174
# Targets for compiling all java modules.
175
JAVA_MODULES := $(ALL_MODULES)
176
JAVA_TARGETS := $(addsuffix -java, $(JAVA_MODULES))
177

178
define DeclareCompileJavaRecipe
179
  $1-java:
180
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
181
	$(patsubst %,-I%/modules/$1,$(PHASE_MAKEDIRS)) \
182
	    -f CompileJavaModules.gmk MODULE=$1)
183
endef
184

185
$(foreach m, $(JAVA_MODULES), $(eval $(call DeclareCompileJavaRecipe,$m)))
186

187
ALL_TARGETS += $(JAVA_TARGETS)
188

189
################################################################################
190
# Targets for compiling native libraries
191
$(eval $(call DeclareRecipesForPhase, LIBS, \
192
    TARGET_SUFFIX := libs, \
193
    FILE_PREFIX := Lib, \
194
    CHECK_MODULES := $(ALL_MODULES), \
195
))
196

197
ALL_TARGETS += $(LIBS_TARGETS)
198

199
################################################################################
200
# Targets for compiling static versions of certain native libraries. These do
201
# not end up in the jmods or the normal JDK image, but are instead bundled into
202
# a special deliverable.
203
$(eval $(call DeclareRecipesForPhase, STATIC_LIBS, \
204
    TARGET_SUFFIX := static-libs, \
205
    FILE_PREFIX := Lib, \
206
    CHECK_MODULES := $(ALL_MODULES), \
207
    EXTRA_ARGS := STATIC_LIBS=true, \
208
))
209

210
ALL_TARGETS += $(STATIC_LIBS_TARGETS)
211

212
################################################################################
213
# Targets for compiling native executables
214
$(eval $(call DeclareRecipesForPhase, LAUNCHER, \
215
    TARGET_SUFFIX := launchers, \
216
    FILE_PREFIX := Launcher, \
217
    CHECK_MODULES := $(ALL_MODULES), \
218
))
219

220
ALL_TARGETS += $(LAUNCHER_TARGETS)
221

222
################################################################################
223
# Build hotspot target
224

225
HOTSPOT_VARIANT_TARGETS := $(addprefix hotspot-, $(JVM_VARIANTS))
226
HOTSPOT_VARIANT_GENSRC_TARGETS := $(addsuffix -gensrc, $(HOTSPOT_VARIANT_TARGETS))
227
HOTSPOT_VARIANT_LIBS_TARGETS := $(addsuffix -libs, $(HOTSPOT_VARIANT_TARGETS))
228
HOTSPOT_VARIANT_STATIC_LIBS_TARGETS := $(addsuffix -static-libs, $(HOTSPOT_VARIANT_TARGETS))
229

230
define DeclareHotspotGensrcRecipe
231
  hotspot-$1-gensrc:
232
	$$(call LogInfo, Building JVM variant '$1' with features '$(JVM_FEATURES_$1)')
233
	+($(CD) $(TOPDIR)/make/hotspot && $(MAKE) $(MAKE_ARGS) -f gensrc/GenerateSources.gmk \
234
	    JVM_VARIANT=$1)
235
endef
236

237
$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotGensrcRecipe,$v)))
238

239
define DeclareHotspotLibsRecipe
240
  hotspot-$1-libs:
241
	+($(CD) $(TOPDIR)/make/hotspot && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibraries.gmk \
242
	    JVM_VARIANT=$1)
243
endef
244

245
$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotLibsRecipe,$v)))
246

247
define DeclareHotspotStaticLibsRecipe
248
  hotspot-$1-static-libs:
249
	+($(CD) $(TOPDIR)/make/hotspot && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibraries.gmk \
250
	    JVM_VARIANT=$1 STATIC_LIBS=true)
251
endef
252

253
$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotStaticLibsRecipe,$v)))
254

255
$(eval $(call SetupTarget, hotspot-ide-project, \
256
    MAKEFILE := ide/visualstudio/hotspot/CreateVSProject, \
257
    DEPS := hotspot exploded-image, \
258
    ARGS := -I$(TOPDIR)/make/hotspot, \
259
))
260

261
$(eval $(call SetupTarget, eclipse-java-env, \
262
    MAKEFILE := ide/eclipse/CreateWorkspace, \
263
    ARGS := --always-make WORKSPACE=java, \
264
))
265

266
$(eval $(call SetupTarget, eclipse-hotspot-env, \
267
    MAKEFILE := ide/eclipse/CreateWorkspace, \
268
    ARGS := --always-make WORKSPACE=hotspot, \
269
))
270

271
$(eval $(call SetupTarget, eclipse-native-env, \
272
    MAKEFILE := ide/eclipse/CreateWorkspace, \
273
    ARGS := --always-make WORKSPACE=native, \
274
))
275

276
$(eval $(call SetupTarget, eclipse-mixed-env, \
277
    MAKEFILE := ide/eclipse/CreateWorkspace, \
278
    ARGS := --always-make, \
279
))
280

281
ALL_TARGETS += $(HOTSPOT_VARIANT_TARGETS) $(HOTSPOT_VARIANT_GENSRC_TARGETS) \
282
    $(HOTSPOT_VARIANT_LIBS_TARGETS) $(HOTSPOT_VARIANT_STATIC_LIBS_TARGETS)
283

284
################################################################################
285
# Help and user support
286

287
$(eval $(call SetupTarget, doctor, \
288
    MAKEFILE := Doctor, \
289
))
290

291
################################################################################
292
# Generate libs and launcher targets for creating compile_commands.json fragments
293
define DeclareCompileCommandsRecipe
294
  $1-compile-commands:
295
	$$(call LogInfo, Generating compile_commands.json fragments for $1)
296
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Main.gmk $1-only \
297
	    GENERATE_COMPILE_COMMANDS_ONLY=true)
298

299
  COMPILE_COMMANDS_TARGETS_$2 += $1-compile-commands
300
endef
301

302
$(foreach t, $(HOTSPOT_VARIANT_LIBS_TARGETS), \
303
  $(eval $(call DeclareCompileCommandsRecipe,$t,HOTSPOT)) \
304
)
305

306
$(foreach t, $(LIBS_TARGETS) $(LAUNCHER_TARGETS), \
307
  $(eval $(call DeclareCompileCommandsRecipe,$t,JDK)) \
308
)
309

310
$(eval $(call SetupTarget, compile-commands, \
311
    MAKEFILE := CompileCommands, \
312
))
313

314
$(eval $(call SetupTarget, compile-commands-hotspot, \
315
    MAKEFILE := CompileCommands, \
316
))
317

318
ALL_TARGETS += $(COMPILE_COMMANDS_TARGETS_HOTSPOT) $(COMPILE_COMMANDS_TARGETS_JDK)
319

320
################################################################################
321
# VS Code projects
322

323
$(eval $(call SetupTarget, vscode-project, \
324
    MAKEFILE := ide/vscode/hotspot/CreateVSCodeProject, \
325
    ARGS := VSCODE_INDEXER=cpptools, \
326
    DEPS := compile-commands, \
327
))
328

329
$(eval $(call SetupTarget, vscode-project-clangd, \
330
    MAKEFILE := ide/vscode/hotspot/CreateVSCodeProject, \
331
    ARGS := VSCODE_INDEXER=clangd, \
332
    DEPS := compile-commands, \
333
))
334

335
$(eval $(call SetupTarget, vscode-project-rtags, \
336
    MAKEFILE := ide/vscode/hotspot/CreateVSCodeProject, \
337
    ARGS := VSCODE_INDEXER=rtags, \
338
    DEPS := compile-commands, \
339
))
340

341
$(eval $(call SetupTarget, vscode-project-ccls, \
342
    MAKEFILE := ide/vscode/hotspot/CreateVSCodeProject, \
343
    ARGS := VSCODE_INDEXER=ccls, \
344
    DEPS := compile-commands, \
345
))
346

347
################################################################################
348
# Build demos targets
349

350
# The demos are currently linking to libjvm and libjava, just like all other
351
# jdk libs, even though they don't need to. To avoid warnings, make sure they
352
# aren't built until after libjava and libjvm are available to link to.
353
$(eval $(call SetupTarget, demos-jdk, \
354
    MAKEFILE := CompileDemos, \
355
    DEPS := java.base-libs exploded-image buildtools-jdk, \
356
))
357

358
$(eval $(call SetupTarget, test-image-demos-jdk, \
359
    MAKEFILE := CompileDemos, \
360
    TARGET := images, \
361
    DEPS := demos-jdk, \
362
))
363

364
################################################################################
365
# Jigsaw specific data and analysis targets.
366

367
$(eval $(call SetupTarget, generate-summary, \
368
    MAKEFILE := GenerateModuleSummary, \
369
    DEPS := jmods buildtools-modules runnable-buildjdk, \
370
))
371

372
################################################################################
373
# Jmod targets
374

375
JMOD_MODULES := $(ALL_MODULES)
376
JMOD_TARGETS := $(addsuffix -jmod, $(JMOD_MODULES))
377

378
define DeclareJmodRecipe
379
  $1-jmod:
380
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
381
	    $(patsubst %,-I%/modules/$1,$(PHASE_MAKEDIRS)) \
382
	    -f CreateJmods.gmk MODULE=$1)
383
endef
384

385
$(foreach m, $(JMOD_MODULES), $(eval $(call DeclareJmodRecipe,$m)))
386

387
ALL_TARGETS += $(JMOD_TARGETS)
388

389
################################################################################
390
# Images targets
391

392
$(eval $(call SetupTarget, store-source-revision, \
393
    MAKEFILE := SourceRevision, \
394
    TARGET := store-source-revision, \
395
))
396

397
$(eval $(call SetupTarget, create-source-revision-tracker, \
398
    MAKEFILE := SourceRevision, \
399
    TARGET := create-source-revision-tracker, \
400
))
401

402
BOOTCYCLE_TARGET := product-images
403
bootcycle-images:
404
        ifneq ($(COMPILE_TYPE), cross)
405
	  $(call LogWarn, Boot cycle build step 2: Building a new JDK image using previously built image)
406
	  $(call MakeDir, $(OUTPUTDIR)/bootcycle-build)
407
	  +$(MAKE) $(MAKE_ARGS) -f $(TOPDIR)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
408
	      LOG_PREFIX="[bootcycle] " JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
409
        else
410
	  $(call LogWarn, Boot cycle build disabled when cross compiling)
411
        endif
412

413
$(eval $(call SetupTarget, zip-security, \
414
    MAKEFILE := ZipSecurity, \
415
    DEPS := buildtools-jdk java.base-java java.security.jgss-java java.security.jgss-libs, \
416
))
417

418
$(eval $(call SetupTarget, zip-source, \
419
    MAKEFILE := ZipSource, \
420
    DEPS := buildtools-jdk gensrc, \
421
))
422

423
$(eval $(call SetupTarget, jrtfs-jar, \
424
    MAKEFILE := JrtfsJar, \
425
    DEPS := interim-langtools, \
426
))
427

428
$(eval $(call SetupTarget, jdk-image, \
429
    MAKEFILE := Images, \
430
    TARGET := jdk, \
431
    DEPS := jmods zip-source demos release-file, \
432
))
433

434
$(eval $(call SetupTarget, legacy-jre-image, \
435
    MAKEFILE := Images, \
436
    TARGET := jre, \
437
    DEPS := jmods release-file, \
438
))
439

440
$(eval $(call SetupTarget, symbols-image, \
441
    MAKEFILE := Images, \
442
    TARGET := symbols, \
443
))
444

445
$(eval $(call SetupTarget, static-libs-image, \
446
    MAKEFILE := StaticLibsImage, \
447
    TARGET := static-libs-image, \
448
))
449

450
$(eval $(call SetupTarget, static-libs-graal-image, \
451
    MAKEFILE := StaticLibsImage, \
452
    TARGET := static-libs-graal-image, \
453
))
454

455
$(eval $(call SetupTarget, mac-jdk-bundle, \
456
    MAKEFILE := MacBundles, \
457
    TARGET := jdk-bundle, \
458
    DEPS := jdk-image, \
459
))
460

461
$(eval $(call SetupTarget, mac-legacy-jre-bundle, \
462
    MAKEFILE := MacBundles, \
463
    TARGET := jre-bundle, \
464
    DEPS := legacy-jre-image, \
465
))
466

467
$(eval $(call SetupTarget, release-file, \
468
    MAKEFILE := ReleaseFile, \
469
    DEPS := create-source-revision-tracker, \
470
))
471

472
$(eval $(call SetupTarget, exploded-image-optimize, \
473
    MAKEFILE := ExplodedImageOptimize, \
474
    DEPS := java copy gendata java.base-libs java.base-launchers \
475
        buildtools-modules, \
476
))
477

478
$(eval $(call SetupTarget, graal-builder-image, \
479
    MAKEFILE := GraalBuilderImage, \
480
    DEPS := jdk-image static-libs-graal-image, \
481
))
482

483
ifeq ($(JCOV_ENABLED), true)
484
  $(eval $(call SetupTarget, jcov-image, \
485
      MAKEFILE := Coverage, \
486
      TARGET := jcov-image, \
487
      DEPS := jdk-image, \
488
  ))
489
endif
490

491
ALL_TARGETS += bootcycle-images
492

493
################################################################################
494
# Docs targets
495

496
# If building full docs, to complete docs-*-api we need both the javadoc and
497
# graphs targets.
498
$(eval $(call SetupTarget, docs-jdk-api-javadoc, \
499
    MAKEFILE := Docs, \
500
    TARGET := docs-jdk-api-javadoc, \
501
))
502

503
$(eval $(call SetupTarget, docs-jdk-api-graphs, \
504
    MAKEFILE := Docs, \
505
    TARGET := docs-jdk-api-graphs, \
506
    DEPS := buildtools-modules runnable-buildjdk, \
507
))
508

509
$(eval $(call SetupTarget, docs-javase-api-javadoc, \
510
    MAKEFILE := Docs, \
511
    TARGET := docs-javase-api-javadoc, \
512
))
513

514
$(eval $(call SetupTarget, docs-javase-api-graphs, \
515
    MAKEFILE := Docs, \
516
    TARGET := docs-javase-api-graphs, \
517
    DEPS := buildtools-modules runnable-buildjdk, \
518
))
519

520
$(eval $(call SetupTarget, docs-reference-api-javadoc, \
521
    MAKEFILE := Docs, \
522
    TARGET := docs-reference-api-javadoc, \
523
))
524

525
$(eval $(call SetupTarget, docs-reference-api-graphs, \
526
    MAKEFILE := Docs, \
527
    TARGET := docs-reference-api-graphs, \
528
    DEPS := buildtools-modules runnable-buildjdk, \
529
))
530

531
# The gensrc steps for jdk.jdi create html spec files.
532
$(eval $(call SetupTarget, docs-jdk-specs, \
533
    MAKEFILE := Docs, \
534
    TARGET := docs-jdk-specs, \
535
    DEPS := buildtools-jdk jdk.jdi-gensrc docs-jdk-index, \
536
))
537

538
$(eval $(call SetupTarget, docs-jdk-index, \
539
    MAKEFILE := Docs, \
540
    TARGET := docs-jdk-index, \
541
))
542

543
$(eval $(call SetupTarget, docs-zip, \
544
    MAKEFILE := Docs, \
545
    TARGET := docs-zip, \
546
    DEPS :=  docs-jdk buildtools-jdk, \
547
))
548

549
$(eval $(call SetupTarget, docs-specs-zip, \
550
    MAKEFILE := Docs, \
551
    TARGET := docs-specs-zip, \
552
    DEPS := docs-jdk-specs buildtools-jdk, \
553
))
554

555
$(eval $(call SetupTarget, update-build-docs, \
556
    MAKEFILE := UpdateBuildDocs, \
557
))
558

559
$(eval $(call SetupTarget, update-x11wrappers, \
560
    MAKEFILE := UpdateX11Wrappers, \
561
    DEPS := java.base-copy buildtools-jdk, \
562
))
563

564
ifneq ($(HSDIS_BACKEND), none)
565
  $(eval $(call SetupTarget, build-hsdis, \
566
      MAKEFILE := Hsdis, \
567
      TARGET := build, \
568
  ))
569

570
  $(eval $(call SetupTarget, install-hsdis, \
571
      MAKEFILE := Hsdis, \
572
      TARGET := install, \
573
      DEPS := jdk-image, \
574
  ))
575
endif
576

577
################################################################################
578
# Cross compilation support
579

580
ifeq ($(CREATING_BUILDJDK), true)
581
  # This target is only called by the recursive call below.
582
  create-buildjdk-interim-image-helper: interim-image jdk.jlink-launchers \
583
      java.base-copy jdk.jdeps-launchers jdk.compiler-launchers
584
endif
585

586
BUILDJDK_MODULES := $(sort $(foreach m, jdk.jlink jdk.compiler \
587
    $(INTERIM_IMAGE_MODULES), $(call FindTransitiveDepsForModule, $m) $m))
588

589
$(eval $(call SetupTarget, create-buildjdk-interim-image, \
590
    MAKEFILE := Main, \
591
    TARGET := create-buildjdk-interim-image-helper, \
592
    ARGS := SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
593
        HOTSPOT_SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
594
        CREATING_BUILDJDK=true \
595
        LOG_PREFIX="[buildjdk] " \
596
        JAVA_MODULES="$(BUILDJDK_MODULES)", \
597
))
598

599
################################################################################
600
# The interim-image is a small jlinked image that is used to generate artifacts
601
# at build time for use when linking the real images.
602

603
INTERIM_JMOD_TARGETS := $(addsuffix -interim-jmod, $(INTERIM_IMAGE_MODULES))
604

605
define DeclareInterimJmodRecipe
606
  $1-interim-jmod:
607
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
608
	    MODULE=$1 \
609
	    JMODS_DIR=$(INTERIM_JMODS_DIR) \
610
	    JMODS_SUPPORT_DIR=$(INTERIM_JMODS_DIR)/support \
611
	    INTERIM_JMOD=true \
612
	)
613
endef
614

615
$(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $(call DeclareInterimJmodRecipe,$m)))
616

617
$(eval $(call SetupTarget, interim-image, \
618
    MAKEFILE := InterimImage, \
619
))
620

621
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
622
  $(eval $(call SetupTarget, generate-link-opt-data, \
623
      MAKEFILE := GenerateLinkOptData, \
624
  ))
625
endif
626

627
################################################################################
628
# Generate test names for all JTReg test groups
629
#
630

631
define DeclareRunTestRecipe
632
  test-$1:
633
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk \
634
	    TEST="$1")
635

636
  exploded-test-$1:
637
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk \
638
	    TEST="$1" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
639
endef
640

641
# ALL_NAMED_TESTS is defined in FindTests.gmk
642
$(foreach t, $(ALL_NAMED_TESTS), $(eval $(call DeclareRunTestRecipe,$t)))
643
ALL_TEST_TARGETS := $(addprefix test-, $(ALL_NAMED_TESTS))
644

645
# We only support the "exploded-test-gtest" shortcut
646
ALL_EXPLODED_TESTS := gtest
647
ALL_EXPLODED_TEST_TARGETS := $(addprefix exploded-test-, $(ALL_EXPLODED_TESTS))
648

649
ALL_TARGETS += $(ALL_TEST_TARGETS) $(ALL_EXPLODED_TEST_TARGETS)
650

651
################################################################################
652
# Build tests and microbenchmarks
653
#
654

655
$(eval $(call SetupTarget, prepare-test-image, \
656
    MAKEFILE := TestImage, \
657
    TARGET := prepare-test-image, \
658
))
659

660
$(eval $(call SetupTarget, build-test-hotspot-jtreg-native, \
661
    MAKEFILE := test/JtregNativeHotspot, \
662
    TARGET := build-test-hotspot-jtreg-native, \
663
    DEPS := buildtools-jdk, \
664
))
665

666
$(eval $(call SetupTarget, test-image-hotspot-jtreg-native, \
667
    MAKEFILE := test/JtregNativeHotspot, \
668
    TARGET := test-image-hotspot-jtreg-native, \
669
    DEPS := build-test-hotspot-jtreg-native, \
670
))
671

672
$(eval $(call SetupTarget, build-test-jdk-jtreg-native, \
673
    MAKEFILE := test/JtregNativeJdk, \
674
    TARGET := build-test-jdk-jtreg-native, \
675
    DEPS := buildtools-jdk java.base-libs, \
676
))
677

678
$(eval $(call SetupTarget, test-image-jdk-jtreg-native, \
679
    MAKEFILE := test/JtregNativeJdk, \
680
    TARGET := test-image-jdk-jtreg-native, \
681
    DEPS := build-test-jdk-jtreg-native, \
682
))
683

684
# Native files needed by the testlib
685
$(eval $(call SetupTarget, build-test-lib-native, \
686
    MAKEFILE := test/BuildTestLibNative, \
687
    TARGET := build-test-lib-native, \
688
    DEPS := buildtools-jdk java.base-libs, \
689
))
690

691
$(eval $(call SetupTarget, test-image-lib-native, \
692
    MAKEFILE := test/BuildTestLibNative, \
693
    TARGET := test-image-lib-native, \
694
    DEPS := build-test-lib-native, \
695
))
696

697
# Native files needed when testing the testlib itself
698
$(eval $(call SetupTarget, build-test-libtest-jtreg-native, \
699
    MAKEFILE := test/JtregNativeLibTest, \
700
    TARGET := build-test-libtest-jtreg-native, \
701
    DEPS := buildtools-jdk, \
702
))
703

704
$(eval $(call SetupTarget, test-image-libtest-jtreg-native, \
705
    MAKEFILE := test/JtregNativeLibTest, \
706
    TARGET := test-image-libtest-jtreg-native, \
707
    DEPS := build-test-libtest-jtreg-native, \
708
))
709

710
ifneq ($(GTEST_FRAMEWORK_SRC), )
711
  $(eval $(call SetupTarget, test-image-hotspot-gtest, \
712
      MAKEFILE := hotspot/test/GtestImage, \
713
      DEPS := hotspot, \
714
  ))
715
endif
716

717
$(eval $(call SetupTarget, build-test-lib, \
718
    MAKEFILE := test/BuildTestLib, \
719
    TARGET := build-test-lib, \
720
    DEPS := exploded-image, \
721
))
722

723
$(eval $(call SetupTarget, test-image-lib, \
724
    MAKEFILE := test/BuildTestLib, \
725
    TARGET := test-image-lib, \
726
    DEPS := build-test-lib, \
727
))
728

729
ifeq ($(BUILD_FAILURE_HANDLER), true)
730
  # Builds the failure handler jtreg extension
731
  $(eval $(call SetupTarget, build-test-failure-handler, \
732
      MAKEFILE := test/BuildFailureHandler, \
733
      TARGET := build, \
734
      DEPS := interim-langtools, \
735
  ))
736

737
  # Copies the failure handler jtreg extension into the test image
738
  $(eval $(call SetupTarget, test-image-failure-handler, \
739
      MAKEFILE := test/BuildFailureHandler, \
740
      TARGET := images, \
741
      DEPS := build-test-failure-handler, \
742
  ))
743
endif
744

745
ifeq ($(BUILD_JTREG_TEST_THREAD_FACTORY), true)
746
  # Builds the test thread factory jtreg extension
747
  $(eval $(call SetupTarget, build-test-test-thread-factory, \
748
      MAKEFILE := test/BuildJtregTestThreadFactory, \
749
      TARGET := build, \
750
      DEPS := interim-langtools exploded-image, \
751
  ))
752

753
  # Copies the jtreg test thread factory into the test image
754
  $(eval $(call SetupTarget, test-image-test-thread-factory, \
755
      MAKEFILE := test/BuildJtregTestThreadFactory, \
756
      TARGET := images, \
757
      DEPS := build-test-test-thread-factory, \
758
  ))
759
endif
760

761
$(eval $(call SetupTarget, build-microbenchmark, \
762
    MAKEFILE := test/BuildMicrobenchmark, \
763
    DEPS := interim-langtools exploded-image build-test-lib, \
764
))
765

766
################################################################################
767
# Run tests
768

769
$(eval $(call SetupTarget, test, \
770
    MAKEFILE := RunTests, \
771
    ARGS := TEST="$(TEST)", \
772
    DEPS := jdk-image test-image, \
773
))
774

775
$(eval $(call SetupTarget, exploded-test, \
776
    MAKEFILE := RunTests, \
777
    ARGS := TEST="$(TEST)" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR), \
778
    DEPS := exploded-image test-image, \
779
))
780

781
ifeq ($(JCOV_ENABLED), true)
782
  $(eval $(call SetupTarget, jcov-test, \
783
      MAKEFILE := RunTests, \
784
      ARGS := TEST="$(TEST)" TEST_OPTS_JCOV=true, \
785
      DEPS := jcov-image test-image, \
786
  ))
787
endif
788

789
################################################################################
790
# Bundles
791

792
$(eval $(call SetupTarget, product-bundles, \
793
    MAKEFILE := Bundles, \
794
    TARGET := product-bundles, \
795
    DEPS := product-images, \
796
))
797

798
$(eval $(call SetupTarget, legacy-bundles, \
799
    MAKEFILE := Bundles, \
800
    TARGET := legacy-bundles, \
801
    DEPS := legacy-images, \
802
))
803

804
$(eval $(call SetupTarget, test-bundles, \
805
    MAKEFILE := Bundles, \
806
    TARGET := test-bundles, \
807
    DEPS := test-image, \
808
))
809

810
$(eval $(call SetupTarget, docs-jdk-bundles, \
811
    MAKEFILE := Bundles, \
812
    TARGET := docs-jdk-bundles, \
813
    DEPS := docs-image, \
814
))
815

816
$(eval $(call SetupTarget, docs-javase-bundles, \
817
    MAKEFILE := Bundles, \
818
    TARGET := docs-javase-bundles, \
819
    DEPS := docs-javase-image, \
820
))
821

822
$(eval $(call SetupTarget, docs-reference-bundles, \
823
    MAKEFILE := Bundles, \
824
    TARGET := docs-reference-bundles, \
825
    DEPS := docs-reference-image, \
826
))
827

828
$(eval $(call SetupTarget, static-libs-bundles, \
829
    MAKEFILE := Bundles, \
830
    TARGET := static-libs-bundles, \
831
    DEPS := static-libs-image, \
832
))
833

834
$(eval $(call SetupTarget, static-libs-graal-bundles, \
835
    MAKEFILE := Bundles, \
836
    TARGET := static-libs-graal-bundles, \
837
    DEPS := static-libs-graal-image, \
838
))
839

840
ifeq ($(JCOV_ENABLED), true)
841
  $(eval $(call SetupTarget, jcov-bundles, \
842
      MAKEFILE := Bundles, \
843
      TARGET := jcov-bundles, \
844
      DEPS := jcov-image, \
845
  ))
846
endif
847

848
################################################################################
849
#
850
# Dependency declarations between targets.
851
#
852
# These are declared in two groups. First all dependencies between targets that
853
# have recipes above as these dependencies may be disabled. Then the aggregator
854
# targets that do not have recipes of their own, which will never have their
855
# dependencies disabled.
856
#
857
################################################################################
858
# Targets with recipes above
859

860
# If running an *-only target, parallel execution and dependencies between
861
# recipe targets are disabled. This makes it possible to run a select set of
862
# recipe targets in order. It's the responsibility of the user to make sure
863
# all prerequisites are fulfilled.
864
ifeq ($(DEPS), none)
865
  .NOTPARALLEL:
866
else
867
  $(LANGTOOLS_GENSRC_TARGETS): buildtools-langtools
868

869
  interim-langtools: $(INTERIM_LANGTOOLS_GENSRC_TARGETS)
870

871
  $(HOTSPOT_GENSRC_TARGETS): interim-langtools buildtools-hotspot
872

873
  $(JDK_GENSRC_TARGETS): interim-langtools buildtools-jdk
874

875
  $(GENSRC_MODULEINFO_TARGETS): buildtools-jdk
876

877
  $(GENDATA_TARGETS): interim-langtools buildtools-jdk
878

879
  $(JAVA_TARGETS): interim-langtools
880

881
  # Declare dependencies between hotspot-<variant>* targets
882
  $(foreach v, $(JVM_VARIANTS), \
883
      $(eval hotspot-$v-gensrc: java.base-copy buildtools-hotspot) \
884
      $(eval hotspot-$v-libs: hotspot-$v-gensrc java.base-copy) \
885
      $(eval hotspot-$v-static-libs: hotspot-$v-gensrc java.base-copy) \
886
  )
887

888
  # If not already set, set the JVM variant target so that the JVM will be built.
889
  JVM_MAIN_LIB_TARGETS ?= hotspot-$(JVM_VARIANT_MAIN)-libs
890
  JVM_MAIN_GENSRC_TARGETS ?= hotspot-$(JVM_VARIANT_MAIN)-gensrc
891

892
  # Building one JVM variant is enough to start building the other libs
893
  $(LIBS_TARGETS): $(JVM_MAIN_LIB_TARGETS)
894

895
  # Static libs depend on hotspot gensrc
896
  $(STATIC_LIBS_TARGETS): $(JVM_MAIN_GENSRC_TARGETS)
897

898
  $(LAUNCHER_TARGETS): java.base-libs
899

900
  # Declare dependency from <module>-java to <module>-gensrc
901
  $(foreach m, $(GENSRC_MODULES), $(eval $m-java: $m-gensrc))
902

903
  # Declare dependencies between java modules
904
  $(foreach m, $(JAVA_MODULES), \
905
      $(eval $m-java: $(addsuffix -java, $(filter $(JAVA_MODULES), \
906
      $(call FindDepsForModule,$m)))))
907
  # Declare dependencies between the module meta targets
908
  $(foreach m, $(ALL_MODULES), $(eval $m: $(call FindDepsForModule,$m)))
909

910
  # Declare dependencies from <module>-lib to <module>-java
911
  # Skip modules that do not have java source.
912
  $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs: $m-java))
913

914
  # Declare dependencies from all other <module>-lib to java.base-lib
915
  $(foreach t, $(filter-out java.base-libs, $(LIBS_TARGETS)), \
916
      $(eval $t: java.base-libs))
917

918
  ifeq ($(ENABLE_HSDIS_BUNDLING), true)
919
    java.base-copy: build-hsdis
920
  endif
921

922
  # On Windows, we need to copy tzmappings generated by gensrc
923
  ifeq ($(call isTargetOs, windows), true)
924
    java.base-copy: java.base-gensrc
925
  endif
926

927
  # jdk.accessibility depends on java.desktop
928
  jdk.accessibility-libs: java.desktop-libs
929

930
  # This dependency needs to be explicitly declared. jdk.jdi-gensrc generates a
931
  # header file used by jdk.jdwp.agent-libs. The jdk.jdwp.agent-gensrc is a
932
  # virtual target.
933
  jdk.jdwp.agent-libs: jdk.jdwp.agent-gensrc
934

935
  # jdk.jfr-gendata uses TOOL_JFR_GEN from buildtools-hotspot
936
  jdk.jfr-gendata: buildtools-hotspot
937

938
  # The swing beans need to have java base properly generated to avoid errors
939
  # in javadoc. The X11 wrappers need the java.base include files to have been
940
  # copied and processed.
941
  java.desktop-gensrc-src: java.base-gensrc java.base-copy
942

943
  jdk.jdeps-gendata: java
944

945
  # jdk.compiler gendata generates ct.sym, which requires all generated
946
  # java source and compiled classes present.
947
  jdk.compiler-gendata: $(JAVA_TARGETS)
948

949
  # jdk.javadoc gendata generates element-list, which requires all java sources
950
  # but not compiled classes.
951
  jdk.javadoc-gendata: $(GENSRC_TARGETS)
952

953
  # ct.sym and element-list generation also needs the BUILD_JDK. If the
954
  # BUILD_JDK was supplied externally, no extra prerequisites are needed.
955
  ifeq ($(CREATE_BUILDJDK), true)
956
    ifneq ($(CREATING_BUILDJDK), true)
957
      # When cross compiling and an external BUILD_JDK wasn't supplied, it's
958
      # produced by the create-buildjdk target.
959
      jdk.compiler-gendata: create-buildjdk
960
      jdk.javadoc-gendata: create-buildjdk
961
    endif
962
  else ifeq ($(EXTERNAL_BUILDJDK), false)
963
    # When not cross compiling, the BUILD_JDK is the interim jdk image, and
964
    # the javac launcher is needed.
965
    jdk.compiler-gendata: jdk.compiler-launchers
966
    jdk.javadoc-gendata: jdk.compiler-launchers
967
  endif
968

969
  # Declare dependencies between jmod targets.
970
  # java.base jmod needs jrt-fs.jar and access to the jmods for all non
971
  # upgradeable modules and their transitive dependencies.
972
  # When creating the BUILDJDK, we don't need to add hashes to java.base, thus
973
  # we don't need to depend on all other jmods
974
  ifneq ($(CREATING_BUILDJDK), true)
975
    java.base-jmod: jrtfs-jar $(addsuffix -jmod, $(filter-out java.base, $(sort \
976
        $(foreach m, $(filter-out $(call FindAllUpgradeableModules), $(JMOD_MODULES)), \
977
          $m $(call FindTransitiveDepsForModules, $m) \
978
        ))))
979
  endif
980

981
  # If not already set, set the JVM target so that the JVM will be built.
982
  JVM_MAIN_TARGETS ?= hotspot
983

984
  # Building java.base-jmod requires all of VM (ie hotspot) to be built.
985
  java.base-jmod: $(JVM_MAIN_TARGETS)
986

987
  # Declare dependencies from <module>-jmod to all other module targets
988
  $(foreach m, $(JAVA_MODULES), $(eval $m_JMOD_DEPS += $m-java))
989
  $(foreach m, $(GENDATA_MODULES), $(eval $m_JMOD_DEPS += $m-gendata))
990
  $(foreach m, $(LIBS_MODULES), $(eval $m_JMOD_DEPS += $m-libs))
991
  $(foreach m, $(LAUNCHER_MODULES), $(eval $m_JMOD_DEPS += $m-launchers))
992
  $(foreach m, $(COPY_MODULES), $(eval $m_JMOD_DEPS += $m-copy))
993
  $(foreach m, $(ALL_MODULES), $(eval $m-jmod: $($(m)_JMOD_DEPS)))
994
  $(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $m-interim-jmod: $($(m)_JMOD_DEPS)))
995

996
  # Setup the minimal set of generated native source dependencies for hotspot
997
  $(foreach v, $(JVM_VARIANTS), \
998
    $(eval hotspot-$v-libs-compile-commands: hotspot-$v-gensrc) \
999
    $(foreach m, $(filter java.desktop jdk.hotspot.agent, $(GENSRC_MODULES)), \
1000
      $(eval hotspot-$v-libs-compile-commands: $m-gensrc)) \
1001
  )
1002

1003
  # For the full JDK compile commands, create all possible generated sources
1004
  $(foreach m, $(GENSRC_MODULES), $(eval $m-libs-compile-commands: $m-gensrc))
1005
  $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs-compile-commands: $m-java))
1006

1007
  $(COMPILE_COMMANDS_TARGETS_HOTSPOT): clean-compile-commands
1008
  $(COMPILE_COMMANDS_TARGETS_JDK): clean-compile-commands
1009
  compile-commands-hotspot: $(COMPILE_COMMANDS_TARGETS_HOTSPOT)
1010
  compile-commands: $(COMPILE_COMMANDS_TARGETS_HOTSPOT) $(COMPILE_COMMANDS_TARGETS_JDK)
1011

1012
  # The -static-libs targets depend on -java as well as java.base-copy.
1013
  $(foreach m, $(filter $(JAVA_MODULES), $(STATIC_LIBS_MODULES)), \
1014
    $(eval $m-static-libs: $m-java java.base-copy))
1015

1016
  # Jmods cannot be created until we have the jmod tool ready to run. During
1017
  # a normal build we run it from the exploded image, but when cross compiling
1018
  # it's run from the buildjdk, which is either created at build time or user
1019
  # supplied.
1020
  ifeq ($(CREATE_BUILDJDK), true)
1021
    ifneq ($(CREATING_BUILDJDK), true)
1022
      # When cross compiling and buildjdk is to be created, simply depend on
1023
      # creating the buildjdk.
1024
      $(JMOD_TARGETS): create-buildjdk
1025
      buildtools-modules: create-buildjdk
1026
    else
1027
      # While actually creating the buildjdk, we need to list the bare
1028
      # minimum dependencies needed before running jmod, to avoid building
1029
      # more than necessary. This includes:
1030
      # * all java modules
1031
      # * jdk.jlink-launchers
1032
      # * copy jvm.cfg (done in java.base-copy)
1033
      # * tzdb.dat (done in java.base-gendata)
1034
      # Without all of these jimage, jlink and jmod won't start.
1035
      $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): java.base-libs java.base-copy \
1036
          java.base-gendata jdk.jlink-launchers java
1037
    endif
1038
  else ifeq ($(EXTERNAL_BUILDJDK), false)
1039
    # The normal non cross compilation usecase needs to wait for the full
1040
    # exploded-image to avoid a race with the optimize target.
1041
    $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): exploded-image
1042
    # The buildtools-modules are used for the exploded-image-optimize target,
1043
    # but can be built either using the exploded-image or an external BUILDJDK.
1044
    buildtools-modules: exploded-image-base
1045
  endif
1046

1047
  # All modules include the main license files from java.base.
1048
  $(JMOD_TARGETS): java.base-copy
1049

1050
  # jdk.javadoc uses an internal copy of the main license files from java.base.
1051
  jdk.javadoc-copy: java.base-copy
1052

1053
  zip-security: $(filter jdk.crypto%, $(JAVA_TARGETS))
1054

1055
  ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
1056
    ifeq ($(CREATE_BUILDJDK), true)
1057
      # If creating a buildjdk, the interim image needs to be based on that.
1058
      generate-link-opt-data: create-buildjdk
1059
    else ifeq ($(EXTERNAL_BUILDJDK), false)
1060
      # If an external buildjdk has been provided, we skip generating an
1061
      # interim-image and just use the external buildjdk for generating
1062
      # classlist.
1063
      generate-link-opt-data: interim-image
1064
    endif
1065
    generate-link-opt-data: buildtools-jdk
1066

1067
    # The generated classlist needs to go into java.base-jmod.
1068
    java.base-jmod jdk.jlink-jmod jdk-image legacy-jre-image: generate-link-opt-data
1069
  endif
1070

1071
  symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS)
1072

1073
  static-libs-image: hotspot-static-libs $(STATIC_LIBS_TARGETS)
1074

1075
  static-libs-graal-image: $(STATIC_LIBS_TARGETS)
1076

1077
  bootcycle-images: jdk-image
1078

1079
  docs-jdk-api-javadoc: $(GENSRC_TARGETS)
1080

1081
  docs-javase-api-javadoc: $(GENSRC_TARGETS)
1082

1083
  docs-reference-api-javadoc: $(GENSRC_TARGETS)
1084

1085
  # If not already set, then set the JVM specific docs targets
1086
  JVM_DOCS_TARGETS ?= hotspot-$(JVM_VARIANT_MAIN)-gensrc
1087

1088
  # The gensrc steps for hotspot create html spec files.
1089
  docs-jdk-specs: $(JVM_DOCS_TARGETS)
1090

1091
  # Tests
1092
  test-make: clean-test-make compile-commands
1093

1094
  test-make-compile-commands: compile-commands
1095

1096
  # Declare dependency for all generated test targets
1097
  $(foreach t, $(filter-out test-make%, $(ALL_TEST_TARGETS)), $(eval $t: jdk-image test-image))
1098
  $(foreach t, $(ALL_EXPLODED_TEST_TARGETS), $(eval $t: exploded-image test-image))
1099

1100
  interim-image: $(INTERIM_JMOD_TARGETS)
1101

1102
  build-test-hotspot-jtreg-native: hotspot-$(JVM_VARIANT_MAIN)-libs
1103
  build-test-libtest-jtreg-native: hotspot-$(JVM_VARIANT_MAIN)-libs
1104

1105
endif
1106

1107
################################################################################
1108
# Virtual targets without recipes
1109

1110
# If not already set, set the JVM specific tools targets
1111
JVM_TOOLS_TARGETS ?= buildtools-hotspot
1112
buildtools: buildtools-langtools interim-langtools \
1113
    buildtools-jdk $(JVM_TOOLS_TARGETS)
1114

1115
# Declare dependencies from hotspot-<variant> targets
1116
$(foreach v, $(JVM_VARIANTS), \
1117
  $(eval hotspot-$v: hotspot-$v-gensrc hotspot-$v-libs) \
1118
)
1119
hotspot: $(HOTSPOT_VARIANT_TARGETS)
1120

1121
# Create targets hotspot-libs and hotspot-gensrc.
1122
$(foreach v, $(JVM_VARIANTS), \
1123
  $(eval hotspot-libs: hotspot-$v-libs) \
1124
  $(eval hotspot-gensrc: hotspot-$v-gensrc) \
1125
  $(eval hotspot-static-libs: hotspot-$v-static-libs) \
1126
)
1127

1128
gensrc: $(GENSRC_TARGETS)
1129

1130
gendata: $(GENDATA_TARGETS)
1131

1132
copy: $(ALL_COPY_TARGETS)
1133

1134
java: $(JAVA_TARGETS)
1135

1136
libs: $(LIBS_TARGETS)
1137

1138
static-libs: $(STATIC_LIBS_TARGETS)
1139

1140
launchers: $(LAUNCHER_TARGETS)
1141

1142
jmods: $(JMOD_TARGETS)
1143

1144
# Explicitly declare dependency for virtual target jdk.jdwp.agent-gensrc which
1145
# is actually handled by jdk.jdi-gensrc
1146
jdk.jdwp.agent-gensrc: jdk.jdi-gensrc
1147

1148
# Declare dependencies from <module> to all the individual targets specific
1149
# to that module <module>-*, that are needed for the exploded image.
1150
$(foreach m, $(GENSRC_MODULES), $(eval $m: $m-gensrc))
1151
$(foreach m, $(JAVA_MODULES), $(eval $m: $m-java))
1152
$(foreach m, $(GENDATA_MODULES), $(eval $m: $m-gendata))
1153
$(foreach m, $(LIBS_MODULES), $(eval $m: $m-libs))
1154
$(foreach m, $(LAUNCHER_MODULES), $(eval $m: $m-launchers))
1155
$(foreach m, $(ALL_COPY_MODULES), $(eval $m: $m-copy))
1156

1157
# Building java.base includes building all of hotspot.
1158
java.base: $(JVM_MAIN_TARGETS)
1159

1160
demos: demos-jdk
1161

1162
# The "exploded image" is a locally runnable JDK in $(OUTPUTDIR)/jdk.
1163
exploded-image-base: $(ALL_MODULES)
1164
exploded-image: exploded-image-base release-file
1165
# When cross compiling, no need to optimize the exploded image since it won't
1166
# be runnable on the host platform anyway.
1167
ifneq ($(COMPILE_TYPE), cross)
1168
  exploded-image: exploded-image-optimize
1169
endif
1170

1171
# The runnable-buildjdk target guarantees that the buildjdk is done
1172
# building and ready to be used. The exact set of dependencies it needs
1173
# depends on what kind of buildjdk is used for the current configuration.
1174
runnable-buildjdk:
1175
ifeq ($(CREATE_BUILDJDK), true)
1176
  ifneq ($(CREATING_BUILDJDK), true)
1177
    runnable-buildjdk: create-buildjdk
1178
  endif
1179
else ifeq ($(EXTERNAL_BUILDJDK), false)
1180
  runnable-buildjdk: exploded-image
1181
endif
1182

1183
create-buildjdk: create-buildjdk-interim-image
1184

1185
docs-jdk-api: docs-jdk-api-javadoc
1186
docs-javase-api: docs-javase-api-javadoc
1187
docs-reference-api: docs-reference-api-javadoc
1188

1189
# If we're building full docs, we must also generate the module graphs to
1190
# get non-broken api documentation.
1191
ifeq ($(ENABLE_FULL_DOCS), true)
1192
  docs-jdk-api: docs-jdk-api-graphs
1193
  docs-javase-api: docs-javase-api-graphs
1194
  docs-reference-api: docs-reference-api-graphs
1195

1196
  # We must generate javadoc first so we know what graphs are needed
1197
  docs-jdk-api-graphs: docs-jdk-api-javadoc
1198
  docs-javase-api-graphs: docs-javase-api-javadoc
1199
  docs-reference-api-graphs: docs-reference-api-javadoc
1200
endif
1201

1202
docs-jdk: docs-jdk-api docs-jdk-specs docs-jdk-index
1203
docs-javase: docs-javase-api
1204
docs-reference: docs-reference-api
1205

1206
# alias for backwards compatibility
1207
docs-javadoc: docs-jdk-api
1208

1209
mac-bundles: mac-jdk-bundle
1210

1211
# The $(OUTPUTDIR)/images directory contain the resulting deliverables,
1212
# and in line with this, our targets for creating these are named *-image[s].
1213

1214
# This target builds the product images, e.g. the JDK image
1215
# (and possibly other, more specific versions)
1216
product-images: jdk-image symbols-image exploded-image
1217

1218
# This target builds the legacy images, e.g. the legacy JRE image
1219
legacy-images: legacy-jre-image
1220

1221
# zip-security is actually a bundle, but for now it needs to be considered
1222
# an image until this can be cleaned up properly.
1223
product-images: zip-security
1224

1225
# The module summary cannot be run when:
1226
# * Cross compiling and building a partial BUILDJDK for the build host
1227
# * An external buildjdk has been supplied since it may not match the
1228
#   module selection of the target jdk
1229
ifneq ($(CREATE_BUILDJDK), true)
1230
  ifeq ($(EXTERNAL_BUILDJDK), false)
1231
    product-images: generate-summary
1232
  endif
1233
endif
1234

1235
ifeq ($(call isTargetOs, macosx), true)
1236
  product-images: mac-jdk-bundle
1237

1238
  legacy-images: mac-legacy-jre-bundle
1239
endif
1240

1241
# These targets build the various documentation images
1242
docs-jdk-image: docs-jdk
1243
docs-javase-image: docs-javase
1244
docs-reference-image: docs-reference
1245
# The docs-jdk-image is what most users expect to be built
1246
docs-image: docs-jdk-image
1247
all-docs-images: docs-jdk-image docs-javase-image docs-reference-image
1248

1249
docs-bundles: docs-jdk-bundles
1250
all-docs-bundles: docs-jdk-bundles docs-javase-bundles docs-reference-bundles
1251

1252
# This target builds the test image
1253
test-image: prepare-test-image test-image-jdk-jtreg-native \
1254
    test-image-demos-jdk test-image-libtest-jtreg-native \
1255
    test-image-lib test-image-lib-native
1256

1257
ifneq ($(JVM_TEST_IMAGE_TARGETS), )
1258
  # If JVM_TEST_IMAGE_TARGETS is externally defined, use it instead of the
1259
  # standard hotspot set of tests.
1260
  test-image: $(JVM_TEST_IMAGE_TARGETS)
1261
else
1262
  test-image: test-image-hotspot-jtreg-native
1263
  ifneq ($(GTEST_FRAMEWORK_SRC), )
1264
    test-image: test-image-hotspot-gtest
1265
  endif
1266
endif
1267

1268
ifeq ($(BUILD_FAILURE_HANDLER), true)
1269
  test-image: test-image-failure-handler
1270
endif
1271

1272
ifeq ($(BUILD_JTREG_TEST_THREAD_FACTORY), true)
1273
  test-image: test-image-test-thread-factory
1274
endif
1275

1276
ifneq ($(JMH_CORE_JAR), )
1277
  test-image: build-microbenchmark
1278
endif
1279

1280
################################################################################
1281

1282
# all-images builds all our deliverables as images.
1283
all-images: product-images test-image all-docs-images
1284

1285
# all-bundles packages all our deliverables as tar.gz bundles.
1286
all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles
1287

1288
ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-static-libs \
1289
    hotspot-gensrc gensrc gendata \
1290
    copy java libs static-libs launchers jmods \
1291
    jdk.jdwp.agent-gensrc $(ALL_MODULES) demos \
1292
    exploded-image-base exploded-image runnable-buildjdk \
1293
    create-buildjdk docs-jdk-api docs-javase-api docs-reference-api docs-jdk \
1294
    docs-javase docs-reference docs-javadoc mac-bundles product-images legacy-images \
1295
    docs-image docs-javase-image docs-reference-image all-docs-images \
1296
    docs-bundles all-docs-bundles test-image all-images \
1297
    all-bundles
1298

1299
################################################################################
1300

1301
# Traditional targets typically run by users.
1302
# These can be considered aliases for the targets now named by a more
1303
# "modern" naming scheme.
1304
default: $(DEFAULT_MAKE_TARGET)
1305
jdk: exploded-image
1306
images: product-images
1307
docs: docs-image
1308
bundles: all-bundles
1309
all: all-images
1310

1311
ALL_TARGETS += default jdk images docs bundles all
1312

1313
# Aliases used for running tests.
1314

1315
# Let "run-test" be an alias for "test"
1316
$(foreach t, $(ALL_NAMED_TESTS), $(eval run-test-$t: test-$t))
1317
RUN_TEST_TARGETS := $(addprefix run-test-, $(ALL_NAMED_TESTS))
1318

1319
run-test: test
1320
exploded-run-test: exploded-test
1321

1322
# "make check" is a common idiom for running basic testing
1323
check: test-tier1
1324

1325
# Keep some old names as aliases
1326
test-hotspot-jtreg: test-hotspot_all
1327
test-hotspot-jtreg-native: test-hotspot_native_sanity
1328
test-hotspot-gtest: exploded-test-gtest
1329
test-jdk-jtreg-native: test-jdk_native_sanity
1330

1331
ALL_TARGETS += $(RUN_TEST_TARGETS) run-test exploded-run-test check \
1332
    test-hotspot-jtreg test-hotspot-jtreg-native test-hotspot-gtest \
1333
    test-jdk-jtreg-native
1334

1335
################################################################################
1336
################################################################################
1337
#
1338
# Clean targets
1339
#
1340
################################################################################
1341
# Clean targets are automatically run serially by the Makefile calling this
1342
# file.
1343

1344
CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
1345
    images make-support test-make bundles buildjdk test-results test-support \
1346
    support/images
1347
CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
1348
CLEAN_SUPPORT_DIRS += demos
1349
CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
1350
CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
1351
CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
1352
CLEAN_PHASES := gensrc java native include
1353
CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
1354
CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
1355
# Construct targets of the form clean-$module-$phase
1356
CLEAN_MODULE_PHASE_TARGETS := $(addprefix clean-, $(foreach m, $(ALL_MODULES), \
1357
    $(addprefix $m-, $(CLEAN_PHASES))))
1358

1359
# Remove everything, except the output from configure.
1360
clean: $(CLEAN_DIR_TARGETS)
1361
	($(CD) $(OUTPUTDIR) && $(RM) -r build*.log* compile_commands.json)
1362
	$(ECHO) Cleaned all build artifacts.
1363

1364
clean-docs:
1365
	$(call CleanDocs)
1366

1367
clean-compile-commands:
1368
	$(call CleanMakeSupportDir,compile-commands)
1369

1370
$(CLEAN_DIR_TARGETS):
1371
	$(call CleanDir,$(patsubst clean-%, %, $@))
1372

1373
$(CLEAN_SUPPORT_DIR_TARGETS):
1374
	$(call CleanSupportDir,$(patsubst clean-%, %, $@))
1375

1376
$(CLEAN_TEST_TARGETS):
1377
	$(call CleanTest,$(patsubst clean-test-%, %, $@))
1378

1379
$(CLEAN_PHASE_TARGETS):
1380
	$(call Clean-$(patsubst clean-%,%, $@))
1381

1382
$(CLEAN_MODULE_TARGETS):
1383
	$(call CleanModule,$(patsubst clean-%, %, $@))
1384

1385
$(CLEAN_MODULE_PHASE_TARGETS):
1386
	$(call Clean-$(word 3, $(subst -,$(SPACE),$@)), \
1387
	    $(word 2, $(subst -,$(SPACE),$@)))
1388

1389
# When removing the support dir, we must also remove jdk. Building classes has
1390
# the side effect of generating native headers. The headers end up in support
1391
# while classes and touch files end up in jdk.
1392
clean-support: clean-jdk
1393

1394
clean-test: clean-test-results clean-test-support
1395

1396
# When cleaning images, also clean the support/images directory.
1397
clean-images: clean-support/images
1398

1399
# Remove everything, including configure configuration. If the output
1400
# directory was created by configure and now becomes empty, remove it as well.
1401
dist-clean: clean
1402
	($(CD) $(OUTPUTDIR) && \
1403
	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide \
1404
	    configure.log* build.log*)
1405
	$(if $(filter $(CONF_NAME),$(notdir $(OUTPUTDIR))), \
1406
	  if test "x`$(LS) $(OUTPUTDIR)`" != x; then \
1407
	    $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
1408
	  else \
1409
	    ($(CD) $(TOPDIR) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" \
1410
	        && $(RM) -r $(OUTPUTDIR)) \
1411
	  fi \
1412
	)
1413
	$(ECHO) Cleaned everything, you will have to re-run configure.
1414

1415
ALL_TARGETS += clean clean-docs clean-compile-commands dist-clean $(CLEAN_DIR_TARGETS) \
1416
    $(CLEAN_SUPPORT_DIR_TARGETS) $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) \
1417
    $(CLEAN_MODULE_TARGETS) $(CLEAN_MODULE_PHASE_TARGETS)
1418

1419
################################################################################
1420
# Declare *-only targets for each normal target
1421
$(foreach t, $(ALL_TARGETS), $(eval $(t)-only: $(t)))
1422

1423
ALL_TARGETS += $(addsuffix -only, $(filter-out dist-clean clean%, $(ALL_TARGETS)))
1424

1425
################################################################################
1426

1427
# The following targets are intentionally not added to ALL_TARGETS since they
1428
# are internal only, to support Init.gmk.
1429

1430
print-targets:
1431
	$(info $(subst $(SPACE),$(NEWLINE),$(sort $(ALL_TARGETS))))
1432

1433
print-modules:
1434
	$(info $(subst $(SPACE),$(NEWLINE),$(sort $(ALL_MODULES))))
1435

1436
print-tests:
1437
	$(info $(subst $(SPACE),$(NEWLINE),$(sort $(ALL_NAMED_TESTS))))
1438

1439
create-main-targets-include:
1440
	  $(call LogInfo, Generating main target list)
1441
	  @$(ECHO) ALL_MAIN_TARGETS := $(sort $(ALL_TARGETS)) > \
1442
	      $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk
1443

1444
################################################################################
1445
# Hook to include the corresponding custom file, if present.
1446
$(eval $(call IncludeCustomExtension, Main-post.gmk))
1447

1448
.PHONY: $(ALL_TARGETS)
1449

1450
FRC: # Force target
1451

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.