Main.gmk revision 2692:d681b4d6c202
1156952Sume#
2269867Sume# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
3269867Sume# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4156952Sume#
5269867Sume# This code is free software; you can redistribute it and/or modify it
6156952Sume# under the terms of the GNU General Public License version 2 only, as
7156952Sume# published by the Free Software Foundation.  Oracle designates this
8156952Sume# particular file as subject to the "Classpath" exception as provided
9269867Sume# by Oracle in the LICENSE file that accompanied this code.
10269867Sume#
11269867Sume# This code is distributed in the hope that it will be useful, but WITHOUT
12269867Sume# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13269867Sume# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14269867Sume# version 2 for more details (a copy is included in the LICENSE file that
15269867Sume# accompanied this code).
16156952Sume#
17156952Sume# You should have received a copy of the GNU General Public License version
18156952Sume# 2 along with this work; if not, write to the Free Software Foundation,
19156952Sume# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20156952Sume#
21269867Sume# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22156952Sume# or visit www.oracle.com if you need additional information or have any
23156952Sume# questions.
24156952Sume#
25156952Sume
26156952Sume################################################################################
27156952Sume# This is the main makefile containing most actual top level targets. It needs
28156952Sume# to be called with a SPEC file defined.
29156952Sume################################################################################
30156952Sume
31156952Sume# Declare default target
32186090Sumedefault:
33186090Sume
34156952Sumeifeq ($(wildcard $(SPEC)),)
35156952Sume  $(error Main.gmk needs SPEC set to a proper spec.gmk)
36156952Sumeendif
37156952Sume
38156952Sume# Now load the spec
39156952Sumeinclude $(SPEC)
40156952Sume
41156952Sumeinclude $(SRC_ROOT)/make/MainSupport.gmk
42156952Sume
43156952Sume# Load the vital tools for all the makefiles.
44156952Sumeinclude $(SRC_ROOT)/make/common/MakeBase.gmk
45156952Sumeinclude $(SRC_ROOT)/make/common/Modules.gmk
46156952Sumeinclude $(SRC_ROOT)/make/common/FindTests.gmk
47156952Sume
48156952Sume# Declare ALL_TARGETS as an immediate variable. This variable is a list of all
49156952Sume# valid top level targets. It's used to declare them all as PHONY and to
50156952Sume# generate the -only targets.
51156952SumeALL_TARGETS :=
52156952Sume
53156952Sume# Hook to include the corresponding custom file, if present.
54156952Sume$(eval $(call IncludeCustomExtension, , Main.gmk))
55156952Sume
56156952Sume# All modules for the current target platform.
57156952SumeALL_MODULES := $(call FindAllModules)
58156952Sume
59156952Sume################################################################################
60156952Sume################################################################################
61156952Sume#
62156952Sume# Recipes for all targets. Only recipes, dependencies are declared later.
63156952Sume#
64156952Sume################################################################################
65156952Sume
66156952Sume################################################################################
67156952Sume# Interim/build tools targets, compiling tools used during the build
68156952Sume
69156952Sume# When creating a BUILDJDK, the buildtools and interim targets have already
70156952Sume# been built and should not be built again.
71156952Sumeifneq ($(CREATING_BUILDJDK), true)
72156952Sume  buildtools-langtools:
73156952Sume	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Tools.gmk)
74156952Sume
75156952Sume  interim-langtools:
76156952Sume	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterim.gmk)
77156952Sume
78156952Sume  interim-rmic:
79156952Sume	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterimRmic.gmk)
80156952Sume
81156952Sume  interim-cldrconverter:
82156952Sume	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimCLDRConverter.gmk)
83156952Sume
84156952Sume  buildtools-jdk:
85156952Sume	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)
86156952Sume
87156952Sume  buildtools-modules:
88156952Sume	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileModuleTools.gmk)
89156952Sume
90156952Sume  buildtools-hotspot:
91156952Sume	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)
92156952Sumeendif
93156952Sume
94156952SumeALL_TARGETS += buildtools-langtools interim-langtools \
95156952Sume    interim-rmic interim-cldrconverter buildtools-jdk buildtools-modules \
96156952Sume    buildtools-hotspot
97156952Sume
98156952Sume################################################################################
99156952Sume# Special targets for certain modules
100156952Sume
101156952Sumeunpack-sec:
102156952Sume	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UnpackSecurity.gmk)
103156952Sume
104156952Sumegenerate-exported-symbols:
105156952Sume	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildStatic.gmk)
106156952Sume
107156952SumeALL_TARGETS += unpack-sec generate-exported-symbols
108156952Sume
109156952Sume################################################################################
110156952Sume# Gensrc targets, generating source before java compilation can be done
111156952Sume#
112156952Sume# When creating a BUILDJDK, the java targets have already been built and copied
113156952Sume# into the buildjdk so no need to generate sources.
114156952Sumeifneq ($(CREATING_BUILDJDK), true)
115156952Sume  $(eval $(call DeclareRecipesForPhase, GENSRC, \
116156952Sume      TARGET_SUFFIX := gensrc, \
117156952Sume      FILE_PREFIX := Gensrc, \
118156952Sume      MAKE_SUBDIR := gensrc, \
119156952Sume      CHECK_MODULES := $(ALL_MODULES), \
120156952Sume      MULTIPLE_MAKEFILES := true))
121156952Sume
122156952Sume  JDK_GENSRC_TARGETS := $(filter %-gensrc-jdk, $(GENSRC_TARGETS))
123156952Sume  LANGTOOLS_GENSRC_TARGETS := $(filter %-gensrc-langtools, $(GENSRC_TARGETS))
124156952Sume  CORBA_GENSRC_TARGETS := $(filter %-gensrc-corba, $(GENSRC_TARGETS))
125156952Sume  HOTSPOT_GENSRC_TARGETS := $(filter %-gensrc-hotspot, $(GENSRC_TARGETS))
126156952Sume
127156952Sume  GENSRC_MODULEINFO_MODULES := $(ALL_MODULES)
128156952Sume  GENSRC_MODULEINFO_TARGETS := $(addsuffix -gensrc-moduleinfo, \
129156952Sume      $(GENSRC_MODULEINFO_MODULES))
130156952Sume
131156952Sume  GENSRC_MODULES := $(GENSRC_MODULEINFO_MODULES)
132156952Sume  GENSRC_TARGETS += $(sort $(GENSRC_MODULEINFO_TARGETS) \
133156952Sume      $(addsuffix -gensrc, $(GENSRC_MODULES)))
134156952Sume
135156952Sume  define DeclareModuleInfoRecipe
136156952Sume    $1-gensrc-moduleinfo:
137156952Sume	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
138156952Sume	    -f GensrcModuleInfo.gmk MODULE=$1)
139156952Sume
140156952Sume    $1-gensrc: $1-gensrc-moduleinfo
141156952Sume  endef
142156952Sume
143156952Sume  $(foreach m, $(GENSRC_MODULEINFO_MODULES), $(eval $(call DeclareModuleInfoRecipe,$m)))
144156952Sumeendif
145156952Sume
146156952SumeALL_TARGETS += $(GENSRC_TARGETS)
147156952Sume
148156952Sume################################################################################
149156952Sume# Generate data targets
150156952Sume$(eval $(call DeclareRecipesForPhase, GENDATA, \
151156952Sume    TARGET_SUFFIX := gendata, \
152156952Sume    FILE_PREFIX := Gendata, \
153156952Sume    MAKE_SUBDIR := gendata, \
154156952Sume    CHECK_MODULES := $(ALL_MODULES), \
155156952Sume    USE_WRAPPER := true))
156156952Sume
157156952SumeALL_TARGETS += $(GENDATA_TARGETS)
158156952Sume
159156952Sume################################################################################
160156952Sume# Copy files targets
161156952Sume$(eval $(call DeclareRecipesForPhase, COPY, \
162156952Sume    TARGET_SUFFIX := copy, \
163156952Sume    FILE_PREFIX := Copy, \
164156952Sume    MAKE_SUBDIR := copy, \
165156952Sume    CHECK_MODULES := $(ALL_MODULES), \
166156952Sume    USE_WRAPPER := true, \
167156952Sume    MULTIPLE_MAKEFILES := true))
168156952Sume
169156952SumeALL_COPY_MODULES += $(COPY_MODULES)
170156952SumeALL_COPY_TARGETS += $(COPY_TARGETS)
171156952Sume
172156952SumeIMPORT_COPY_MODULES := $(call FindImportedModules)
173156952SumeIMPORT_COPY_TARGETS := $(addsuffix -copy, $(IMPORT_COPY_MODULES))
174156952SumeALL_COPY_MODULES += $(IMPORT_COPY_MODULES)
175156952SumeALL_COPY_TARGETS += $(IMPORT_COPY_TARGETS)
176156952Sume
177156952Sumedefine DeclareImportCopyRecipe
178156952Sume  $1-copy:
179156952Sume	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
180156952Sume	    -f CopyImportModules.gmk MODULE=$1)
181156952Sumeendef
182156952Sume
183156952Sume$(foreach m, $(IMPORT_COPY_MODULES), $(eval $(call DeclareImportCopyRecipe,$m)))
184156952Sume
185156952SumeALL_TARGETS += $(ALL_COPY_TARGETS)
186156952Sume
187156952Sume################################################################################
188156952Sume# Targets for compiling all java modules. Nashorn is treated separately.
189156952SumeJAVA_MODULES := $(ALL_MODULES)
190156952SumeJAVA_TARGETS := $(addsuffix -java, $(JAVA_MODULES))
191156952Sume
192156952Sumedefine DeclareCompileJavaRecipe
193156952Sume  $1-java:
194156952Sume	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
195156952Sume	    -f CompileJavaModules.gmk MODULE=$1)
196156952Sumeendef
197156952Sume
198156952Sume$(foreach m, $(filter-out jdk.scripting.nashorn, $(JAVA_MODULES)), \
199156952Sume    $(eval $(call DeclareCompileJavaRecipe,$m)))
200156952Sume
201156952Sume# Build nashorn. Needs to be compiled separately from the rest of the modules
202156952Sume# due to nasgen.
203156952Sumejdk.scripting.nashorn-java:
204156952Sume	+($(CD) $(NASHORN_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
205170242Sume	    -f BuildNashorn.gmk compile)
206170242Sume
207ALL_TARGETS += $(JAVA_TARGETS)
208
209################################################################################
210# Targets for running rmic.
211$(eval $(call DeclareRecipesForPhase, RMIC, \
212    TARGET_SUFFIX := rmic, \
213    FILE_PREFIX := Rmic, \
214    MAKE_SUBDIR := rmic, \
215    CHECK_MODULES := $(ALL_MODULES)))
216
217ALL_TARGETS += $(RMIC_TARGETS)
218
219################################################################################
220# Targets for compiling native libraries
221$(eval $(call DeclareRecipesForPhase, LIBS, \
222    TARGET_SUFFIX := libs, \
223    FILE_PREFIX := Lib, \
224    MAKE_SUBDIR := lib, \
225    CHECK_MODULES := $(ALL_MODULES), \
226    USE_WRAPPER := true))
227
228ALL_TARGETS += $(LIBS_TARGETS)
229
230################################################################################
231# Targets for compiling native executables
232$(eval $(call DeclareRecipesForPhase, LAUNCHER, \
233    TARGET_SUFFIX := launchers, \
234    FILE_PREFIX := Launcher, \
235    MAKE_SUBDIR := launcher, \
236    CHECK_MODULES := $(ALL_MODULES), \
237    USE_WRAPPER := true))
238
239ALL_TARGETS += $(LAUNCHER_TARGETS)
240
241################################################################################
242# Build hotspot target
243
244HOTSPOT_VARIANT_TARGETS := $(addprefix hotspot-, $(JVM_VARIANTS))
245HOTSPOT_VARIANT_GENSRC_TARGETS := $(addsuffix -gensrc, $(HOTSPOT_VARIANT_TARGETS))
246HOTSPOT_VARIANT_LIBS_TARGETS := $(addsuffix -libs, $(HOTSPOT_VARIANT_TARGETS))
247
248define DeclareHotspotGensrcRecipe
249  hotspot-$1-gensrc:
250	$$(call LogInfo, Building JVM variant '$1' with features '$(JVM_FEATURES_$1)')
251	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f gensrc/GenerateSources.gmk \
252	    JVM_VARIANT=$1)
253endef
254
255$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotGensrcRecipe,$v)))
256
257define DeclareHotspotLibsRecipe
258  hotspot-$1-libs:
259	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibraries.gmk \
260	    JVM_VARIANT=$1)
261endef
262
263$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotLibsRecipe,$v)))
264
265hotspot-jsig:
266	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibjsig.gmk)
267
268hotspot-ide-project:
269	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ide/CreateVSProject.gmk)
270
271ALL_TARGETS += $(HOTSPOT_VARIANT_TARGETS) $(HOTSPOT_VARIANT_GENSRC_TARGETS) \
272    $(HOTSPOT_VARIANT_LIBS_TARGETS) hotspot-jsig hotspot-ide-project
273
274################################################################################
275# Build demos targets
276
277demos-jdk:
278	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk)
279
280test-image-demos-jdk:
281	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk images)
282
283ALL_TARGETS += demos-jdk test-image-demos-jdk
284
285################################################################################
286# Jigsaw specific data and analysis targets.
287
288generate-summary:
289	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f GenerateModuleSummary.gmk)
290
291ALL_TARGETS += generate-summary
292
293################################################################################
294# Jmod targets
295
296JMOD_MODULES := $(ALL_MODULES)
297JMOD_TARGETS := $(addsuffix -jmod, $(JMOD_MODULES))
298
299define DeclareJmodRecipe
300  $1-jmod:
301	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
302	    MODULE=$1)
303endef
304
305$(foreach m, $(JMOD_MODULES), $(eval $(call DeclareJmodRecipe,$m)))
306
307ALL_TARGETS += $(JMOD_TARGETS)
308
309################################################################################
310# Images targets
311
312store-source-revision:
313	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk store-source-revision)
314
315create-source-revision-tracker:
316	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk create-source-revision-tracker)
317
318BOOTCYCLE_TARGET := product-images
319bootcycle-images:
320        ifneq ($(COMPILE_TYPE), cross)
321	  $(call LogWarn, Boot cycle build step 2: Building a new JDK image using previously built image)
322	  +$(MAKE) $(MAKE_ARGS) -f $(SRC_ROOT)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
323	      JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
324        else
325	  $(call LogWarn, Boot cycle build disabled when cross compiling)
326        endif
327
328zip-security:
329	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSecurity.gmk)
330
331zip-source:
332	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSource.gmk)
333
334jrtfs-jar:
335	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f JrtfsJar.gmk)
336
337jdk-image:
338	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jdk)
339
340jre-image:
341	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jre)
342
343symbols-image:
344	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk symbols)
345
346profiles-image:
347	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)
348
349mac-bundles-jdk:
350	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk)
351
352release-file:
353	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ReleaseFile.gmk)
354
355exploded-image-optimize:
356	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk)
357
358ALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \
359    zip-source jrtfs-jar jdk-image jre-image \
360    symbols-image profiles-image mac-bundles-jdk \
361    release-file exploded-image-optimize
362
363################################################################################
364# Docs targets
365
366# If building full docs, to complete docs-*-api we need both the javadoc and
367# modulegraph targets.
368docs-jdk-api-javadoc:
369	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-api-javadoc)
370
371docs-jdk-api-modulegraph:
372	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-api-modulegraph)
373
374docs-javase-api-javadoc:
375	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-javase-api-javadoc)
376
377docs-javase-api-modulegraph:
378	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-javase-api-modulegraph)
379
380docs-jdk-specs:
381	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-specs)
382
383docs-jdk-index:
384	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-index)
385
386docs-zip:
387	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-zip)
388
389update-build-docs:
390	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f UpdateBuildDocs.gmk)
391
392ALL_TARGETS += docs-jdk-api-javadoc docs-jdk-api-modulegraph \
393    docs-javase-api-javadoc docs-javase-api-modulegraph docs-jdk-specs \
394    docs-jdk-index docs-zip update-build-docs
395
396################################################################################
397# Cross compilation support
398
399ifeq ($(CREATING_BUILDJDK), true)
400  # This target is only called by the recursive call below.
401  create-buildjdk-interim-image-helper: interim-image jdk.jlink-launchers \
402      java.base-copy jdk.jdeps-launchers
403endif
404
405create-buildjdk-copy:
406	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateBuildJdkCopy.gmk)
407
408create-buildjdk-interim-image:
409	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Main.gmk \
410	    $@-helper \
411	    SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
412	    HOTSPOT_SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
413	    CREATING_BUILDJDK=true)
414
415ALL_TARGETS += create-buildjdk-copy create-buildjdk-interim-image
416
417################################################################################
418# The interim-image is a small jlinked image that is used to generate artifacts
419# at build time for use when linking the real images.
420
421INTERIM_JMOD_TARGETS := $(addsuffix -interim-jmod, $(INTERIM_IMAGE_MODULES))
422
423define DeclareInterimJmodRecipe
424  $1-interim-jmod:
425	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
426	    MODULE=$1 \
427	    JMODS_DIR=$(INTERIM_JMODS_DIR) \
428	    JMODS_TEMPDIR=$(INTERIM_JMODS_DIR)/temp \
429	    INTERIM_JMOD=true \
430	)
431endef
432
433$(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $(call DeclareInterimJmodRecipe,$m)))
434
435interim-image:
436	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f InterimImage.gmk)
437
438ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
439  generate-link-opt-data:
440	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f GenerateLinkOptData.gmk)
441endif
442
443ALL_TARGETS += $(INTERIM_JMOD_TARGETS) interim-image generate-link-opt-data
444
445################################################################################
446# Generate test names for all JTReg test groups
447#
448
449define DeclareRunTestRecipe
450  run-test-$1:
451	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$1")
452
453  exploded-run-test-$1:
454	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \
455	    TEST="$1" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
456
457endef
458
459# ALL_NAMED_TESTS is defined in FindTests.gmk
460$(foreach t, $(ALL_NAMED_TESTS), $(eval $(call DeclareRunTestRecipe,$t)))
461ALL_TEST_TARGETS := $(addprefix run-test-, $(ALL_NAMED_TESTS))
462ALL_EXPLODED_TEST_TARGETS := $(addprefix exploded-run-test-, $(ALL_NAMED_TESTS))
463
464ALL_TARGETS += $(ALL_TEST_TARGETS) $(ALL_EXPLODED_TEST_TARGETS)
465
466################################################################################
467# Build tests
468#
469
470prepare-test-image:
471	$(MKDIR) -p $(TEST_IMAGE_DIR)
472	$(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image'
473
474build-test-hotspot-jtreg-native:
475	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
476	    build-test-hotspot-jtreg-native)
477
478test-image-hotspot-jtreg-native:
479	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
480	    test-image-hotspot-jtreg-native)
481
482build-test-jdk-jtreg-native:
483	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
484	    build-test-jdk-jtreg-native)
485
486test-image-jdk-jtreg-native:
487	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
488	    test-image-jdk-jtreg-native)
489
490run-test:
491	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$(TEST)")
492
493exploded-run-test:
494	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \
495	    TEST="$(TEST)" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
496
497ifeq ($(BUILD_GTEST), true)
498  test-image-hotspot-gtest:
499	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f GtestImage.gmk)
500endif
501
502build-test-lib:
503	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk)
504
505ifeq ($(BUILD_FAILURE_HANDLER), true)
506  # Builds the failure handler jtreg extension
507  build-test-failure-handler:
508	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
509	    -f BuildFailureHandler.gmk build)
510
511  # Runs the tests for the failure handler jtreg extension
512  test-failure-handler:
513	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
514	    -f BuildFailureHandler.gmk test)
515
516  # Copies the failure handler jtreg extension into the test image
517  test-image-failure-handler:
518	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
519	     -f BuildFailureHandler.gmk images)
520endif
521
522ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \
523    test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
524    test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \
525    test-failure-handler test-image-failure-handler test-image-hotspot-gtest \
526    run-test exploded-run-test
527
528################################################################################
529# Run tests
530
531# Run tests specified by $(TEST), or the default test set.
532test:
533	$(call RunTests, $(TEST), $(JDK_IMAGE_DIR))
534
535test-hotspot-jtreg:
536	$(call RunTests, "hotspot_all", $(JDK_IMAGE_DIR))
537
538test-hotspot-jtreg-native:
539	$(call RunTests, "hotspot_native_sanity", $(JDK_IMAGE_DIR))
540
541test-hotspot-internal:
542	$(call RunTests, "hotspot_internal", $(JDK_OUTPUTDIR))
543
544test-hotspot-gtest:
545	$(call RunTests, "hotspot_gtest", $(JDK_OUTPUTDIR))
546
547test-jdk-jtreg-native:
548	$(call RunTests, "jdk_native_sanity", $(JDK_IMAGE_DIR))
549
550test-make:
551	($(CD) $(SRC_ROOT)/test/make && $(MAKE) $(MAKE_ARGS) -f TestMake.gmk $(TEST_TARGET))
552
553ALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \
554    test-hotspot-internal test-hotspot-gtest test-jdk-jtreg-native test-make
555
556################################################################################
557# Bundles
558
559product-bundles:
560	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles)
561
562profiles-bundles:
563	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk profiles-bundles)
564
565test-bundles:
566	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles)
567
568docs-bundles:
569	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles)
570
571ALL_TARGETS += product-bundles profiles-bundles test-bundles docs-bundles
572
573################################################################################
574# Install targets
575
576install:
577	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Install.gmk)
578
579ALL_TARGETS += install
580
581################################################################################
582#
583# Dependency declarations between targets.
584#
585# These are declared in two groups. First all dependencies between targets that
586# have recipes above as these dependencies may be disabled. Then the aggregator
587# targets that do not have recipes of their own, which will never have their
588# dependencies disabled.
589#
590################################################################################
591# Targets with recipes above
592
593# If running an *-only target, parallel execution and dependencies between
594# recipe targets are disabled. This makes it possible to run a select set of
595# recipe targets in order. It's the responsibility of the user to make sure
596# all prerequisites are fulfilled.
597ifneq ($(findstring -only, $(MAKECMDGOALS)), )
598  .NOTPARALLEL:
599else
600  $(LANGTOOLS_GENSRC_TARGETS): buildtools-langtools
601
602  interim-langtools: $(LANGTOOLS_GENSRC_TARGETS)
603
604  buildtools-jdk: interim-langtools interim-cldrconverter
605
606  buildtools-hotspot: interim-langtools
607
608  buildtools-modules: exploded-image-base
609
610  $(CORBA_GENSRC_TARGETS): interim-langtools
611
612  $(HOTSPOT_GENSRC_TARGETS): interim-langtools buildtools-hotspot
613
614  $(JDK_GENSRC_TARGETS): interim-langtools buildtools-jdk
615
616  $(GENSRC_MODULEINFO_TARGETS): buildtools-jdk
617
618  $(GENDATA_TARGETS): interim-langtools buildtools-jdk
619
620  interim-rmic: interim-langtools
621
622  $(RMIC_TARGETS): interim-langtools interim-rmic
623
624  $(JAVA_TARGETS): interim-langtools
625
626  # Declare dependencies between hotspot-<variant>* targets
627  $(foreach v, $(JVM_VARIANTS), \
628      $(eval hotspot-$v: hotspot-$v-gensrc hotspot-$v-libs) \
629      $(eval hotspot-$v-libs: hotspot-$v-gensrc) \
630  )
631
632  hotspot-ide-project: hotspot exploded-image
633
634  generate-exported-symbols: java.base-libs jdk.jdwp.agent-libs
635
636  # Building one JVM variant is enough to start building the other libs
637  $(LIBS_TARGETS): hotspot-$(JVM_VARIANT_MAIN)-libs
638
639  $(LAUNCHER_TARGETS): java.base-libs
640
641  ifeq ($(STATIC_BUILD), true)
642    $(LAUNCHER_TARGETS): generate-exported-symbols
643  endif
644
645  # The demos are currently linking to libjvm and libjava, just like all other
646  # jdk libs, even though they don't need to. To avoid warnings, make sure they
647  # aren't built until after libjava and libjvm are available to link to.
648  demos-jdk: java.base-libs exploded-image-optimize
649  test-image-demos-jdk: demos-jdk
650
651  # Declare dependency from <module>-java to <module>-gensrc
652  $(foreach m, $(GENSRC_MODULES), $(eval $m-java: $m-gensrc))
653
654  # Declare dependencies between java modules
655  $(foreach m, $(JAVA_MODULES), \
656      $(eval $m-java: $(addsuffix -java, $(filter $(JAVA_MODULES), \
657      $(call FindDepsForModule,$m)))))
658
659  # Declare dependencies between <module>-rmic to <module>-java
660  $(foreach m, $(RMIC_MODULES), $(eval $m-rmic: $m-java))
661
662  # Declare dependencies from <module>-lib to <module>-java
663  # Skip modules that do not have java source.
664  # When creating a BUILDJDK, the java compilation has already been done by the
665  # normal build and copied in.
666  ifneq ($(CREATING_BUILDJDK), true)
667    $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs: $m-java))
668  endif
669
670  # Declare dependencies from all other <module>-lib to java.base-lib
671  $(foreach t, $(filter-out java.base-libs, $(LIBS_TARGETS)), \
672      $(eval $t: java.base-libs))
673
674  # jdk.accessibility depends on java.desktop
675  jdk.accessibility-libs: java.desktop-libs
676
677  # This dependency needs to be explicitly declared. jdk.jdi-gensrc generates a
678  # header file used by jdk.jdwp.agent-libs. The jdk.jdwp.agent-gensrc is a
679  # virtual target.
680  jdk.jdwp.agent-libs: jdk.jdwp.agent-gensrc
681
682  # The swing beans need to have java base properly generated to avoid errors
683  # in javadoc.
684  java.desktop-gensrc-jdk: java.base-gensrc
685
686  # The annotation processing for jdk.internal.vm.ci and jdk.internal.vm.compiler
687  # needs classes from the current JDK.
688  jdk.internal.vm.ci-gensrc-hotspot: $(addsuffix -java, \
689      $(call FindTransitiveDepsForModule, jdk.internal.vm.ci))
690  jdk.internal.vm.compiler-gensrc-hotspot: $(addsuffix -java, \
691      $(call FindTransitiveDepsForModule, jdk.internal.vm.compiler))
692
693  # For jdk.internal.vm.compiler, the gensrc step is generating a module-info.java.extra
694  # file to be processed by the gensrc-moduleinfo target.
695  jdk.internal.vm.compiler-gensrc-moduleinfo: jdk.internal.vm.compiler-gensrc-hotspot
696
697  # Explicitly add dependencies for special targets
698  java.base-java: unpack-sec
699
700  jdk.jdeps-gendata: java rmic
701
702  # The ct.sym generation uses all the moduleinfos as input
703  jdk.compiler-gendata: $(GENSRC_MODULEINFO_TARGETS)
704
705  # Declare dependencies between jmod targets.
706  # java.base jmod needs jrt-fs.jar and access to the other jmods to be built.
707  # When creating a BUILDJDK, we don't need to add hashes to java.base, thus
708  # we don't need to depend on all other jmods
709  ifneq ($(CREATING_BUILDJDK), true)
710    java.base-jmod: jrtfs-jar $(filter-out java.base-jmod, $(JMOD_TARGETS))
711  endif
712
713  # Building java.base-jmod requires all of hotspot to be built.
714  java.base-jmod: hotspot
715
716  # Declare dependencies from <module>-jmod to all other module targets
717  # When creating a BUILDJDK, the java compilation has already been done by the
718  # normal build and copied in.
719  ifneq ($(CREATING_BUILDJDK), true)
720    $(foreach m, $(JAVA_MODULES), $(eval $m_JMOD_DEPS += $m-java))
721  endif
722  $(foreach m, $(GENDATA_MODULES), $(eval $m_JMOD_DEPS += $m-gendata))
723  $(foreach m, $(RMIC_MODULES), $(eval $m_JMOD_DEPS += $m-rmic))
724  $(foreach m, $(LIBS_MODULES), $(eval $m_JMOD_DEPS += $m-libs))
725  $(foreach m, $(LAUNCHER_MODULES), $(eval $m_JMOD_DEPS += $m-launchers))
726  $(foreach m, $(COPY_MODULES), $(eval $m_JMOD_DEPS += $m-copy))
727  $(foreach m, $(ALL_MODULES), $(eval $m-jmod: $($(m)_JMOD_DEPS)))
728  $(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $m-interim-jmod: $($(m)_JMOD_DEPS)))
729
730  # Jmods cannot be created until we have the jmod tool ready to run. During
731  # a normal build we run it from the exploded image, but when cross compiling
732  # it's run from the buildjdk, which is either created at build time or user
733  # supplied.
734  #
735  # For the exploded image to be runnable, all java modules and
736  # jdk.jlink-launchers need to be built. We also need to copy jvm.cfg (done
737  # in java.base-copy) and tzdb.dat (done in java.base-gendata) to the
738  # appropriate location otherwise jimage, jlink and jmod won't start. This
739  # also applies when creating the buildjdk.
740  DEFAULT_JMOD_DEPS := java.base-libs java.base-copy java.base-gendata \
741      jdk.jlink-launchers
742  # When cross compiling and buildjdk is to be created, depend on creating the
743  # buildjdk instead of the default dependencies.
744  ifeq ($(CREATE_BUILDJDK), true)
745    # Avoid calling create-buildjdk from within a create-buildjdk call.
746    ifneq ($(CREATING_BUILDJDK), true)
747      $(JMOD_TARGETS): create-buildjdk
748      buildtools-modules: create-buildjdk
749    else
750      # While actually creating the buildjdk, the default deps applies.
751      $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
752    endif
753  else
754    # The normal non cross compilation case uses the default deps.
755    # To avoid races with the optimize target, that also needs to happen first.
756    $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) \
757        exploded-image-optimize
758  endif
759
760  # All modules include the main license files from java.base.
761  $(JMOD_TARGETS): java.base-copy
762
763  zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
764      $(filter jdk.crypto%, $(JAVA_TARGETS))
765
766  zip-source: gensrc rmic
767
768  jrtfs-jar: interim-langtools
769
770  ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
771    ifeq ($(CREATE_BUILDJDK), true)
772      # If creating a buildjdk, the interim image needs to be based on that.
773      generate-link-opt-data: create-buildjdk
774    else ifeq ($(EXTERNAL_BUILDJDK), false)
775      # If an external buildjdk has been provided, we skip generating an
776      # interim-image and just use the external buildjdk for generating
777      # classlist.
778      generate-link-opt-data: interim-image
779    endif
780    generate-link-opt-data: buildtools-jdk
781
782    # The generated classlist needs to go into java.base-jmod.
783    java.base-jmod jdk.jlink-jmod jdk-image jre-image: generate-link-opt-data
784  endif
785
786  release-file: create-source-revision-tracker
787
788  jdk-image: jmods zip-source demos release-file
789  jre-image: jmods release-file
790  symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS)
791
792  profiles-image: jmods release-file
793
794  mac-bundles-jdk: jdk-image jre-image
795
796  # The optimize target can run as soon as the modules dir has been completely
797  # populated (java, copy and gendata targets) and the basic libs and launchers
798  # have been built.
799  exploded-image-optimize: java copy gendata java.base-libs java.base-launchers \
800      buildtools-modules
801
802  bootcycle-images: jdk-image
803
804  docs-jdk-api-javadoc: $(GENSRC_TARGETS) rmic
805
806  docs-javase-api-javadoc: $(GENSRC_TARGETS) rmic
807
808  docs-jdk-api-modulegraph: exploded-image buildtools-modules
809
810  docs-javase-api-modulegraph: exploded-image buildtools-modules
811
812  # The gensrc steps for hotspot and jdk.jdi create html spec files.
813  docs-jdk-specs: hotspot-$(JVM_VARIANT_MAIN)-gensrc jdk.jdi-gensrc \
814      docs-jdk-index
815
816  docs-jdk-index: exploded-image buildtools-modules
817
818  docs-zip: docs-jdk
819
820  test: jdk-image test-image
821
822  run-test: jdk-image test-image
823  exploded-run-test: exploded-image test-image
824
825  # Declare dependency for all generated test targets
826  $(foreach t, $(ALL_TEST_TARGETS), $(eval $t: jdk-image test-image))
827  $(foreach t, $(ALL_EXPLODED_TEST_TARGETS), $(eval $t: exploded-image test-image))
828
829  create-buildjdk-copy: jdk.jlink-java java.base-gendata \
830      $(addsuffix -java, $(INTERIM_IMAGE_MODULES))
831
832  create-buildjdk-interim-image: create-buildjdk-copy
833
834  interim-image: $(INTERIM_JMOD_TARGETS)
835
836  test-make: clean-test-make
837
838  build-test-lib: exploded-image-optimize
839
840  build-test-failure-handler: interim-langtools
841
842  test-failure-handler: build-test-failure-handler
843
844  test-image-failure-handler: build-test-failure-handler
845
846  build-test-hotspot-jtreg-native: buildtools-jdk \
847      hotspot-$(JVM_VARIANT_MAIN)-libs
848
849  build-test-jdk-jtreg-native: buildtools-jdk java.base-libs
850
851  test-image-hotspot-jtreg-native: build-test-hotspot-jtreg-native
852
853  test-image-jdk-jtreg-native: build-test-jdk-jtreg-native
854
855  test-image-hotspot-gtest: hotspot
856
857  test-hotspot-internal: exploded-image
858
859  test-hotspot-jtreg: jdk-image test-image
860
861  test-hotspot-gtest: exploded-image test-image-hotspot-gtest
862
863  install: product-images
864
865  product-bundles: product-images
866
867  profiles-bundles: profiles-images
868
869  test-bundles: test-image
870
871  docs-bundles: docs-image
872
873  generate-summary: jmods buildtools-modules
874
875endif
876
877################################################################################
878# Virtual targets without recipes
879
880buildtools: buildtools-langtools interim-langtools interim-rmic \
881    buildtools-jdk buildtools-hotspot
882
883hotspot: $(HOTSPOT_VARIANT_TARGETS) hotspot-jsig
884
885hotspot-libs: hotspot-jsig
886
887# Create targets hotspot-libs and hotspot-gensrc.
888$(foreach v, $(JVM_VARIANTS), \
889  $(eval hotspot-libs: hotspot-$v-libs) \
890  $(eval hotspot-gensrc: hotspot-$v-gensrc) \
891)
892
893gensrc: $(GENSRC_TARGETS)
894
895gendata: $(GENDATA_TARGETS)
896
897copy: $(ALL_COPY_TARGETS)
898
899java: $(JAVA_TARGETS)
900
901rmic: $(RMIC_TARGETS)
902
903libs: $(LIBS_TARGETS)
904
905launchers: $(LAUNCHER_TARGETS)
906
907jmods: $(JMOD_TARGETS)
908
909# Explicitly declare dependency for virtual target jdk.jdwp.agent-gensrc which
910# is actually handled by jdk.jdi-gensrc
911jdk.jdwp.agent-gensrc: jdk.jdi-gensrc
912
913# Declare dependencies from <module> to all the individual targets specific
914# to that module <module>-*, that are needed for the exploded image.
915$(foreach m, $(GENSRC_MODULES), $(eval $m: $m-gensrc))
916$(foreach m, $(JAVA_MODULES), $(eval $m: $m-java))
917$(foreach m, $(GENDATA_MODULES), $(eval $m: $m-gendata))
918$(foreach m, $(RMIC_MODULES), $(eval $m: $m-rmic))
919$(foreach m, $(LIBS_MODULES), $(eval $m: $m-libs))
920$(foreach m, $(LAUNCHER_MODULES), $(eval $m: $m-launchers))
921$(foreach m, $(ALL_COPY_MODULES), $(eval $m: $m-copy))
922
923# Building java.base includes building all of hotspot.
924java.base: hotspot
925
926demos: demos-jdk
927
928# The "exploded image" is a locally runnable JDK in $(BUILD_OUTPUT)/jdk.
929exploded-image-base: $(ALL_MODULES)
930exploded-image: exploded-image-base release-file
931# When cross compiling, no need to optimize the exploded image since it won't
932# be runnable on the host platform anyway.
933ifneq ($(COMPILE_TYPE), cross)
934  exploded-image: exploded-image-optimize
935endif
936
937create-buildjdk: create-buildjdk-copy create-buildjdk-interim-image
938
939docs-jdk-api: docs-jdk-api-javadoc
940docs-javase-api: docs-javase-api-javadoc
941
942# If we're building full docs, we must also generate the module graphs to
943# get non-broken api documentation.
944ifeq ($(ENABLE_FULL_DOCS), true)
945  docs-jdk-api: docs-jdk-api-modulegraph
946  docs-javase-api: docs-javase-api-modulegraph
947endif
948
949docs-jdk: docs-jdk-api docs-jdk-specs docs-jdk-index
950docs-javase: docs-javase-api
951
952# alias for backwards compatibility
953docs-javadoc: docs-jdk-api
954
955mac-bundles: mac-bundles-jdk
956
957# The $(BUILD_OUTPUT)/images directory contain the resulting deliverables,
958# and in line with this, our targets for creating these are named *-image[s].
959
960# This target builds the product images, e.g. the JRE and JDK image
961# (and possibly other, more specific versions)
962product-images: jdk-image jre-image symbols-image exploded-image
963
964# zip-security is actually a bundle, but for now it needs to be considered
965# an image until this can be cleaned up properly.
966product-images: zip-security
967
968# Declare these for backwards compatiblity and convenience.
969profiles profiles-images: profiles-image
970
971# The module summary cannot be run when:
972# * Cross compiling and building a partial BUILDJDK for the build host
973# * An external buildjdk has been supplied since it may not match the
974#   module selection of the target jdk
975ifneq ($(CREATE_BUILDJDK), true)
976  ifeq ($(EXTERNAL_BUILDJDK), false)
977    product-images: generate-summary
978  endif
979endif
980
981ifeq ($(OPENJDK_TARGET_OS), macosx)
982  product-images: mac-bundles
983endif
984
985# This target builds the documentation image
986docs-image: docs-jdk
987
988# This target builds the test image
989test-image: prepare-test-image test-image-hotspot-jtreg-native \
990    test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest \
991    test-image-demos-jdk
992
993# all-images builds all our deliverables as images.
994all-images: product-images test-image docs-image
995
996# all-bundles packages all our deliverables as tar.gz bundles.
997all-bundles: product-bundles test-bundles docs-bundles
998
999ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-gensrc gensrc gendata \
1000    copy java rmic libs launchers jmods \
1001    jdk.jdwp.agent-gensrc $(ALL_MODULES) demos \
1002    exploded-image-base exploded-image \
1003    create-buildjdk docs-jdk-api docs-javase-api docs-jdk docs-javase \
1004    docs-javadoc mac-bundles product-images \
1005    profiles profiles-images \
1006    docs-image test-image all-images \
1007    all-bundles
1008
1009################################################################################
1010
1011# Traditional targets typically run by users.
1012# These can be considered aliases for the targets now named by a more
1013# "modern" naming scheme.
1014default: $(DEFAULT_MAKE_TARGET)
1015jdk: exploded-image
1016images: product-images
1017docs: docs-image
1018bundles: all-bundles
1019all: all-images
1020
1021ALL_TARGETS += default jdk images docs bundles all
1022
1023################################################################################
1024################################################################################
1025#
1026# Clean targets
1027#
1028################################################################################
1029# Clean targets are automatically run serially by the Makefile calling this
1030# file.
1031
1032CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
1033    images make-support test-make bundles buildjdk
1034CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
1035CLEAN_SUPPORT_DIRS += demos
1036CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
1037CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
1038CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
1039CLEAN_PHASES := gensrc java native include
1040CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
1041CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
1042# Construct targets of the form clean-$module-$phase
1043CLEAN_MODULE_PHASE_TARGETS := $(addprefix clean-, $(foreach m, $(ALL_MODULES), \
1044    $(addprefix $m-, $(CLEAN_PHASES))))
1045
1046# Remove everything, except the output from configure.
1047clean: $(CLEAN_DIR_TARGETS)
1048	($(CD) $(OUTPUT_ROOT) && $(RM) -r build*.log*)
1049	$(ECHO) Cleaned all build artifacts.
1050
1051clean-docs:
1052	$(call CleanDocs)
1053
1054$(CLEAN_DIR_TARGETS):
1055	$(call CleanDir,$(patsubst clean-%, %, $@))
1056
1057$(CLEAN_SUPPORT_DIR_TARGETS):
1058	$(call CleanSupportDir,$(patsubst clean-%, %, $@))
1059
1060$(CLEAN_TEST_TARGETS):
1061	$(call CleanTest,$(patsubst clean-test-%, %, $@))
1062
1063$(CLEAN_PHASE_TARGETS):
1064	$(call Clean-$(patsubst clean-%,%, $@))
1065
1066$(CLEAN_MODULE_TARGETS):
1067	$(call CleanModule,$(patsubst clean-%, %, $@))
1068
1069$(CLEAN_MODULE_PHASE_TARGETS):
1070	$(call Clean-$(word 3, $(subst -,$(SPACE),$@)), \
1071	    $(word 2, $(subst -,$(SPACE),$@)))
1072
1073# When removing the support dir, we must also remove jdk. Building classes has
1074# the side effect of generating native headers. The headers end up in support
1075# while classes and touch files end up in jdk.
1076clean-support: clean-jdk
1077
1078# Remove everything, including configure configuration. If the output
1079# directory was created by configure and now becomes empty, remove it as well.
1080dist-clean: clean
1081	($(CD) $(OUTPUT_ROOT) && \
1082	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide)
1083	$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
1084	  if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
1085	    $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
1086	  else \
1087	    ($(CD) $(SRC_ROOT) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" \
1088	        && $(RM) -r $(OUTPUT_ROOT)) \
1089	  fi \
1090	)
1091	$(ECHO) Cleaned everything, you will have to re-run configure.
1092
1093ALL_TARGETS += clean clean-docs dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_SUPPORT_DIR_TARGETS) \
1094    $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) $(CLEAN_MODULE_TARGETS) \
1095    $(CLEAN_MODULE_PHASE_TARGETS)
1096
1097################################################################################
1098# Declare *-only targets for each normal target
1099$(foreach t, $(ALL_TARGETS), $(eval $(t)-only: $(t)))
1100
1101ALL_TARGETS += $(addsuffix -only, $(filter-out dist-clean clean%, $(ALL_TARGETS)))
1102
1103################################################################################
1104
1105# Include JPRT targets
1106include $(SRC_ROOT)/make/Jprt.gmk
1107
1108################################################################################
1109
1110# The following targets are intentionally not added to ALL_TARGETS since they
1111# are internal only, to support Init.gmk.
1112
1113print-targets:
1114	  @$(ECHO) $(sort $(ALL_TARGETS))
1115
1116print-modules:
1117	  @$(ECHO) $(sort $(ALL_MODULES))
1118
1119print-tests:
1120	  @$(ECHO) $(sort $(ALL_NAMED_TESTS))
1121
1122create-main-targets-include:
1123	  $(call LogInfo, Generating main target list)
1124	  @$(ECHO) ALL_MAIN_TARGETS := $(sort $(ALL_TARGETS)) > \
1125	      $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk
1126
1127################################################################################
1128
1129.PHONY: $(ALL_TARGETS)
1130
1131FRC: # Force target
1132