Main.gmk revision 2635:2c5c3648a45f
1344884Scy#
2275970Scy# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
3275970Scy# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4344884Scy#
5285169Scy# This code is free software; you can redistribute it and/or modify it
6275970Scy# under the terms of the GNU General Public License version 2 only, as
7275970Scy# published by the Free Software Foundation.  Oracle designates this
8275970Scy# particular file as subject to the "Classpath" exception as provided
9275970Scy# by Oracle in the LICENSE file that accompanied this code.
10275970Scy#
11275970Scy# This code is distributed in the hope that it will be useful, but WITHOUT
12275970Scy# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13275970Scy# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14275970Scy# version 2 for more details (a copy is included in the LICENSE file that
15275970Scy# accompanied this code).
16275970Scy#
17275970Scy# You should have received a copy of the GNU General Public License version
18285169Scy# 2 along with this work; if not, write to the Free Software Foundation,
19285169Scy# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20285169Scy#
21285169Scy# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22285169Scy# or visit www.oracle.com if you need additional information or have any
23285169Scy# questions.
24285169Scy#
25285169Scy
26285169Scy################################################################################
27285169Scy# This is the main makefile containing most actual top level targets. It needs
28285169Scy# to be called with a SPEC file defined.
29285169Scy################################################################################
30285169Scy
31285169Scy# Declare default target
32285169Scydefault:
33285169Scy
34285169Scyifeq ($(wildcard $(SPEC)),)
35285169Scy  $(error Main.gmk needs SPEC set to a proper spec.gmk)
36285169Scyendif
37285169Scy
38285169Scy# Now load the spec
39285169Scyinclude $(SPEC)
40285169Scy
41285169Scyinclude $(SRC_ROOT)/make/MainSupport.gmk
42285169Scy
43285169Scy# Load the vital tools for all the makefiles.
44285169Scyinclude $(SRC_ROOT)/make/common/MakeBase.gmk
45285169Scyinclude $(SRC_ROOT)/make/common/Modules.gmk
46285169Scyinclude $(SRC_ROOT)/make/common/FindTests.gmk
47285169Scy
48285169Scy# Declare ALL_TARGETS as an immediate variable. This variable is a list of all
49285169Scy# valid top level targets. It's used to declare them all as PHONY and to
50285169Scy# generate the -only targets.
51285169ScyALL_TARGETS :=
52285169Scy
53285169Scy# Hook to include the corresponding custom file, if present.
54285169Scy$(eval $(call IncludeCustomExtension, , Main.gmk))
55285169Scy
56285169Scy# All modules for the current target platform.
57285169ScyALL_MODULES := $(call FindAllModules)
58285169Scy
59285169Scy################################################################################
60285169Scy################################################################################
61285169Scy#
62285169Scy# Recipes for all targets. Only recipes, dependencies are declared later.
63285169Scy#
64285169Scy################################################################################
65285169Scy
66285169Scy################################################################################
67285169Scy# Interim/build tools targets, compiling tools used during the build
68285169Scy
69285169Scy# When creating a BUILDJDK, the buildtools and interim targets have already
70285169Scy# been built and should not be built again.
71285169Scyifneq ($(CREATING_BUILDJDK), true)
72285169Scy  buildtools-langtools:
73275970Scy	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Tools.gmk)
74275970Scy
75275970Scy  interim-langtools:
76275970Scy	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterim.gmk)
77275970Scy
78275970Scy  interim-rmic:
79275970Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterimRmic.gmk)
80275970Scy
81275970Scy  interim-cldrconverter:
82275970Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimCLDRConverter.gmk)
83275970Scy
84275970Scy  buildtools-jdk:
85275970Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)
86275970Scy
87275970Scy  buildtools-modules:
88275970Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileModuleTools.gmk)
89275970Scy
90275970Scy  buildtools-hotspot:
91275970Scy	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)
92275970Scyendif
93275970Scy
94275970ScyALL_TARGETS += buildtools-langtools interim-langtools \
95275970Scy    interim-rmic interim-cldrconverter buildtools-jdk buildtools-modules \
96275970Scy    buildtools-hotspot
97275970Scy
98275970Scy################################################################################
99275970Scy# Special targets for certain modules
100275970Scy
101275970Scyunpack-sec:
102275970Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UnpackSecurity.gmk)
103316068Sdelphij
104316068Sdelphijgenerate-exported-symbols:
105275970Scy	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildStatic.gmk)
106275970Scy
107275970ScyALL_TARGETS += unpack-sec generate-exported-symbols
108275970Scy
109275970Scy################################################################################
110275970Scy# Gensrc targets, generating source before java compilation can be done
111275970Scy#
112285169Scy# When creating a BUILDJDK, the java targets have already been built and copied
113275970Scy# into the buildjdk so no need to generate sources.
114282408Scyifneq ($(CREATING_BUILDJDK), true)
115282408Scy  $(eval $(call DeclareRecipesForPhase, GENSRC, \
116301247Sdelphij      TARGET_SUFFIX := gensrc, \
117301247Sdelphij      FILE_PREFIX := Gensrc, \
118301247Sdelphij      MAKE_SUBDIR := gensrc, \
119275970Scy      CHECK_MODULES := $(ALL_MODULES), \
120275970Scy      MULTIPLE_MAKEFILES := true))
121285169Scy
122285169Scy  JDK_GENSRC_TARGETS := $(filter %-gensrc-jdk, $(GENSRC_TARGETS))
123275970Scy  LANGTOOLS_GENSRC_TARGETS := $(filter %-gensrc-langtools, $(GENSRC_TARGETS))
124275970Scy  CORBA_GENSRC_TARGETS := $(filter %-gensrc-corba, $(GENSRC_TARGETS))
125275970Scy  HOTSPOT_GENSRC_TARGETS := $(filter %-gensrc-hotspot, $(GENSRC_TARGETS))
126275970Scy
127285169Scy  GENSRC_MODULEINFO_MODULES := $(ALL_MODULES)
128285169Scy  GENSRC_MODULEINFO_TARGETS := $(addsuffix -gensrc-moduleinfo, \
129285169Scy      $(GENSRC_MODULEINFO_MODULES))
130285169Scy
131285169Scy  GENSRC_MODULES := $(GENSRC_MODULEINFO_MODULES)
132285169Scy  GENSRC_TARGETS += $(sort $(GENSRC_MODULEINFO_TARGETS) \
133285169Scy      $(addsuffix -gensrc, $(GENSRC_MODULES)))
134285169Scy
135285169Scy  define DeclareModuleInfoRecipe
136285169Scy    $1-gensrc-moduleinfo:
137275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
138285169Scy	    -f GensrcModuleInfo.gmk MODULE=$1)
139275970Scy
140275970Scy    $1-gensrc: $1-gensrc-moduleinfo
141285169Scy  endef
142285169Scy
143285169Scy  $(foreach m, $(GENSRC_MODULEINFO_MODULES), $(eval $(call DeclareModuleInfoRecipe,$m)))
144285169Scyendif
145285169Scy
146275970ScyALL_TARGETS += $(GENSRC_TARGETS)
147285169Scy
148285169Scy################################################################################
149275970Scy# Generate data targets
150275970Scy$(eval $(call DeclareRecipesForPhase, GENDATA, \
151275970Scy    TARGET_SUFFIX := gendata, \
152275970Scy    FILE_PREFIX := Gendata, \
153275970Scy    MAKE_SUBDIR := gendata, \
154275970Scy    CHECK_MODULES := $(ALL_MODULES), \
155275970Scy    USE_WRAPPER := true))
156275970Scy
157275970ScyALL_TARGETS += $(GENDATA_TARGETS)
158275970Scy
159289764Sglebius################################################################################
160275970Scy# Copy files targets
161275970Scy$(eval $(call DeclareRecipesForPhase, COPY, \
162275970Scy    TARGET_SUFFIX := copy, \
163275970Scy    FILE_PREFIX := Copy, \
164275970Scy    MAKE_SUBDIR := copy, \
165275970Scy    CHECK_MODULES := $(ALL_MODULES), \
166275970Scy    USE_WRAPPER := true, \
167275970Scy    MULTIPLE_MAKEFILES := true))
168289764Sglebius
169275970ScyALL_COPY_MODULES += $(COPY_MODULES)
170275970ScyALL_COPY_TARGETS += $(COPY_TARGETS)
171275970Scy
172275970ScyIMPORT_COPY_MODULES := $(call FindImportedModules)
173275970ScyIMPORT_COPY_TARGETS := $(addsuffix -copy, $(IMPORT_COPY_MODULES))
174275970ScyALL_COPY_MODULES += $(IMPORT_COPY_MODULES)
175275970ScyALL_COPY_TARGETS += $(IMPORT_COPY_TARGETS)
176275970Scy
177275970Scydefine DeclareImportCopyRecipe
178275970Scy  $1-copy:
179275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
180275970Scy	    -f CopyImportModules.gmk MODULE=$1)
181275970Scyendef
182275970Scy
183275970Scy$(foreach m, $(IMPORT_COPY_MODULES), $(eval $(call DeclareImportCopyRecipe,$m)))
184275970Scy
185275970ScyALL_TARGETS += $(ALL_COPY_TARGETS)
186275970Scy
187275970Scy################################################################################
188275970Scy# Targets for compiling all java modules. Nashorn is treated separately.
189275970ScyJAVA_MODULES := $(ALL_MODULES)
190275970ScyJAVA_TARGETS := $(addsuffix -java, $(JAVA_MODULES))
191275970Scy
192275970Scydefine DeclareCompileJavaRecipe
193275970Scy  $1-java:
194275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
195275970Scy	    -f CompileJavaModules.gmk MODULE=$1)
196275970Scyendef
197280849Scy
198275970Scy$(foreach m, $(filter-out jdk.scripting.nashorn, $(JAVA_MODULES)), \
199275970Scy    $(eval $(call DeclareCompileJavaRecipe,$m)))
200275970Scy
201275970Scy# Build nashorn. Needs to be compiled separately from the rest of the modules
202275970Scy# due to nasgen.
203275970Scyjdk.scripting.nashorn-java:
204275970Scy	+($(CD) $(NASHORN_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
205275970Scy	    -f BuildNashorn.gmk compile)
206275970Scy
207275970ScyALL_TARGETS += $(JAVA_TARGETS)
208275970Scy
209275970Scy################################################################################
210275970Scy# Targets for running rmic.
211275970Scy$(eval $(call DeclareRecipesForPhase, RMIC, \
212275970Scy    TARGET_SUFFIX := rmic, \
213289764Sglebius    FILE_PREFIX := Rmic, \
214275970Scy    MAKE_SUBDIR := rmic, \
215316068Sdelphij    CHECK_MODULES := $(ALL_MODULES)))
216275970Scy
217275970ScyALL_TARGETS += $(RMIC_TARGETS)
218275970Scy
219275970Scy################################################################################
220275970Scy# Targets for compiling native libraries
221275970Scy$(eval $(call DeclareRecipesForPhase, LIBS, \
222275970Scy    TARGET_SUFFIX := libs, \
223275970Scy    FILE_PREFIX := Lib, \
224275970Scy    MAKE_SUBDIR := lib, \
225275970Scy    CHECK_MODULES := $(ALL_MODULES), \
226275970Scy    USE_WRAPPER := true))
227275970Scy
228275970ScyALL_TARGETS += $(LIBS_TARGETS)
229275970Scy
230275970Scy################################################################################
231275970Scy# Targets for compiling native executables
232275970Scy$(eval $(call DeclareRecipesForPhase, LAUNCHER, \
233275970Scy    TARGET_SUFFIX := launchers, \
234275970Scy    FILE_PREFIX := Launcher, \
235275970Scy    MAKE_SUBDIR := launcher, \
236275970Scy    CHECK_MODULES := $(ALL_MODULES), \
237275970Scy    USE_WRAPPER := true))
238275970Scy
239275970ScyALL_TARGETS += $(LAUNCHER_TARGETS)
240275970Scy
241275970Scy################################################################################
242275970Scy# Build hotspot target
243275970Scy
244275970ScyHOTSPOT_VARIANT_TARGETS := $(addprefix hotspot-, $(JVM_VARIANTS))
245275970ScyHOTSPOT_VARIANT_GENSRC_TARGETS := $(addsuffix -gensrc, $(HOTSPOT_VARIANT_TARGETS))
246275970ScyHOTSPOT_VARIANT_LIBS_TARGETS := $(addsuffix -libs, $(HOTSPOT_VARIANT_TARGETS))
247275970Scy
248275970Scydefine DeclareHotspotGensrcRecipe
249275970Scy  hotspot-$1-gensrc:
250275970Scy	$$(call LogInfo, Building JVM variant '$1' with features '$(JVM_FEATURES_$1)')
251275970Scy	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f gensrc/GenerateSources.gmk \
252275970Scy	    JVM_VARIANT=$1)
253275970Scyendef
254275970Scy
255275970Scy$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotGensrcRecipe,$v)))
256275970Scy
257275970Scydefine DeclareHotspotLibsRecipe
258275970Scy  hotspot-$1-libs:
259275970Scy	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibraries.gmk \
260275970Scy	    JVM_VARIANT=$1)
261275970Scyendef
262275970Scy
263275970Scy$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotLibsRecipe,$v)))
264275970Scy
265275970Scyhotspot-jsig:
266275970Scy	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibjsig.gmk)
267275970Scy
268316068Sdelphijhotspot-ide-project:
269316068Sdelphij	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ide/CreateVSProject.gmk)
270316068Sdelphij
271275970ScyALL_TARGETS += $(HOTSPOT_VARIANT_TARGETS) $(HOTSPOT_VARIANT_GENSRC_TARGETS) \
272275970Scy    $(HOTSPOT_VARIANT_LIBS_TARGETS) hotspot-jsig hotspot-ide-project
273275970Scy
274275970Scy################################################################################
275275970Scy# Build demos targets
276275970Scy
277275970Scydemos-jdk:
278275970Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk)
279275970Scy
280275970Scytest-image-demos-jdk:
281275970Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk images)
282275970Scy
283275970ScyALL_TARGETS += demos-jdk test-image-demos-jdk
284275970Scy
285275970Scy################################################################################
286275970Scy# Jigsaw specific data and analysis targets.
287275970Scy
288275970Scygenerate-summary:
289275970Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f GenerateModuleSummary.gmk)
290275970Scy
291275970ScyALL_TARGETS += generate-summary
292285169Scy
293275970Scy################################################################################
294275970Scy# Jmod targets
295275970Scy
296275970ScyJMOD_MODULES := $(ALL_MODULES)
297275970ScyJMOD_TARGETS := $(addsuffix -jmod, $(JMOD_MODULES))
298275970Scy
299275970Scydefine DeclareJmodRecipe
300275970Scy  $1-jmod:
301275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
302275970Scy	    MODULE=$1)
303275970Scyendef
304275970Scy
305275970Scy$(foreach m, $(JMOD_MODULES), $(eval $(call DeclareJmodRecipe,$m)))
306275970Scy
307275970ScyALL_TARGETS += $(JMOD_TARGETS)
308275970Scy
309275970Scy################################################################################
310275970Scy# Images targets
311275970Scy
312275970Scystore-source-revision:
313275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk store-source-revision)
314275970Scy
315275970Scycreate-source-revision-tracker:
316275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk create-source-revision-tracker)
317275970Scy
318275970ScyBOOTCYCLE_TARGET := product-images
319282408Scybootcycle-images:
320282408Scy        ifneq ($(COMPILE_TYPE), cross)
321282408Scy	  $(call LogWarn, Boot cycle build step 2: Building a new JDK image using previously built image)
322282408Scy	  +$(MAKE) $(MAKE_ARGS) -f $(SRC_ROOT)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
323282408Scy	      JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
324275970Scy        else
325275970Scy	  $(call LogWarn, Boot cycle build disabled when cross compiling)
326275970Scy        endif
327275970Scy
328275970Scyzip-security:
329275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSecurity.gmk)
330275970Scy
331275970Scyzip-source:
332275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSource.gmk)
333275970Scy
334275970Scyjrtfs-jar:
335275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f JrtfsJar.gmk)
336275970Scy
337275970Scyjdk-image:
338275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jdk)
339275970Scy
340275970Scyjre-image:
341275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jre)
342275970Scy
343275970Scysymbols-image:
344275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk symbols)
345275970Scy
346275970Scyprofiles-image:
347275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)
348275970Scy
349275970Scymac-bundles-jdk:
350275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk)
351275970Scy
352275970Scyrelease-file:
353275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ReleaseFile.gmk)
354275970Scy
355275970Scyexploded-image-optimize:
356275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk)
357275970Scy
358275970ScyALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \
359275970Scy    zip-source jrtfs-jar jdk-image jre-image \
360275970Scy    symbols-image profiles-image mac-bundles-jdk \
361275970Scy    release-file exploded-image-optimize
362275970Scy
363275970Scy################################################################################
364275970Scy# Docs targets
365275970Scy
366275970Scy# If building full docs, to complete docs-*-api we need both the javadoc and
367275970Scy# modulegraph targets.
368275970Scydocs-jdk-api-javadoc:
369275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-api-javadoc)
370275970Scy
371275970Scydocs-jdk-api-modulegraph:
372275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-api-modulegraph)
373275970Scy
374275970Scydocs-javase-api-javadoc:
375275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-javase-api-javadoc)
376275970Scy
377275970Scydocs-javase-api-modulegraph:
378275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-javase-api-modulegraph)
379275970Scy
380275970Scydocs-jdk-specs:
381275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-specs)
382275970Scy
383275970Scydocs-jdk-index:
384275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-index)
385275970Scy
386275970Scydocs-zip:
387275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-zip)
388275970Scy
389275970Scyupdate-build-docs:
390275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f UpdateBuildDocs.gmk)
391275970Scy
392275970ScyALL_TARGETS += docs-jdk-api-javadoc docs-jdk-api-modulegraph \
393275970Scy    docs-javase-api-javadoc docs-javase-api-modulegraph docs-jdk-specs \
394275970Scy    docs-jdk-index docs-zip update-build-docs
395275970Scy
396275970Scy################################################################################
397275970Scy# Cross compilation support
398275970Scy
399275970Scyifeq ($(CREATING_BUILDJDK), true)
400275970Scy  # This target is only called by the recursive call below.
401275970Scy  create-buildjdk-interim-image-helper: interim-image jdk.jlink-launchers \
402275970Scy      java.base-copy jdk.jdeps-launchers
403275970Scyendif
404275970Scy
405275970Scycreate-buildjdk-copy:
406275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateBuildJdkCopy.gmk)
407275970Scy
408275970Scycreate-buildjdk-interim-image:
409275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Main.gmk \
410275970Scy	    $@-helper \
411275970Scy	    SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
412275970Scy	    HOTSPOT_SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
413275970Scy	    CREATING_BUILDJDK=true)
414275970Scy
415275970ScyALL_TARGETS += create-buildjdk-copy create-buildjdk-interim-image
416275970Scy
417275970Scy################################################################################
418275970Scy# The interim-image is a small jlinked image that is used to generate artifacts
419275970Scy# at build time for use when linking the real images.
420275970Scy
421275970ScyINTERIM_JMOD_TARGETS := $(addsuffix -interim-jmod, $(INTERIM_IMAGE_MODULES))
422275970Scy
423275970Scydefine DeclareInterimJmodRecipe
424275970Scy  $1-interim-jmod:
425275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
426275970Scy	    MODULE=$1 \
427275970Scy	    JMODS_DIR=$(INTERIM_JMODS_DIR) \
428275970Scy	    JMODS_TEMPDIR=$(INTERIM_JMODS_DIR)/temp \
429285169Scy	    INTERIM_JMOD=true \
430275970Scy	)
431285169Scyendef
432275970Scy
433285169Scy$(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $(call DeclareInterimJmodRecipe,$m)))
434275970Scy
435285169Scyinterim-image:
436275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f InterimImage.gmk)
437275970Scy
438275970Scyifeq ($(ENABLE_GENERATE_CLASSLIST), true)
439275970Scy  generate-link-opt-data:
440275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f GenerateLinkOptData.gmk)
441275970Scyendif
442275970Scy
443275970ScyALL_TARGETS += $(INTERIM_JMOD_TARGETS) interim-image generate-link-opt-data
444275970Scy
445275970Scy################################################################################
446275970Scy# Generate test names for all JTReg test groups
447275970Scy#
448275970Scy
449275970Scydefine DeclareRunTestRecipe
450275970Scy  run-test-$1:
451275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$1")
452275970Scy
453275970Scy  exploded-run-test-$1:
454275970Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \
455275970Scy	    TEST="$1" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
456275970Scy
457275970Scyendef
458275970Scy
459275970Scy# ALL_NAMED_TESTS is defined in FindTests.gmk
460275970Scy$(foreach t, $(ALL_NAMED_TESTS), $(eval $(call DeclareRunTestRecipe,$t)))
461275970ScyALL_TEST_TARGETS := $(addprefix run-test-, $(ALL_NAMED_TESTS))
462275970ScyALL_EXPLODED_TEST_TARGETS := $(addprefix exploded-run-test-, $(ALL_NAMED_TESTS))
463275970Scy
464275970ScyALL_TARGETS += $(ALL_TEST_TARGETS) $(ALL_EXPLODED_TEST_TARGETS)
465275970Scy
466275970Scy################################################################################
467275970Scy# Build tests
468275970Scy#
469275970Scy
470275970Scyprepare-test-image:
471275970Scy	$(MKDIR) -p $(TEST_IMAGE_DIR)
472275970Scy	$(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image'
473275970Scy
474275970Scybuild-test-hotspot-jtreg-native:
475275970Scy	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
476275970Scy	    build-test-hotspot-jtreg-native)
477275970Scy
478275970Scytest-image-hotspot-jtreg-native:
479275970Scy	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
480285169Scy	    test-image-hotspot-jtreg-native)
481285169Scy
482285169Scybuild-test-jdk-jtreg-native:
483285169Scy	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
484285169Scy	    build-test-jdk-jtreg-native)
485285169Scy
486285169Scytest-image-jdk-jtreg-native:
487285169Scy	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
488285169Scy	    test-image-jdk-jtreg-native)
489275970Scy
490275970Scyrun-test:
491275970Scy	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$(TEST)")
492275970Scy
493275970Scyexploded-run-test:
494275970Scy	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \
495275970Scy	    TEST="$(TEST)" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
496275970Scy
497275970Scyifeq ($(BUILD_GTEST), true)
498275970Scy  test-image-hotspot-gtest:
499275970Scy	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f GtestImage.gmk)
500275970Scyendif
501275970Scy
502275970Scybuild-test-lib:
503275970Scy	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk)
504275970Scy
505275970Scyifeq ($(BUILD_FAILURE_HANDLER), true)
506275970Scy  # Builds the failure handler jtreg extension
507275970Scy  build-test-failure-handler:
508275970Scy	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
509275970Scy	    -f BuildFailureHandler.gmk build)
510275970Scy
511275970Scy  # Runs the tests for the failure handler jtreg extension
512275970Scy  test-failure-handler:
513275970Scy	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
514275970Scy	    -f BuildFailureHandler.gmk test)
515275970Scy
516275970Scy  # Copies the failure handler jtreg extension into the test image
517275970Scy  test-image-failure-handler:
518275970Scy	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
519275970Scy	     -f BuildFailureHandler.gmk images)
520275970Scyendif
521275970Scy
522275970ScyALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \
523275970Scy    test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
524275970Scy    test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \
525275970Scy    test-failure-handler test-image-failure-handler test-image-hotspot-gtest \
526275970Scy    run-test exploded-run-test
527275970Scy
528275970Scy################################################################################
529275970Scy# Run tests
530275970Scy
531275970Scy# Run tests specified by $(TEST), or the default test set.
532275970Scytest:
533275970Scy	$(call RunTests, $(TEST), $(JDK_IMAGE_DIR))
534275970Scy
535275970Scytest-hotspot-jtreg:
536275970Scy	$(call RunTests, "hotspot_all", $(JDK_IMAGE_DIR))
537275970Scy
538275970Scytest-hotspot-jtreg-native:
539275970Scy	$(call RunTests, "hotspot_native_sanity", $(JDK_IMAGE_DIR))
540275970Scy
541275970Scytest-hotspot-internal:
542275970Scy	$(call RunTests, "hotspot_internal", $(JDK_OUTPUTDIR))
543275970Scy
544275970Scytest-hotspot-gtest:
545275970Scy	$(call RunTests, "hotspot_gtest", $(JDK_OUTPUTDIR))
546275970Scy
547275970Scytest-jdk-jtreg-native:
548275970Scy	$(call RunTests, "jdk_native_sanity", $(JDK_IMAGE_DIR))
549275970Scy
550275970Scytest-make:
551275970Scy	($(CD) $(SRC_ROOT)/test/make && $(MAKE) $(MAKE_ARGS) -f TestMake.gmk $(TEST_TARGET))
552275970Scy
553275970ScyALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \
554275970Scy    test-hotspot-internal test-hotspot-gtest test-jdk-jtreg-native test-make
555275970Scy
556275970Scy################################################################################
557275970Scy# Bundles
558275970Scy
559275970Scyproduct-bundles:
560275970Scy	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles)
561275970Scy
562275970Scyprofiles-bundles:
563275970Scy	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk profiles-bundles)
564275970Scy
565275970Scytest-bundles:
566275970Scy	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles)
567275970Scy
568275970Scydocs-bundles:
569285169Scy	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles)
570285169Scy
571285169ScyALL_TARGETS += product-bundles profiles-bundles test-bundles docs-bundles
572285169Scy
573285169Scy################################################################################
574285169Scy# Install targets
575285169Scy
576285169Scyinstall:
577285169Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Install.gmk)
578285169Scy
579275970ScyALL_TARGETS += install
580285169Scy
581275970Scy################################################################################
582285169Scy#
583275970Scy# Dependency declarations between targets.
584275970Scy#
585275970Scy# These are declared in two groups. First all dependencies between targets that
586275970Scy# have recipes above as these dependencies may be disabled. Then the aggregator
587275970Scy# targets that do not have recipes of their own, which will never have their
588275970Scy# dependencies disabled.
589275970Scy#
590275970Scy################################################################################
591275970Scy# 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  # Declare dependencies between jmod targets.
703  # java.base jmod needs jrt-fs.jar and access to the other jmods to be built.
704  # When creating a BUILDJDK, we don't need to add hashes to java.base, thus
705  # we don't need to depend on all other jmods
706  ifneq ($(CREATING_BUILDJDK), true)
707    java.base-jmod: jrtfs-jar $(filter-out java.base-jmod, $(JMOD_TARGETS))
708  endif
709
710  # Building java.base-jmod requires all of hotspot to be built.
711  java.base-jmod: hotspot
712
713  # Declare dependencies from <module>-jmod to all other module targets
714  # When creating a BUILDJDK, the java compilation has already been done by the
715  # normal build and copied in.
716  ifneq ($(CREATING_BUILDJDK), true)
717    $(foreach m, $(JAVA_MODULES), $(eval $m_JMOD_DEPS += $m-java))
718  endif
719  $(foreach m, $(GENDATA_MODULES), $(eval $m_JMOD_DEPS += $m-gendata))
720  $(foreach m, $(RMIC_MODULES), $(eval $m_JMOD_DEPS += $m-rmic))
721  $(foreach m, $(LIBS_MODULES), $(eval $m_JMOD_DEPS += $m-libs))
722  $(foreach m, $(LAUNCHER_MODULES), $(eval $m_JMOD_DEPS += $m-launchers))
723  $(foreach m, $(COPY_MODULES), $(eval $m_JMOD_DEPS += $m-copy))
724  $(foreach m, $(ALL_MODULES), $(eval $m-jmod: $($(m)_JMOD_DEPS)))
725  $(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $m-interim-jmod: $($(m)_JMOD_DEPS)))
726
727  # Jmods cannot be created until we have the jmod tool ready to run. During
728  # a normal build we run it from the exploded image, but when cross compiling
729  # it's run from the buildjdk, which is either created at build time or user
730  # supplied.
731  #
732  # For the exploded image to be runnable, all java modules and
733  # jdk.jlink-launchers need to be built. We also need to copy jvm.cfg (done
734  # in java.base-copy) and tzdb.dat (done in java.base-gendata) to the
735  # appropriate location otherwise jimage, jlink and jmod won't start. This
736  # also applies when creating the buildjdk.
737  DEFAULT_JMOD_DEPS := java.base-libs java.base-copy java.base-gendata \
738      jdk.jlink-launchers
739  # When cross compiling and buildjdk is to be created, depend on creating the
740  # buildjdk instead of the default dependencies.
741  ifeq ($(CREATE_BUILDJDK), true)
742    # Avoid calling create-buildjdk from within a create-buildjdk call.
743    ifneq ($(CREATING_BUILDJDK), true)
744      $(JMOD_TARGETS): create-buildjdk
745      buildtools-modules: create-buildjdk
746    else
747      # While actually creating the buildjdk, the default deps applies.
748      $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
749    endif
750  else
751    # The normal non cross compilation case uses the default deps.
752    # To avoid races with the optimize target, that also needs to happen first.
753    $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) \
754        exploded-image-optimize
755  endif
756
757  # All modules include the main license files from java.base.
758  $(JMOD_TARGETS): java.base-copy
759
760  zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
761      $(filter jdk.crypto%, $(JAVA_TARGETS))
762
763  zip-source: gensrc rmic
764
765  jrtfs-jar: interim-langtools
766
767  ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
768    ifeq ($(CREATE_BUILDJDK), true)
769      # If creating a buildjdk, the interim image needs to be based on that.
770      generate-link-opt-data: create-buildjdk
771    else ifeq ($(EXTERNAL_BUILDJDK), false)
772      # If an external buildjdk has been provided, we skip generating an
773      # interim-image and just use the external buildjdk for generating
774      # classlist.
775      generate-link-opt-data: interim-image
776    endif
777    generate-link-opt-data: buildtools-jdk
778
779    # The generated classlist needs to go into java.base-jmod.
780    java.base-jmod jdk.jlink-jmod jdk-image jre-image: generate-link-opt-data
781  endif
782
783  release-file: create-source-revision-tracker
784
785  jdk-image: jmods zip-source demos release-file
786  jre-image: jmods release-file
787  symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS)
788
789  profiles-image: jmods release-file
790
791  mac-bundles-jdk: jdk-image jre-image
792
793  # The optimize target can run as soon as the modules dir has been completely
794  # populated (java, copy and gendata targets) and the basic libs and launchers
795  # have been built.
796  exploded-image-optimize: java copy gendata java.base-libs java.base-launchers \
797      buildtools-modules
798
799  bootcycle-images: jdk-image
800
801  docs-jdk-api-javadoc: $(GENSRC_TARGETS) rmic
802
803  docs-javase-api-javadoc: $(GENSRC_TARGETS) rmic
804
805  docs-jdk-api-modulegraph: exploded-image buildtools-modules
806
807  docs-javase-api-modulegraph: exploded-image buildtools-modules
808
809  # The gensrc steps for hotspot and jdk.jdi create html spec files.
810  docs-jdk-specs: hotspot-$(JVM_VARIANT_MAIN)-gensrc jdk.jdi-gensrc
811
812  docs-jdk-index: exploded-image buildtools-modules
813
814  docs-zip: docs-jdk
815
816  test: jdk-image test-image
817
818  run-test: jdk-image test-image
819  exploded-run-test: exploded-image test-image
820
821  # Declare dependency for all generated test targets
822  $(foreach t, $(ALL_TEST_TARGETS), $(eval $t: jdk-image test-image))
823  $(foreach t, $(ALL_EXPLODED_TEST_TARGETS), $(eval $t: exploded-image test-image))
824
825  create-buildjdk-copy: jdk.jlink-java java.base-gendata \
826      $(addsuffix -java, $(INTERIM_IMAGE_MODULES))
827
828  create-buildjdk-interim-image: create-buildjdk-copy
829
830  interim-image: $(INTERIM_JMOD_TARGETS)
831
832  test-make: clean-test-make
833
834  build-test-lib: exploded-image-optimize
835
836  build-test-failure-handler: interim-langtools
837
838  test-failure-handler: build-test-failure-handler
839
840  test-image-failure-handler: build-test-failure-handler
841
842  build-test-hotspot-jtreg-native: buildtools-jdk \
843      hotspot-$(JVM_VARIANT_MAIN)-libs
844
845  build-test-jdk-jtreg-native: buildtools-jdk
846
847  test-image-hotspot-jtreg-native: build-test-hotspot-jtreg-native
848
849  test-image-jdk-jtreg-native: build-test-jdk-jtreg-native
850
851  test-image-hotspot-gtest: hotspot
852
853  test-hotspot-internal: exploded-image
854
855  test-hotspot-jtreg: jdk-image test-image
856
857  test-hotspot-gtest: exploded-image test-image-hotspot-gtest
858
859  install: product-images
860
861  product-bundles: product-images
862
863  profiles-bundles: profiles-images
864
865  test-bundles: test-image
866
867  docs-bundles: docs-image
868
869  generate-summary: jmods buildtools-modules
870
871endif
872
873################################################################################
874# Virtual targets without recipes
875
876buildtools: buildtools-langtools interim-langtools interim-rmic \
877    buildtools-jdk buildtools-hotspot
878
879hotspot: $(HOTSPOT_VARIANT_TARGETS) hotspot-jsig
880
881hotspot-libs: hotspot-jsig
882
883# Create targets hotspot-libs and hotspot-gensrc.
884$(foreach v, $(JVM_VARIANTS), \
885  $(eval hotspot-libs: hotspot-$v-libs) \
886  $(eval hotspot-gensrc: hotspot-$v-gensrc) \
887)
888
889gensrc: $(GENSRC_TARGETS)
890
891gendata: $(GENDATA_TARGETS)
892
893copy: $(ALL_COPY_TARGETS)
894
895java: $(JAVA_TARGETS)
896
897rmic: $(RMIC_TARGETS)
898
899libs: $(LIBS_TARGETS)
900
901launchers: $(LAUNCHER_TARGETS)
902
903jmods: $(JMOD_TARGETS)
904
905# Explicitly declare dependency for virtual target jdk.jdwp.agent-gensrc which
906# is actually handled by jdk.jdi-gensrc
907jdk.jdwp.agent-gensrc: jdk.jdi-gensrc
908
909# Declare dependencies from <module> to all the individual targets specific
910# to that module <module>-*, that are needed for the exploded image.
911$(foreach m, $(GENSRC_MODULES), $(eval $m: $m-gensrc))
912$(foreach m, $(JAVA_MODULES), $(eval $m: $m-java))
913$(foreach m, $(GENDATA_MODULES), $(eval $m: $m-gendata))
914$(foreach m, $(RMIC_MODULES), $(eval $m: $m-rmic))
915$(foreach m, $(LIBS_MODULES), $(eval $m: $m-libs))
916$(foreach m, $(LAUNCHER_MODULES), $(eval $m: $m-launchers))
917$(foreach m, $(ALL_COPY_MODULES), $(eval $m: $m-copy))
918
919# Building java.base includes building all of hotspot.
920java.base: hotspot
921
922demos: demos-jdk
923
924# The "exploded image" is a locally runnable JDK in $(BUILD_OUTPUT)/jdk.
925exploded-image-base: $(ALL_MODULES)
926exploded-image: exploded-image-base release-file
927# When cross compiling, no need to optimize the exploded image since it won't
928# be runnable on the host platform anyway.
929ifneq ($(COMPILE_TYPE), cross)
930  exploded-image: exploded-image-optimize
931endif
932
933create-buildjdk: create-buildjdk-copy create-buildjdk-interim-image
934
935docs-jdk-api: docs-jdk-api-javadoc
936docs-javase-api: docs-javase-api-javadoc
937
938# If we're building full docs, we must also generate the module graphs to
939# get non-broken api documentation.
940ifeq ($(ENABLE_FULL_DOCS), true)
941  docs-jdk-api: docs-jdk-api-modulegraph
942  docs-javase-api: docs-javase-api-modulegraph
943endif
944
945docs-jdk: docs-jdk-api docs-jdk-specs docs-jdk-index
946docs-javase: docs-javase-api
947
948# alias for backwards compatibility
949docs-javadoc: docs-jdk-api
950
951mac-bundles: mac-bundles-jdk
952
953# The $(BUILD_OUTPUT)/images directory contain the resulting deliverables,
954# and in line with this, our targets for creating these are named *-image[s].
955
956# This target builds the product images, e.g. the JRE and JDK image
957# (and possibly other, more specific versions)
958product-images: jdk-image jre-image symbols-image exploded-image
959
960# zip-security is actually a bundle, but for now it needs to be considered
961# an image until this can be cleaned up properly.
962product-images: zip-security
963
964# Declare these for backwards compatiblity and convenience.
965profiles profiles-images: profiles-image
966
967# The module summary cannot be run when:
968# * Cross compiling and building a partial BUILDJDK for the build host
969# * An external buildjdk has been supplied since it may not match the
970#   module selection of the target jdk
971ifneq ($(CREATE_BUILDJDK), true)
972  ifeq ($(EXTERNAL_BUILDJDK), false)
973    product-images: generate-summary
974  endif
975endif
976
977ifeq ($(OPENJDK_TARGET_OS), macosx)
978  product-images: mac-bundles
979endif
980
981# This target builds the documentation image
982docs-image: docs-jdk
983
984# This target builds the test image
985test-image: prepare-test-image test-image-hotspot-jtreg-native \
986    test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest \
987    test-image-demos-jdk
988
989# all-images builds all our deliverables as images.
990all-images: product-images test-image docs-image
991
992# all-bundles packages all our deliverables as tar.gz bundles.
993all-bundles: product-bundles test-bundles docs-bundles
994
995ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-gensrc gensrc gendata \
996    copy java rmic libs launchers jmods \
997    jdk.jdwp.agent-gensrc $(ALL_MODULES) demos \
998    exploded-image-base exploded-image \
999    create-buildjdk docs-jdk-api docs-javase-api docs-jdk docs-javase \
1000    docs-javadoc mac-bundles product-images \
1001    profiles profiles-images \
1002    docs-image test-image all-images \
1003    all-bundles
1004
1005################################################################################
1006
1007# Traditional targets typically run by users.
1008# These can be considered aliases for the targets now named by a more
1009# "modern" naming scheme.
1010default: $(DEFAULT_MAKE_TARGET)
1011jdk: exploded-image
1012images: product-images
1013docs: docs-image
1014bundles: all-bundles
1015all: all-images
1016
1017ALL_TARGETS += default jdk images docs bundles all
1018
1019################################################################################
1020################################################################################
1021#
1022# Clean targets
1023#
1024################################################################################
1025# Clean targets are automatically run serially by the Makefile calling this
1026# file.
1027
1028CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
1029    images make-support test-make bundles buildjdk
1030CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
1031CLEAN_SUPPORT_DIRS += demos
1032CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
1033CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
1034CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
1035CLEAN_PHASES := gensrc java native include
1036CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
1037CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
1038# Construct targets of the form clean-$module-$phase
1039CLEAN_MODULE_PHASE_TARGETS := $(addprefix clean-, $(foreach m, $(ALL_MODULES), \
1040    $(addprefix $m-, $(CLEAN_PHASES))))
1041
1042# Remove everything, except the output from configure.
1043clean: $(CLEAN_DIR_TARGETS)
1044	($(CD) $(OUTPUT_ROOT) && $(RM) -r build*.log*)
1045	$(ECHO) Cleaned all build artifacts.
1046
1047clean-docs:
1048	$(call CleanDocs)
1049
1050$(CLEAN_DIR_TARGETS):
1051	$(call CleanDir,$(patsubst clean-%, %, $@))
1052
1053$(CLEAN_SUPPORT_DIR_TARGETS):
1054	$(call CleanSupportDir,$(patsubst clean-%, %, $@))
1055
1056$(CLEAN_TEST_TARGETS):
1057	$(call CleanTest,$(patsubst clean-test-%, %, $@))
1058
1059$(CLEAN_PHASE_TARGETS):
1060	$(call Clean-$(patsubst clean-%,%, $@))
1061
1062$(CLEAN_MODULE_TARGETS):
1063	$(call CleanModule,$(patsubst clean-%, %, $@))
1064
1065$(CLEAN_MODULE_PHASE_TARGETS):
1066	$(call Clean-$(word 3, $(subst -,$(SPACE),$@)), \
1067	    $(word 2, $(subst -,$(SPACE),$@)))
1068
1069# When removing the support dir, we must also remove jdk. Building classes has
1070# the side effect of generating native headers. The headers end up in support
1071# while classes and touch files end up in jdk.
1072clean-support: clean-jdk
1073
1074# Remove everything, including configure configuration. If the output
1075# directory was created by configure and now becomes empty, remove it as well.
1076dist-clean: clean
1077	($(CD) $(OUTPUT_ROOT) && \
1078	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide)
1079	$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
1080	  if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
1081	    $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
1082	  else \
1083	    ($(CD) $(SRC_ROOT) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" \
1084	        && $(RM) -r $(OUTPUT_ROOT)) \
1085	  fi \
1086	)
1087	$(ECHO) Cleaned everything, you will have to re-run configure.
1088
1089ALL_TARGETS += clean clean-docs dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_SUPPORT_DIR_TARGETS) \
1090    $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) $(CLEAN_MODULE_TARGETS) \
1091    $(CLEAN_MODULE_PHASE_TARGETS)
1092
1093################################################################################
1094# Declare *-only targets for each normal target
1095$(foreach t, $(ALL_TARGETS), $(eval $(t)-only: $(t)))
1096
1097ALL_TARGETS += $(addsuffix -only, $(filter-out dist-clean clean%, $(ALL_TARGETS)))
1098
1099################################################################################
1100
1101# Include JPRT targets
1102include $(SRC_ROOT)/make/Jprt.gmk
1103
1104################################################################################
1105
1106# The following targets are intentionally not added to ALL_TARGETS since they
1107# are internal only, to support Init.gmk.
1108
1109print-targets:
1110	  @$(ECHO) $(sort $(ALL_TARGETS))
1111
1112print-modules:
1113	  @$(ECHO) $(sort $(ALL_MODULES))
1114
1115print-tests:
1116	  @$(ECHO) $(sort $(ALL_NAMED_TESTS))
1117
1118create-main-targets-include:
1119	  $(call LogInfo, Generating main target list)
1120	  @$(ECHO) ALL_MAIN_TARGETS := $(sort $(ALL_TARGETS)) > \
1121	      $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk
1122
1123################################################################################
1124
1125.PHONY: $(ALL_TARGETS)
1126
1127FRC: # Force target
1128