Main.gmk revision 2622:c569c88b7650
1118611Snjl#
2118611Snjl# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
3118611Snjl# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4118611Snjl#
5118611Snjl# This code is free software; you can redistribute it and/or modify it
6118611Snjl# under the terms of the GNU General Public License version 2 only, as
7118611Snjl# published by the Free Software Foundation.  Oracle designates this
8217365Sjkim# particular file as subject to the "Classpath" exception as provided
9217365Sjkim# by Oracle in the LICENSE file that accompanied this code.
10118611Snjl#
11118611Snjl# This code is distributed in the hope that it will be useful, but WITHOUT
12217365Sjkim# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13217365Sjkim# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14217365Sjkim# version 2 for more details (a copy is included in the LICENSE file that
15217365Sjkim# accompanied this code).
16217365Sjkim#
17217365Sjkim# You should have received a copy of the GNU General Public License version
18217365Sjkim# 2 along with this work; if not, write to the Free Software Foundation,
19217365Sjkim# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20217365Sjkim#
21217365Sjkim# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22217365Sjkim# or visit www.oracle.com if you need additional information or have any
23217365Sjkim# questions.
24217365Sjkim#
25217365Sjkim
26118611Snjl################################################################################
27217365Sjkim# This is the main makefile containing most actual top level targets. It needs
28217365Sjkim# to be called with a SPEC file defined.
29217365Sjkim################################################################################
30118611Snjl
31217365Sjkim# Declare default target
32217365Sjkimdefault:
33217365Sjkim
34217365Sjkimifeq ($(wildcard $(SPEC)),)
35217365Sjkim  $(error Main.gmk needs SPEC set to a proper spec.gmk)
36217365Sjkimendif
37217365Sjkim
38217365Sjkim# Now load the spec
39217365Sjkiminclude $(SPEC)
40217365Sjkim
41217365Sjkiminclude $(SRC_ROOT)/make/MainSupport.gmk
42217365Sjkim
43217365Sjkim# Load the vital tools for all the makefiles.
44118611Snjlinclude $(SRC_ROOT)/make/common/MakeBase.gmk
45118611Snjlinclude $(SRC_ROOT)/make/common/Modules.gmk
46151937Sjkiminclude $(SRC_ROOT)/make/common/FindTests.gmk
47118611Snjl
48193529Sjkim# Declare ALL_TARGETS as an immediate variable. This variable is a list of all
49118611Snjl# valid top level targets. It's used to declare them all as PHONY and to
50193529Sjkim# generate the -only targets.
51193529SjkimALL_TARGETS :=
52118611Snjl
53118611Snjl# Hook to include the corresponding custom file, if present.
54118611Snjl$(eval $(call IncludeCustomExtension, , Main.gmk))
55118611Snjl
56151937Sjkim# All modules for the current target platform.
57118611SnjlALL_MODULES := $(call FindAllModules)
58151937Sjkim
59151937Sjkim################################################################################
60151937Sjkim################################################################################
61151937Sjkim#
62151937Sjkim# Recipes for all targets. Only recipes, dependencies are declared later.
63151937Sjkim#
64151937Sjkim################################################################################
65151937Sjkim
66151937Sjkim################################################################################
67151937Sjkim# Interim/build tools targets, compiling tools used during the build
68151937Sjkim
69151937Sjkim# When creating a BUILDJDK, the buildtools and interim targets have already
70151937Sjkim# been built and should not be built again.
71151937Sjkimifneq ($(CREATING_BUILDJDK), true)
72151937Sjkim  buildtools-langtools:
73151937Sjkim	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Tools.gmk)
74151937Sjkim
75151937Sjkim  interim-langtools:
76151937Sjkim	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterim.gmk)
77118611Snjl
78118611Snjl  interim-rmic:
79118611Snjl	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterimRmic.gmk)
80118611Snjl
81118611Snjl  interim-cldrconverter:
82118611Snjl	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimCLDRConverter.gmk)
83118611Snjl
84118611Snjl  buildtools-jdk:
85118611Snjl	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)
86118611Snjl
87118611Snjl  buildtools-modules:
88118611Snjl	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileModuleTools.gmk)
89151937Sjkim
90118611Snjl  buildtools-hotspot:
91118611Snjl	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)
92118611Snjlendif
93118611Snjl
94118611SnjlALL_TARGETS += buildtools-langtools interim-langtools \
95118611Snjl    interim-rmic interim-cldrconverter buildtools-jdk buildtools-modules \
96118611Snjl    buildtools-hotspot
97118611Snjl
98118611Snjl################################################################################
99118611Snjl# Special targets for certain modules
100118611Snjl
101118611Snjlunpack-sec:
102118611Snjl	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UnpackSecurity.gmk)
103118611Snjl
104118611Snjlgenerate-exported-symbols:
105118611Snjl	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildStatic.gmk)
106118611Snjl
107118611SnjlALL_TARGETS += unpack-sec generate-exported-symbols
108118611Snjl
109118611Snjl################################################################################
110118611Snjl# Gensrc targets, generating source before java compilation can be done
111118611Snjl#
112118611Snjl# When creating a BUILDJDK, the java targets have already been built and copied
113118611Snjl# into the buildjdk so no need to generate sources.
114118611Snjlifneq ($(CREATING_BUILDJDK), true)
115118611Snjl  $(eval $(call DeclareRecipesForPhase, GENSRC, \
116118611Snjl      TARGET_SUFFIX := gensrc, \
117118611Snjl      FILE_PREFIX := Gensrc, \
118118611Snjl      MAKE_SUBDIR := gensrc, \
119118611Snjl      CHECK_MODULES := $(ALL_MODULES), \
120118611Snjl      MULTIPLE_MAKEFILES := true))
121118611Snjl
122118611Snjl  JDK_GENSRC_TARGETS := $(filter %-gensrc-jdk, $(GENSRC_TARGETS))
123118611Snjl  LANGTOOLS_GENSRC_TARGETS := $(filter %-gensrc-langtools, $(GENSRC_TARGETS))
124118611Snjl  CORBA_GENSRC_TARGETS := $(filter %-gensrc-corba, $(GENSRC_TARGETS))
125118611Snjl  HOTSPOT_GENSRC_TARGETS := $(filter %-gensrc-hotspot, $(GENSRC_TARGETS))
126118611Snjl
127118611Snjl  GENSRC_MODULEINFO_MODULES := $(ALL_MODULES)
128118611Snjl  GENSRC_MODULEINFO_TARGETS := $(addsuffix -gensrc-moduleinfo, \
129118611Snjl      $(GENSRC_MODULEINFO_MODULES))
130118611Snjl
131118611Snjl  GENSRC_MODULES := $(GENSRC_MODULEINFO_MODULES)
132118611Snjl  GENSRC_TARGETS += $(sort $(GENSRC_MODULEINFO_TARGETS) \
133118611Snjl      $(addsuffix -gensrc, $(GENSRC_MODULES)))
134118611Snjl
135118611Snjl  define DeclareModuleInfoRecipe
136151937Sjkim    $1-gensrc-moduleinfo:
137118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
138118611Snjl	    -f GensrcModuleInfo.gmk MODULE=$1)
139118611Snjl
140118611Snjl    $1-gensrc: $1-gensrc-moduleinfo
141118611Snjl  endef
142118611Snjl
143118611Snjl  $(foreach m, $(GENSRC_MODULEINFO_MODULES), $(eval $(call DeclareModuleInfoRecipe,$m)))
144118611Snjlendif
145118611Snjl
146118611SnjlALL_TARGETS += $(GENSRC_TARGETS)
147118611Snjl
148118611Snjl################################################################################
149118611Snjl# Generate data targets
150118611Snjl$(eval $(call DeclareRecipesForPhase, GENDATA, \
151118611Snjl    TARGET_SUFFIX := gendata, \
152118611Snjl    FILE_PREFIX := Gendata, \
153118611Snjl    MAKE_SUBDIR := gendata, \
154118611Snjl    CHECK_MODULES := $(ALL_MODULES), \
155118611Snjl    USE_WRAPPER := true))
156118611Snjl
157118611SnjlALL_TARGETS += $(GENDATA_TARGETS)
158118611Snjl
159118611Snjl################################################################################
160118611Snjl# Copy files targets
161118611Snjl$(eval $(call DeclareRecipesForPhase, COPY, \
162118611Snjl    TARGET_SUFFIX := copy, \
163118611Snjl    FILE_PREFIX := Copy, \
164118611Snjl    MAKE_SUBDIR := copy, \
165118611Snjl    CHECK_MODULES := $(ALL_MODULES), \
166118611Snjl    USE_WRAPPER := true, \
167118611Snjl    MULTIPLE_MAKEFILES := true))
168118611Snjl
169118611SnjlALL_COPY_MODULES += $(COPY_MODULES)
170118611SnjlALL_COPY_TARGETS += $(COPY_TARGETS)
171118611Snjl
172118611SnjlIMPORT_COPY_MODULES := $(call FindImportedModules)
173118611SnjlIMPORT_COPY_TARGETS := $(addsuffix -copy, $(IMPORT_COPY_MODULES))
174118611SnjlALL_COPY_MODULES += $(IMPORT_COPY_MODULES)
175118611SnjlALL_COPY_TARGETS += $(IMPORT_COPY_TARGETS)
176118611Snjl
177118611Snjldefine DeclareImportCopyRecipe
178118611Snjl  $1-copy:
179118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
180118611Snjl	    -f CopyImportModules.gmk MODULE=$1)
181118611Snjlendef
182151937Sjkim
183118611Snjl$(foreach m, $(IMPORT_COPY_MODULES), $(eval $(call DeclareImportCopyRecipe,$m)))
184118611Snjl
185118611SnjlALL_TARGETS += $(ALL_COPY_TARGETS)
186118611Snjl
187118611Snjl################################################################################
188118611Snjl# Targets for compiling all java modules. Nashorn is treated separately.
189118611SnjlJAVA_MODULES := $(ALL_MODULES)
190118611SnjlJAVA_TARGETS := $(addsuffix -java, $(JAVA_MODULES))
191118611Snjl
192118611Snjldefine DeclareCompileJavaRecipe
193118611Snjl  $1-java:
194118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
195118611Snjl	    -f CompileJavaModules.gmk MODULE=$1)
196118611Snjlendef
197118611Snjl
198118611Snjl$(foreach m, $(filter-out jdk.scripting.nashorn, $(JAVA_MODULES)), \
199118611Snjl    $(eval $(call DeclareCompileJavaRecipe,$m)))
200118611Snjl
201118611Snjl# Build nashorn. Needs to be compiled separately from the rest of the modules
202118611Snjl# due to nasgen.
203118611Snjljdk.scripting.nashorn-java:
204151937Sjkim	+($(CD) $(NASHORN_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
205151937Sjkim	    -f BuildNashorn.gmk compile)
206118611Snjl
207118611SnjlALL_TARGETS += $(JAVA_TARGETS)
208118611Snjl
209151937Sjkim################################################################################
210151937Sjkim# Targets for running rmic.
211118611Snjl$(eval $(call DeclareRecipesForPhase, RMIC, \
212118611Snjl    TARGET_SUFFIX := rmic, \
213118611Snjl    FILE_PREFIX := Rmic, \
214118611Snjl    MAKE_SUBDIR := rmic, \
215118611Snjl    CHECK_MODULES := $(ALL_MODULES)))
216118611Snjl
217118611SnjlALL_TARGETS += $(RMIC_TARGETS)
218118611Snjl
219118611Snjl################################################################################
220118611Snjl# Targets for compiling native libraries
221118611Snjl$(eval $(call DeclareRecipesForPhase, LIBS, \
222118611Snjl    TARGET_SUFFIX := libs, \
223118611Snjl    FILE_PREFIX := Lib, \
224118611Snjl    MAKE_SUBDIR := lib, \
225118611Snjl    CHECK_MODULES := $(ALL_MODULES), \
226118611Snjl    USE_WRAPPER := true))
227118611Snjl
228151937SjkimALL_TARGETS += $(LIBS_TARGETS)
229151937Sjkim
230118611Snjl################################################################################
231118611Snjl# Targets for compiling native executables
232118611Snjl$(eval $(call DeclareRecipesForPhase, LAUNCHER, \
233151937Sjkim    TARGET_SUFFIX := launchers, \
234151937Sjkim    FILE_PREFIX := Launcher, \
235118611Snjl    MAKE_SUBDIR := launcher, \
236118611Snjl    CHECK_MODULES := $(ALL_MODULES), \
237118611Snjl    USE_WRAPPER := true))
238118611Snjl
239118611SnjlALL_TARGETS += $(LAUNCHER_TARGETS)
240118611Snjl
241118611Snjl################################################################################
242118611Snjl# Build hotspot target
243118611Snjl
244118611SnjlHOTSPOT_VARIANT_TARGETS := $(addprefix hotspot-, $(JVM_VARIANTS))
245118611SnjlHOTSPOT_VARIANT_GENSRC_TARGETS := $(addsuffix -gensrc, $(HOTSPOT_VARIANT_TARGETS))
246118611SnjlHOTSPOT_VARIANT_LIBS_TARGETS := $(addsuffix -libs, $(HOTSPOT_VARIANT_TARGETS))
247118611Snjl
248118611Snjldefine DeclareHotspotGensrcRecipe
249118611Snjl  hotspot-$1-gensrc:
250118611Snjl	$$(call LogInfo, Building JVM variant '$1' with features '$(JVM_FEATURES_$1)')
251118611Snjl	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f gensrc/GenerateSources.gmk \
252118611Snjl	    JVM_VARIANT=$1)
253118611Snjlendef
254118611Snjl
255118611Snjl$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotGensrcRecipe,$v)))
256118611Snjl
257118611Snjldefine DeclareHotspotLibsRecipe
258118611Snjl  hotspot-$1-libs:
259118611Snjl	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibraries.gmk \
260118611Snjl	    JVM_VARIANT=$1)
261118611Snjlendef
262118611Snjl
263118611Snjl$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotLibsRecipe,$v)))
264118611Snjl
265118611Snjlhotspot-jsig:
266118611Snjl	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibjsig.gmk)
267118611Snjl
268118611Snjlhotspot-ide-project:
269118611Snjl	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ide/CreateVSProject.gmk)
270118611Snjl
271118611SnjlALL_TARGETS += $(HOTSPOT_VARIANT_TARGETS) $(HOTSPOT_VARIANT_GENSRC_TARGETS) \
272118611Snjl    $(HOTSPOT_VARIANT_LIBS_TARGETS) hotspot-jsig hotspot-ide-project
273118611Snjl
274118611Snjl################################################################################
275118611Snjl# Build demos targets
276118611Snjl
277118611Snjldemos-jdk:
278118611Snjl	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk)
279118611Snjl
280118611Snjltest-image-demos-jdk:
281118611Snjl	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk images)
282118611Snjl
283118611SnjlALL_TARGETS += demos-jdk test-image-demos-jdk
284118611Snjl
285118611Snjl################################################################################
286118611Snjl# Jigsaw specific data and analysis targets.
287118611Snjl
288118611Snjlgenerate-summary:
289118611Snjl	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f GenerateModuleSummary.gmk)
290118611Snjl
291118611SnjlALL_TARGETS += generate-summary
292118611Snjl
293118611Snjl################################################################################
294151937Sjkim# Jmod targets
295151937Sjkim
296118611SnjlJMOD_MODULES := $(ALL_MODULES)
297118611SnjlJMOD_TARGETS := $(addsuffix -jmod, $(JMOD_MODULES))
298118611Snjl
299118611Snjldefine DeclareJmodRecipe
300118611Snjl  $1-jmod:
301118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
302118611Snjl	    MODULE=$1)
303118611Snjlendef
304118611Snjl
305118611Snjl$(foreach m, $(JMOD_MODULES), $(eval $(call DeclareJmodRecipe,$m)))
306118611Snjl
307118611SnjlALL_TARGETS += $(JMOD_TARGETS)
308118611Snjl
309118611Snjl################################################################################
310118611Snjl# Images targets
311118611Snjl
312118611Snjlstore-source-revision:
313118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk store-source-revision)
314118611Snjl
315118611Snjlcreate-source-revision-tracker:
316118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk create-source-revision-tracker)
317118611Snjl
318118611SnjlBOOTCYCLE_TARGET := product-images
319118611Snjlbootcycle-images:
320118611Snjl        ifneq ($(COMPILE_TYPE), cross)
321118611Snjl	  $(call LogWarn, Boot cycle build step 2: Building a new JDK image using previously built image)
322118611Snjl	  +$(MAKE) $(MAKE_ARGS) -f $(SRC_ROOT)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
323118611Snjl	      JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
324118611Snjl        else
325118611Snjl	  $(call LogWarn, Boot cycle build disabled when cross compiling)
326118611Snjl        endif
327151937Sjkim
328151937Sjkimzip-security:
329151937Sjkim	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSecurity.gmk)
330151937Sjkim
331118611Snjlzip-source:
332118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSource.gmk)
333118611Snjl
334118611Snjljrtfs-jar:
335118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f JrtfsJar.gmk)
336118611Snjl
337118611Snjljdk-image:
338118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jdk)
339118611Snjl
340118611Snjljre-image:
341118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jre)
342118611Snjl
343118611Snjlsymbols-image:
344118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk symbols)
345118611Snjl
346118611Snjlprofiles-image:
347118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)
348118611Snjl
349118611Snjlmac-bundles-jdk:
350118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk)
351118611Snjl
352118611Snjlrelease-file:
353118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ReleaseFile.gmk)
354118611Snjl
355118611Snjlexploded-image-optimize:
356118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk)
357118611Snjl
358118611SnjlALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \
359118611Snjl    zip-source jrtfs-jar jdk-image jre-image \
360118611Snjl    symbols-image profiles-image mac-bundles-jdk \
361118611Snjl    release-file exploded-image-optimize
362118611Snjl
363118611Snjl################################################################################
364118611Snjl# Docs targets
365118611Snjl
366118611Snjl# If building full docs, to complete docs-*-api we need both the javadoc and
367118611Snjl# modulegraph targets.
368118611Snjldocs-jdk-api-javadoc:
369151937Sjkim	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-api-javadoc)
370151937Sjkim
371151937Sjkimdocs-jdk-api-modulegraph:
372151937Sjkim	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-api-modulegraph)
373118611Snjl
374118611Snjldocs-javase-api-javadoc:
375118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-javase-api-javadoc)
376118611Snjl
377118611Snjldocs-javase-api-modulegraph:
378118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-javase-api-modulegraph)
379118611Snjl
380118611Snjldocs-jdk-specs:
381118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-specs)
382118611Snjl
383118611Snjldocs-jdk-index:
384118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-index)
385118611Snjl
386118611Snjldocs-zip:
387118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-zip)
388118611Snjl
389118611Snjlupdate-build-docs:
390118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f UpdateBuildDocs.gmk)
391151937Sjkim
392151937SjkimALL_TARGETS += docs-jdk-api-javadoc docs-jdk-api-modulegraph \
393151937Sjkim    docs-javase-api-javadoc docs-javase-api-modulegraph docs-jdk-specs \
394151937Sjkim    docs-jdk-index docs-zip update-build-docs
395118611Snjl
396118611Snjl################################################################################
397118611Snjl# Cross compilation support
398118611Snjl
399118611Snjlifeq ($(CREATING_BUILDJDK), true)
400118611Snjl  # This target is only called by the recursive call below.
401118611Snjl  create-buildjdk-interim-image-helper: interim-image jdk.jlink-launchers \
402118611Snjl      java.base-copy jdk.jdeps-launchers
403118611Snjlendif
404151937Sjkim
405151937Sjkimcreate-buildjdk-copy:
406118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateBuildJdkCopy.gmk)
407118611Snjl
408118611Snjlcreate-buildjdk-interim-image:
409118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Main.gmk \
410118611Snjl	    $@-helper \
411193529Sjkim	    SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
412118611Snjl	    HOTSPOT_SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
413118611Snjl	    CREATING_BUILDJDK=true)
414118611Snjl
415118611SnjlALL_TARGETS += create-buildjdk-copy create-buildjdk-interim-image
416118611Snjl
417118611Snjl################################################################################
418118611Snjl# The interim-image is a small jlinked image that is used to generate artifacts
419151937Sjkim# at build time for use when linking the real images.
420151937Sjkim
421123315SnjlINTERIM_JMOD_TARGETS := $(addsuffix -interim-jmod, $(INTERIM_IMAGE_MODULES))
422118611Snjl
423118611Snjldefine DeclareInterimJmodRecipe
424118611Snjl  $1-interim-jmod:
425118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
426118611Snjl	    MODULE=$1 \
427118611Snjl	    JMODS_DIR=$(INTERIM_JMODS_DIR) \
428118611Snjl	    JMODS_TEMPDIR=$(INTERIM_JMODS_DIR)/temp \
429118611Snjl	    INTERIM_JMOD=true \
430118611Snjl	)
431118611Snjlendef
432151937Sjkim
433151937Sjkim$(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $(call DeclareInterimJmodRecipe,$m)))
434118611Snjl
435118611Snjlinterim-image:
436118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f InterimImage.gmk)
437118611Snjl
438118611Snjlifeq ($(ENABLE_GENERATE_CLASSLIST), true)
439118611Snjl  generate-link-opt-data:
440118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f GenerateLinkOptData.gmk)
441118611Snjlendif
442118611Snjl
443151937SjkimALL_TARGETS += $(INTERIM_JMOD_TARGETS) interim-image generate-link-opt-data
444118611Snjl
445118611Snjl################################################################################
446118611Snjl# Generate test names for all JTReg test groups
447118611Snjl#
448118611Snjl
449118611Snjldefine DeclareRunTestRecipe
450118611Snjl  run-test-$1:
451118611Snjl	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$1")
452118611Snjl
453118611Snjlendef
454118611Snjl
455118611Snjl# ALL_NAMED_TESTS is defined in FindTests.gmk
456118611Snjl$(foreach t, $(ALL_NAMED_TESTS), $(eval $(call DeclareRunTestRecipe,$t)))
457118611SnjlALL_TEST_TARGETS := $(addprefix run-test-, $(ALL_NAMED_TESTS))
458118611Snjl
459118611SnjlALL_TARGETS += $(ALL_TEST_TARGETS)
460118611Snjl
461118611Snjl################################################################################
462118611Snjl# Build tests
463118611Snjl#
464118611Snjl
465118611Snjlprepare-test-image:
466118611Snjl	$(MKDIR) -p $(TEST_IMAGE_DIR)
467118611Snjl	$(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image'
468118611Snjl
469118611Snjlbuild-test-hotspot-jtreg-native:
470118611Snjl	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
471151937Sjkim	    build-test-hotspot-jtreg-native)
472151937Sjkim
473118611Snjltest-image-hotspot-jtreg-native:
474118611Snjl	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
475118611Snjl	    test-image-hotspot-jtreg-native)
476118611Snjl
477118611Snjlbuild-test-jdk-jtreg-native:
478118611Snjl	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
479118611Snjl	    build-test-jdk-jtreg-native)
480118611Snjl
481118611Snjltest-image-jdk-jtreg-native:
482118611Snjl	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
483118611Snjl	    test-image-jdk-jtreg-native)
484118611Snjl
485118611Snjlrun-test:
486118611Snjl	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$(TEST)")
487118611Snjl
488118611Snjlifeq ($(BUILD_GTEST), true)
489118611Snjl  test-image-hotspot-gtest:
490118611Snjl	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f GtestImage.gmk)
491118611Snjlendif
492
493build-test-lib:
494	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk)
495
496ifeq ($(BUILD_FAILURE_HANDLER), true)
497  # Builds the failure handler jtreg extension
498  build-test-failure-handler:
499	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
500	    -f BuildFailureHandler.gmk build)
501
502  # Runs the tests for the failure handler jtreg extension
503  test-failure-handler:
504	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
505	    -f BuildFailureHandler.gmk test)
506
507  # Copies the failure handler jtreg extension into the test image
508  test-image-failure-handler:
509	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
510	     -f BuildFailureHandler.gmk images)
511endif
512
513ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \
514    test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
515    test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \
516    test-failure-handler test-image-failure-handler test-image-hotspot-gtest \
517    run-test
518
519################################################################################
520# Run tests
521
522# Run tests specified by $(TEST), or the default test set.
523test:
524	$(call RunTests, $(TEST), $(JDK_IMAGE_DIR))
525
526test-hotspot-jtreg:
527	$(call RunTests, "hotspot_all", $(JDK_IMAGE_DIR))
528
529test-hotspot-jtreg-native:
530	$(call RunTests, "hotspot_native_sanity", $(JDK_IMAGE_DIR))
531
532test-hotspot-internal:
533	$(call RunTests, "hotspot_internal", $(JDK_OUTPUTDIR))
534
535test-hotspot-gtest:
536	$(call RunTests, "hotspot_gtest", $(JDK_OUTPUTDIR))
537
538test-jdk-jtreg-native:
539	$(call RunTests, "jdk_native_sanity", $(JDK_IMAGE_DIR))
540
541test-make:
542	($(CD) $(SRC_ROOT)/test/make && $(MAKE) $(MAKE_ARGS) -f TestMake.gmk $(TEST_TARGET))
543
544ALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \
545    test-hotspot-internal test-hotspot-gtest test-jdk-jtreg-native test-make
546
547################################################################################
548# Bundles
549
550product-bundles:
551	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles)
552
553profiles-bundles:
554	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk profiles-bundles)
555
556test-bundles:
557	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles)
558
559docs-bundles:
560	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles)
561
562ALL_TARGETS += product-bundles profiles-bundles test-bundles docs-bundles
563
564################################################################################
565# Install targets
566
567install:
568	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Install.gmk)
569
570ALL_TARGETS += install
571
572################################################################################
573#
574# Dependency declarations between targets.
575#
576# These are declared in two groups. First all dependencies between targets that
577# have recipes above as these dependencies may be disabled. Then the aggregator
578# targets that do not have recipes of their own, which will never have their
579# dependencies disabled.
580#
581################################################################################
582# Targets with recipes above
583
584# If running an *-only target, parallel execution and dependencies between
585# recipe targets are disabled. This makes it possible to run a select set of
586# recipe targets in order. It's the responsibility of the user to make sure
587# all prerequisites are fulfilled.
588ifneq ($(findstring -only, $(MAKECMDGOALS)), )
589  .NOTPARALLEL:
590else
591  $(LANGTOOLS_GENSRC_TARGETS): buildtools-langtools
592
593  interim-langtools: $(LANGTOOLS_GENSRC_TARGETS)
594
595  buildtools-jdk: interim-langtools interim-cldrconverter
596
597  buildtools-hotspot: interim-langtools
598
599  buildtools-modules: exploded-image-base
600
601  $(CORBA_GENSRC_TARGETS): interim-langtools
602
603  $(HOTSPOT_GENSRC_TARGETS): interim-langtools buildtools-hotspot
604
605  $(JDK_GENSRC_TARGETS): interim-langtools buildtools-jdk
606
607  $(GENSRC_MODULEINFO_TARGETS): buildtools-jdk
608
609  $(GENDATA_TARGETS): interim-langtools buildtools-jdk
610
611  interim-rmic: interim-langtools
612
613  $(RMIC_TARGETS): interim-langtools interim-rmic
614
615  $(JAVA_TARGETS): interim-langtools
616
617  # Declare dependencies between hotspot-<variant>* targets
618  $(foreach v, $(JVM_VARIANTS), \
619      $(eval hotspot-$v: hotspot-$v-gensrc hotspot-$v-libs) \
620      $(eval hotspot-$v-libs: hotspot-$v-gensrc) \
621  )
622
623  hotspot-ide-project: hotspot exploded-image
624
625  generate-exported-symbols: java.base-libs jdk.jdwp.agent-libs
626
627  # Building one JVM variant is enough to start building the other libs
628  $(LIBS_TARGETS): hotspot-$(JVM_VARIANT_MAIN)-libs
629
630  $(LAUNCHER_TARGETS): java.base-libs
631
632  ifeq ($(STATIC_BUILD), true)
633    $(LAUNCHER_TARGETS): generate-exported-symbols
634  endif
635
636  # The demos are currently linking to libjvm and libjava, just like all other
637  # jdk libs, even though they don't need to. To avoid warnings, make sure they
638  # aren't built until after libjava and libjvm are available to link to.
639  demos-jdk: java.base-libs exploded-image-optimize
640  test-image-demos-jdk: demos-jdk
641
642  # Declare dependency from <module>-java to <module>-gensrc
643  $(foreach m, $(GENSRC_MODULES), $(eval $m-java: $m-gensrc))
644
645  # Declare dependencies between java modules
646  $(foreach m, $(JAVA_MODULES), \
647      $(eval $m-java: $(addsuffix -java, $(filter $(JAVA_MODULES), \
648      $(call FindDepsForModule,$m)))))
649
650  # Declare dependencies between <module>-rmic to <module>-java
651  $(foreach m, $(RMIC_MODULES), $(eval $m-rmic: $m-java))
652
653  # Declare dependencies from <module>-lib to <module>-java
654  # Skip modules that do not have java source.
655  # When creating a BUILDJDK, the java compilation has already been done by the
656  # normal build and copied in.
657  ifneq ($(CREATING_BUILDJDK), true)
658    $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs: $m-java))
659  endif
660
661  # Declare dependencies from all other <module>-lib to java.base-lib
662  $(foreach t, $(filter-out java.base-libs, $(LIBS_TARGETS)), \
663      $(eval $t: java.base-libs))
664
665  # jdk.accessibility depends on java.desktop
666  jdk.accessibility-libs: java.desktop-libs
667
668  # This dependency needs to be explicitly declared. jdk.jdi-gensrc generates a
669  # header file used by jdk.jdwp.agent-libs. The jdk.jdwp.agent-gensrc is a
670  # virtual target.
671  jdk.jdwp.agent-libs: jdk.jdwp.agent-gensrc
672
673  # The swing beans need to have java base properly generated to avoid errors
674  # in javadoc.
675  java.desktop-gensrc-jdk: java.base-gensrc
676
677  # The annotation processing for jdk.internal.vm.ci and jdk.internal.vm.compiler
678  # needs classes from the current JDK.
679  jdk.internal.vm.ci-gensrc-hotspot: $(addsuffix -java, \
680      $(call FindTransitiveDepsForModule, jdk.internal.vm.ci))
681  jdk.internal.vm.compiler-gensrc-hotspot: $(addsuffix -java, \
682      $(call FindTransitiveDepsForModule, jdk.internal.vm.compiler))
683
684  # For jdk.internal.vm.compiler, the gensrc step is generating a module-info.java.extra
685  # file to be processed by the gensrc-moduleinfo target.
686  jdk.internal.vm.compiler-gensrc-moduleinfo: jdk.internal.vm.compiler-gensrc-hotspot
687
688  # Explicitly add dependencies for special targets
689  java.base-java: unpack-sec
690
691  jdk.jdeps-gendata: java rmic
692
693  # Declare dependencies between jmod targets.
694  # java.base jmod needs jrt-fs.jar and access to the other jmods to be built.
695  # When creating a BUILDJDK, we don't need to add hashes to java.base, thus
696  # we don't need to depend on all other jmods
697  ifneq ($(CREATING_BUILDJDK), true)
698    java.base-jmod: jrtfs-jar $(filter-out java.base-jmod, $(JMOD_TARGETS))
699  endif
700
701  # Building java.base-jmod requires all of hotspot to be built.
702  java.base-jmod: hotspot
703
704  # Declare dependencies from <module>-jmod to all other module targets
705  # When creating a BUILDJDK, the java compilation has already been done by the
706  # normal build and copied in.
707  ifneq ($(CREATING_BUILDJDK), true)
708    $(foreach m, $(JAVA_MODULES), $(eval $m_JMOD_DEPS += $m-java))
709  endif
710  $(foreach m, $(GENDATA_MODULES), $(eval $m_JMOD_DEPS += $m-gendata))
711  $(foreach m, $(RMIC_MODULES), $(eval $m_JMOD_DEPS += $m-rmic))
712  $(foreach m, $(LIBS_MODULES), $(eval $m_JMOD_DEPS += $m-libs))
713  $(foreach m, $(LAUNCHER_MODULES), $(eval $m_JMOD_DEPS += $m-launchers))
714  $(foreach m, $(COPY_MODULES), $(eval $m_JMOD_DEPS += $m-copy))
715  $(foreach m, $(ALL_MODULES), $(eval $m-jmod: $($(m)_JMOD_DEPS)))
716  $(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $m-interim-jmod: $($(m)_JMOD_DEPS)))
717
718  # Jmods cannot be created until we have the jmod tool ready to run. During
719  # a normal build we run it from the exploded image, but when cross compiling
720  # it's run from the buildjdk, which is either created at build time or user
721  # supplied.
722  #
723  # For the exploded image to be runnable, all java modules and
724  # jdk.jlink-launchers need to be built. We also need to copy jvm.cfg (done
725  # in java.base-copy) and tzdb.dat (done in java.base-gendata) to the
726  # appropriate location otherwise jimage, jlink and jmod won't start. This
727  # also applies when creating the buildjdk.
728  DEFAULT_JMOD_DEPS := java.base-libs java.base-copy java.base-gendata \
729      jdk.jlink-launchers
730  # When cross compiling and buildjdk is to be created, depend on creating the
731  # buildjdk instead of the default dependencies.
732  ifeq ($(CREATE_BUILDJDK), true)
733    # Avoid calling create-buildjdk from within a create-buildjdk call.
734    ifneq ($(CREATING_BUILDJDK), true)
735      $(JMOD_TARGETS): create-buildjdk
736      buildtools-modules: create-buildjdk
737    else
738      # While actually creating the buildjdk, the default deps applies.
739      $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
740    endif
741  else
742    # The normal non cross compilation case uses the default deps.
743    # To avoid races with the optimize target, that also needs to happen first.
744    $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) \
745        exploded-image-optimize
746  endif
747
748  # All modules include the main license files from java.base.
749  $(JMOD_TARGETS): java.base-copy
750
751  zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
752      $(filter jdk.crypto%, $(JAVA_TARGETS))
753
754  zip-source: gensrc rmic
755
756  jrtfs-jar: interim-langtools
757
758  ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
759    ifeq ($(CREATE_BUILDJDK), true)
760      # If creating a buildjdk, the interim image needs to be based on that.
761      generate-link-opt-data: create-buildjdk
762    else ifeq ($(EXTERNAL_BUILDJDK), false)
763      # If an external buildjdk has been provided, we skip generating an
764      # interim-image and just use the external buildjdk for generating
765      # classlist.
766      generate-link-opt-data: interim-image
767    endif
768    generate-link-opt-data: buildtools-jdk
769
770    # The generated classlist needs to go into java.base-jmod.
771    java.base-jmod jdk.jlink-jmod jdk-image jre-image: generate-link-opt-data
772  endif
773
774  release-file: create-source-revision-tracker
775
776  jdk-image: jmods zip-source demos release-file
777  jre-image: jmods release-file
778  symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS)
779
780  profiles-image: jmods release-file
781
782  mac-bundles-jdk: jdk-image jre-image
783
784  # The optimize target can run as soon as the modules dir has been completely
785  # populated (java, copy and gendata targets) and the basic libs and launchers
786  # have been built.
787  exploded-image-optimize: java copy gendata java.base-libs java.base-launchers \
788      buildtools-modules
789
790  bootcycle-images: jdk-image
791
792  docs-jdk-api-javadoc: $(GENSRC_TARGETS) rmic
793
794  docs-javase-api-javadoc: $(GENSRC_TARGETS) rmic
795
796  docs-jdk-api-modulegraph: exploded-image buildtools-modules
797
798  docs-javase-api-modulegraph: exploded-image buildtools-modules
799
800  # The gensrc steps for hotspot and jdk.jdi create html spec files.
801  docs-jdk-specs: hotspot-$(JVM_VARIANT_MAIN)-gensrc jdk.jdi-gensrc
802
803  docs-jdk-index: exploded-image buildtools-modules
804
805  docs-zip: docs-jdk
806
807  test: jdk-image test-image
808
809  run-test: jdk-image test-image
810
811  # Declare dependency for all generated test targets
812  $(foreach t, $(ALL_TEST_TARGETS), $(eval $t: jdk-image test-image))
813
814  create-buildjdk-copy: jdk.jlink-java java.base-gendata \
815      $(addsuffix -java, $(INTERIM_IMAGE_MODULES))
816
817  create-buildjdk-interim-image: create-buildjdk-copy
818
819  interim-image: $(INTERIM_JMOD_TARGETS)
820
821  test-make: clean-test-make
822
823  build-test-lib: exploded-image-optimize
824
825  build-test-failure-handler: interim-langtools
826
827  test-failure-handler: build-test-failure-handler
828
829  test-image-failure-handler: build-test-failure-handler
830
831  build-test-hotspot-jtreg-native: buildtools-jdk \
832      hotspot-$(JVM_VARIANT_MAIN)-libs
833
834  build-test-jdk-jtreg-native: buildtools-jdk
835
836  test-image-hotspot-jtreg-native: build-test-hotspot-jtreg-native
837
838  test-image-jdk-jtreg-native: build-test-jdk-jtreg-native
839
840  test-image-hotspot-gtest: hotspot
841
842  test-hotspot-internal: exploded-image
843
844  test-hotspot-jtreg: jdk-image test-image
845
846  test-hotspot-gtest: exploded-image test-image-hotspot-gtest
847
848  install: product-images
849
850  product-bundles: product-images
851
852  profiles-bundles: profiles-images
853
854  test-bundles: test-image
855
856  docs-bundles: docs-image
857
858  generate-summary: jmods buildtools-modules
859
860endif
861
862################################################################################
863# Virtual targets without recipes
864
865buildtools: buildtools-langtools interim-langtools interim-rmic \
866    buildtools-jdk buildtools-hotspot
867
868hotspot: $(HOTSPOT_VARIANT_TARGETS) hotspot-jsig
869
870hotspot-libs: hotspot-jsig
871
872# Create targets hotspot-libs and hotspot-gensrc.
873$(foreach v, $(JVM_VARIANTS), \
874  $(eval hotspot-libs: hotspot-$v-libs) \
875  $(eval hotspot-gensrc: hotspot-$v-gensrc) \
876)
877
878gensrc: $(GENSRC_TARGETS)
879
880gendata: $(GENDATA_TARGETS)
881
882copy: $(ALL_COPY_TARGETS)
883
884java: $(JAVA_TARGETS)
885
886rmic: $(RMIC_TARGETS)
887
888libs: $(LIBS_TARGETS)
889
890launchers: $(LAUNCHER_TARGETS)
891
892jmods: $(JMOD_TARGETS)
893
894# Explicitly declare dependency for virtual target jdk.jdwp.agent-gensrc which
895# is actually handled by jdk.jdi-gensrc
896jdk.jdwp.agent-gensrc: jdk.jdi-gensrc
897
898# Declare dependencies from <module> to all the individual targets specific
899# to that module <module>-*, that are needed for the exploded image.
900$(foreach m, $(GENSRC_MODULES), $(eval $m: $m-gensrc))
901$(foreach m, $(JAVA_MODULES), $(eval $m: $m-java))
902$(foreach m, $(GENDATA_MODULES), $(eval $m: $m-gendata))
903$(foreach m, $(RMIC_MODULES), $(eval $m: $m-rmic))
904$(foreach m, $(LIBS_MODULES), $(eval $m: $m-libs))
905$(foreach m, $(LAUNCHER_MODULES), $(eval $m: $m-launchers))
906$(foreach m, $(ALL_COPY_MODULES), $(eval $m: $m-copy))
907
908# Building java.base includes building all of hotspot.
909java.base: hotspot
910
911demos: demos-jdk
912
913# The "exploded image" is a locally runnable JDK in $(BUILD_OUTPUT)/jdk.
914exploded-image-base: $(ALL_MODULES)
915exploded-image: exploded-image-base release-file
916# When cross compiling, no need to optimize the exploded image since it won't
917# be runnable on the host platform anyway.
918ifneq ($(COMPILE_TYPE), cross)
919  exploded-image: exploded-image-optimize
920endif
921
922create-buildjdk: create-buildjdk-copy create-buildjdk-interim-image
923
924docs-jdk-api: docs-jdk-api-javadoc
925docs-javase-api: docs-javase-api-javadoc
926
927# If we're building full docs, we must also generate the module graphs to
928# get non-broken api documentation.
929ifeq ($(ENABLE_FULL_DOCS), true)
930  docs-jdk-api: docs-jdk-api-modulegraph
931  docs-javase-api: docs-javase-api-modulegraph
932endif
933
934docs-jdk: docs-jdk-api docs-jdk-specs docs-jdk-index
935docs-javase: docs-javase-api
936
937# alias for backwards compatibility
938docs-javadoc: docs-jdk-api
939
940mac-bundles: mac-bundles-jdk
941
942# The $(BUILD_OUTPUT)/images directory contain the resulting deliverables,
943# and in line with this, our targets for creating these are named *-image[s].
944
945# This target builds the product images, e.g. the JRE and JDK image
946# (and possibly other, more specific versions)
947product-images: jdk-image jre-image symbols-image exploded-image
948
949# zip-security is actually a bundle, but for now it needs to be considered
950# an image until this can be cleaned up properly.
951product-images: zip-security
952
953# Declare these for backwards compatiblity and convenience.
954profiles profiles-images: profiles-image
955
956# The module summary cannot be run when:
957# * Cross compiling and building a partial BUILDJDK for the build host
958# * An external buildjdk has been supplied since it may not match the
959#   module selection of the target jdk
960ifneq ($(CREATE_BUILDJDK), true)
961  ifeq ($(EXTERNAL_BUILDJDK), false)
962    product-images: generate-summary
963  endif
964endif
965
966ifeq ($(OPENJDK_TARGET_OS), macosx)
967  product-images: mac-bundles
968endif
969
970# This target builds the documentation image
971docs-image: docs-jdk
972
973# This target builds the test image
974test-image: prepare-test-image test-image-hotspot-jtreg-native \
975    test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest \
976    test-image-demos-jdk
977
978# all-images builds all our deliverables as images.
979all-images: product-images test-image docs-image
980
981# all-bundles packages all our deliverables as tar.gz bundles.
982all-bundles: product-bundles test-bundles docs-bundles
983
984ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-gensrc gensrc gendata \
985    copy java rmic libs launchers jmods \
986    jdk.jdwp.agent-gensrc $(ALL_MODULES) demos \
987    exploded-image-base exploded-image \
988    create-buildjdk docs-jdk-api docs-javase-api docs-jdk docs-javase \
989    docs-javadoc mac-bundles product-images \
990    profiles profiles-images \
991    docs-image test-image all-images \
992    all-bundles
993
994################################################################################
995
996# Traditional targets typically run by users.
997# These can be considered aliases for the targets now named by a more
998# "modern" naming scheme.
999default: $(DEFAULT_MAKE_TARGET)
1000jdk: exploded-image
1001images: product-images
1002docs: docs-image
1003bundles: all-bundles
1004all: all-images
1005
1006ALL_TARGETS += default jdk images docs bundles all
1007
1008################################################################################
1009################################################################################
1010#
1011# Clean targets
1012#
1013################################################################################
1014# Clean targets are automatically run serially by the Makefile calling this
1015# file.
1016
1017CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
1018    images make-support test-make bundles buildjdk
1019CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
1020CLEAN_SUPPORT_DIRS += demos
1021CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
1022CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
1023CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
1024CLEAN_PHASES := gensrc java native include
1025CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
1026CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
1027# Construct targets of the form clean-$module-$phase
1028CLEAN_MODULE_PHASE_TARGETS := $(addprefix clean-, $(foreach m, $(ALL_MODULES), \
1029    $(addprefix $m-, $(CLEAN_PHASES))))
1030
1031# Remove everything, except the output from configure.
1032clean: $(CLEAN_DIR_TARGETS)
1033	($(CD) $(OUTPUT_ROOT) && $(RM) -r build*.log*)
1034	$(ECHO) Cleaned all build artifacts.
1035
1036clean-docs:
1037	$(call CleanDocs)
1038
1039$(CLEAN_DIR_TARGETS):
1040	$(call CleanDir,$(patsubst clean-%, %, $@))
1041
1042$(CLEAN_SUPPORT_DIR_TARGETS):
1043	$(call CleanSupportDir,$(patsubst clean-%, %, $@))
1044
1045$(CLEAN_TEST_TARGETS):
1046	$(call CleanTest,$(patsubst clean-test-%, %, $@))
1047
1048$(CLEAN_PHASE_TARGETS):
1049	$(call Clean-$(patsubst clean-%,%, $@))
1050
1051$(CLEAN_MODULE_TARGETS):
1052	$(call CleanModule,$(patsubst clean-%, %, $@))
1053
1054$(CLEAN_MODULE_PHASE_TARGETS):
1055	$(call Clean-$(word 3, $(subst -,$(SPACE),$@)), \
1056	    $(word 2, $(subst -,$(SPACE),$@)))
1057
1058# When removing the support dir, we must also remove jdk. Building classes has
1059# the side effect of generating native headers. The headers end up in support
1060# while classes and touch files end up in jdk.
1061clean-support: clean-jdk
1062
1063# Remove everything, including configure configuration. If the output
1064# directory was created by configure and now becomes empty, remove it as well.
1065dist-clean: clean
1066	($(CD) $(OUTPUT_ROOT) && \
1067	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide)
1068	$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
1069	  if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
1070	    $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
1071	  else \
1072	    ($(CD) $(SRC_ROOT) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" \
1073	        && $(RM) -r $(OUTPUT_ROOT)) \
1074	  fi \
1075	)
1076	$(ECHO) Cleaned everything, you will have to re-run configure.
1077
1078ALL_TARGETS += clean clean-docs dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_SUPPORT_DIR_TARGETS) \
1079    $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) $(CLEAN_MODULE_TARGETS) \
1080    $(CLEAN_MODULE_PHASE_TARGETS)
1081
1082################################################################################
1083# Declare *-only targets for each normal target
1084$(foreach t, $(ALL_TARGETS), $(eval $(t)-only: $(t)))
1085
1086ALL_TARGETS += $(addsuffix -only, $(filter-out dist-clean clean%, $(ALL_TARGETS)))
1087
1088################################################################################
1089
1090# Include JPRT targets
1091include $(SRC_ROOT)/make/Jprt.gmk
1092
1093################################################################################
1094
1095# The following targets are intentionally not added to ALL_TARGETS since they
1096# are internal only, to support Init.gmk.
1097
1098print-targets:
1099	  @$(ECHO) $(sort $(ALL_TARGETS))
1100
1101print-modules:
1102	  @$(ECHO) $(sort $(ALL_MODULES))
1103
1104print-tests:
1105	  @$(ECHO) $(sort $(ALL_NAMED_TESTS))
1106
1107create-main-targets-include:
1108	  $(call LogInfo, Generating main target list)
1109	  @$(ECHO) ALL_MAIN_TARGETS := $(sort $(ALL_TARGETS)) > \
1110	      $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk
1111
1112################################################################################
1113
1114.PHONY: $(ALL_TARGETS)
1115
1116FRC: # Force target
1117