Main.gmk revision 1961:f900d5afd9c8
1181834Sroberto#
2280849Scy# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
3280849Scy# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4181834Sroberto#
5181834Sroberto# This code is free software; you can redistribute it and/or modify it
6181834Sroberto# under the terms of the GNU General Public License version 2 only, as
7181834Sroberto# published by the Free Software Foundation.  Oracle designates this
8181834Sroberto# particular file as subject to the "Classpath" exception as provided
9280849Scy# by Oracle in the LICENSE file that accompanied this code.
10280849Scy#
11280849Scy# This code is distributed in the hope that it will be useful, but WITHOUT
12181834Sroberto# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13181834Sroberto# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14280849Scy# version 2 for more details (a copy is included in the LICENSE file that
15280849Scy# accompanied this code).
16285169Scy#
17181834Sroberto# You should have received a copy of the GNU General Public License version
18280849Scy# 2 along with this work; if not, write to the Free Software Foundation,
19280849Scy# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20280849Scy#
21181834Sroberto# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22280849Scy# or visit www.oracle.com if you need additional information or have any
23280849Scy# questions.
24181834Sroberto#
25280849Scy
26280849Scy################################################################################
27181834Sroberto# This is the main makefile containing most actual top level targets. It needs
28280849Scy# to be called with a SPEC file defined.
29181834Sroberto################################################################################
30280849Scy
31280849Scy# Declare default target
32280849Scydefault:
33181834Sroberto
34181834Srobertoifeq ($(wildcard $(SPEC)),)
35280849Scy  $(error Main.gmk needs SPEC set to a proper spec.gmk)
36280849Scyendif
37280849Scy
38280849Scy# Now load the spec
39181834Srobertoinclude $(SPEC)
40280849Scy
41280849Scyinclude $(SRC_ROOT)/make/MainSupport.gmk
42280849Scy
43280849Scy# Load the vital tools for all the makefiles.
44181834Srobertoinclude $(SRC_ROOT)/make/common/MakeBase.gmk
45280849Scyinclude $(SRC_ROOT)/make/common/Modules.gmk
46280849Scy
47280849Scy# Declare ALL_TARGETS as an immediate variable. This variable is a list of all
48280849Scy# valid top level targets. It's used to declare them all as PHONY and to
49280849Scy# generate the -only targets.
50181834SrobertoALL_TARGETS :=
51280849Scy
52280849Scy# Hook to include the corresponding custom file, if present.
53280849Scy$(eval $(call IncludeCustomExtension, , Main.gmk))
54280849Scy
55181834Sroberto# All modules for the current target platform.
56280849ScyALL_MODULES := $(call FindAllModules)
57280849Scy
58280849Scy################################################################################
59280849Scy################################################################################
60280849Scy#
61181834Sroberto# Recipes for all targets. Only recipes, dependencies are declared later.
62181834Sroberto#
63280849Scy################################################################################
64181834Sroberto
65181834Sroberto################################################################################
66181834Sroberto# Interim/build tools targets, compiling tools used during the build
67280849Scy
68280849Scybuildtools-langtools:
69181834Sroberto	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Tools.gmk)
70181834Sroberto
71181834Srobertointerim-langtools:
72181834Sroberto	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterim.gmk)
73280849Scy
74181834Srobertointerim-rmic:
75181834Sroberto	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterimRmic.gmk)
76280849Scy
77181834Srobertointerim-cldrconverter:
78280849Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimCLDRConverter.gmk)
79181834Sroberto
80280849Scybuildtools-jdk:
81280849Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)
82181834Sroberto
83181834SrobertoALL_TARGETS += buildtools-langtools interim-langtools \
84181834Sroberto    interim-rmic interim-cldrconverter buildtools-jdk
85181834Sroberto
86280849Scy################################################################################
87181834Sroberto# Special targets for certain modules
88181834Sroberto
89280849Scyimport-hotspot:
90181834Sroberto	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Import.gmk)
91181834Sroberto
92181834Srobertounpack-sec:
93280849Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UnpackSecurity.gmk)
94280849Scy
95181834Srobertogenerate-exported-symbols:
96181834Sroberto	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildStatic.gmk)
97181834Sroberto
98181834SrobertoALL_TARGETS += import-hotspot unpack-sec generate-exported-symbols
99280849Scy
100181834Sroberto################################################################################
101280849Scy# Gensrc targets, generating source before java compilation can be done
102280849Scy$(eval $(call DeclareRecipesForPhase, GENSRC, \
103181834Sroberto    TARGET_SUFFIX := gensrc, \
104181834Sroberto    FILE_PREFIX := Gensrc, \
105181834Sroberto    MAKE_SUBDIR := gensrc, \
106181834Sroberto    CHECK_MODULES := $(ALL_MODULES), \
107181834Sroberto    MULTIPLE_MAKEFILES := true))
108280849Scy
109181834SrobertoJDK_GENSRC_TARGETS := $(filter %-gensrc-jdk, $(GENSRC_TARGETS))
110181834SrobertoLANGTOOLS_GENSRC_TARGETS := $(filter %-gensrc-langtools, $(GENSRC_TARGETS))
111181834SrobertoCORBA_GENSRC_TARGETS := $(filter %-gensrc-corba, $(GENSRC_TARGETS))
112181834SrobertoHOTSPOT_GENSRC_TARGETS := $(filter %-gensrc-hotspot, $(GENSRC_TARGETS))
113181834Sroberto
114280849ScyGENSRC_MODULEINFO_MODULES := $(ALL_MODULES)
115280849ScyGENSRC_MODULEINFO_TARGETS := $(addsuffix -gensrc-moduleinfo, \
116280849Scy    $(GENSRC_MODULEINFO_MODULES))
117280849Scy
118181834SrobertoGENSRC_MODULES := $(GENSRC_MODULEINFO_MODULES)
119280849ScyGENSRC_TARGETS += $(sort $(GENSRC_MODULEINFO_TARGETS) \
120181834Sroberto    $(addsuffix -gensrc, $(GENSRC_MODULES)))
121181834Sroberto
122181834Srobertodefine DeclareModuleInfoRecipe
123181834Sroberto  $1-gensrc-moduleinfo:
124181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
125280849Scy	    -f GensrcModuleInfo.gmk MODULE=$1)
126280849Scy
127181834Sroberto  $1-gensrc: $1-gensrc-moduleinfo
128181834Srobertoendef
129181834Sroberto
130181834Sroberto$(foreach m, $(GENSRC_MODULEINFO_MODULES), $(eval $(call DeclareModuleInfoRecipe,$m)))
131181834Sroberto
132181834SrobertoALL_TARGETS += $(GENSRC_TARGETS)
133181834Sroberto
134280849Scy################################################################################
135181834Sroberto# Generate data targets
136181834Sroberto$(eval $(call DeclareRecipesForPhase, GENDATA, \
137181834Sroberto    TARGET_SUFFIX := gendata, \
138280849Scy    FILE_PREFIX := Gendata, \
139280849Scy    MAKE_SUBDIR := gendata, \
140181834Sroberto    CHECK_MODULES := $(ALL_MODULES), \
141181834Sroberto    USE_WRAPPER := true))
142181834Sroberto
143181834SrobertoALL_TARGETS += $(GENDATA_TARGETS)
144181834Sroberto
145181834Sroberto################################################################################
146280849Scy# Copy files targets
147181834Sroberto$(eval $(call DeclareRecipesForPhase, COPY, \
148181834Sroberto    TARGET_SUFFIX := copy, \
149181834Sroberto    FILE_PREFIX := Copy, \
150181834Sroberto    MAKE_SUBDIR := copy, \
151181834Sroberto    CHECK_MODULES := $(ALL_MODULES), \
152181834Sroberto    USE_WRAPPER := true, \
153181834Sroberto    MULTIPLE_MAKEFILES := true))
154181834Sroberto
155280849ScyALL_COPY_MODULES += $(COPY_MODULES)
156280849ScyALL_COPY_TARGETS += $(COPY_TARGETS)
157280849Scy
158181834SrobertoIMPORT_COPY_MODULES := $(call FindImportedModules)
159181834SrobertoIMPORT_COPY_TARGETS := $(addsuffix -copy, $(IMPORT_COPY_MODULES))
160181834SrobertoALL_COPY_MODULES += $(IMPORT_COPY_MODULES)
161181834SrobertoALL_COPY_TARGETS += $(IMPORT_COPY_TARGETS)
162181834Sroberto
163181834Srobertodefine DeclareImportCopyRecipe
164181834Sroberto  $1-copy:
165181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
166181834Sroberto	    -f CopyImportModules.gmk MODULE=$1)
167280849Scyendef
168181834Sroberto
169181834Sroberto$(foreach m, $(IMPORT_COPY_MODULES), $(eval $(call DeclareImportCopyRecipe,$m)))
170280849Scy
171181834SrobertoALL_TARGETS += $(ALL_COPY_TARGETS)
172181834Sroberto
173181834Sroberto################################################################################
174181834Sroberto# Targets for compiling all java modules. Nashorn is treated separately.
175280849ScyJAVA_MODULES := $(ALL_MODULES)
176280849ScyJAVA_TARGETS := $(addsuffix -java, $(JAVA_MODULES))
177280849Scy
178181834Srobertodefine DeclareCompileJavaRecipe
179181834Sroberto  $1-java:
180181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
181181834Sroberto	    -f CompileJavaModules.gmk MODULE=$1)
182280849Scyendef
183181834Sroberto
184280849Scy$(foreach m, $(filter-out jdk.scripting.nashorn, $(JAVA_MODULES)), \
185280849Scy    $(eval $(call DeclareCompileJavaRecipe,$m)))
186181834Sroberto
187181834Sroberto# Build nashorn. Needs to be compiled separately from the rest of the modules
188280849Scy# due to nasgen.
189280849Scyjdk.scripting.nashorn-java:
190181834Sroberto	+($(CD) $(NASHORN_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
191181834Sroberto	    -f BuildNashorn.gmk compile)
192280849Scy
193280849ScyALL_TARGETS += $(JAVA_TARGETS)
194181834Sroberto
195181834Sroberto################################################################################
196181834Sroberto# Targets for running rmic.
197181834Sroberto$(eval $(call DeclareRecipesForPhase, RMIC, \
198181834Sroberto    TARGET_SUFFIX := rmic, \
199280849Scy    FILE_PREFIX := Rmic, \
200280849Scy    MAKE_SUBDIR := rmic, \
201280849Scy    CHECK_MODULES := $(ALL_MODULES)))
202181834Sroberto
203181834SrobertoALL_TARGETS += $(RMIC_TARGETS)
204181834Sroberto
205280849Scy################################################################################
206280849Scy# Targets for compiling native libraries
207181834Sroberto$(eval $(call DeclareRecipesForPhase, LIBS, \
208181834Sroberto    TARGET_SUFFIX := libs, \
209181834Sroberto    FILE_PREFIX := Lib, \
210181834Sroberto    MAKE_SUBDIR := lib, \
211280849Scy    CHECK_MODULES := $(ALL_MODULES), \
212181834Sroberto    USE_WRAPPER := true))
213181834Sroberto
214181834SrobertoALL_TARGETS += $(LIBS_TARGETS)
215181834Sroberto
216280849Scy################################################################################
217280849Scy# Targets for compiling native executables
218280849Scy$(eval $(call DeclareRecipesForPhase, LAUNCHER, \
219181834Sroberto    TARGET_SUFFIX := launchers, \
220280849Scy    FILE_PREFIX := Launcher, \
221280849Scy    MAKE_SUBDIR := launcher, \
222181834Sroberto    CHECK_MODULES := $(ALL_MODULES), \
223280849Scy    USE_WRAPPER := true))
224280849Scy
225280849ScyALL_TARGETS += $(LAUNCHER_TARGETS)
226280849Scy
227280849Scy################################################################################
228181834Sroberto# Build hotspot target
229280849Scy
230280849Scyifeq ($(BUILD_HOTSPOT),true)
231280849Scy  hotspot:
232280849Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk)
233181834Srobertoendif
234181834Sroberto
235280849ScyALL_TARGETS += hotspot
236181834Sroberto
237181834Sroberto################################################################################
238280849Scy# Build demos and samples targets
239280849Scy
240280849Scydemos-jdk:
241280849Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk)
242280849Scy
243181834Srobertosamples-jdk:
244280849Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopySamples.gmk)
245280849Scy
246181834SrobertoALL_TARGETS += demos-jdk samples-jdk
247181834Sroberto
248280849Scy################################################################################
249181834Sroberto# Jigsaw specific data and analysis targets.
250280849Scy
251181834Srobertogenerate-summary:
252280849Scy	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) -f GenerateModuleSummary.gmk)
253181834Sroberto
254280849ScyALL_TARGETS += generate-summary
255280849Scy
256181834Sroberto################################################################################
257181834Sroberto# Strip binaries targets
258181834Sroberto
259181834SrobertoSTRIP_MODULES := $(sort $(LIBS_MODULES) $(LAUNCHER_MODULES) $(COPY_MODULES) \
260181834Sroberto    $(GENDATA_MODULES))
261280849ScySTRIP_TARGETS := $(addsuffix -strip, $(STRIP_MODULES))
262181834Sroberto
263181834Srobertodefine DeclareStripRecipe
264280849Scy  $1-strip:
265280849Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f StripBinaries.gmk \
266181834Sroberto	    MODULE=$1)
267280849Scyendef
268181834Sroberto
269181834Sroberto$(foreach m, $(STRIP_MODULES), $(eval $(call DeclareStripRecipe,$m)))
270280849Scy
271181834SrobertoALL_TARGETS += $(STRIP_TARGETS)
272280849Scy
273181834Sroberto################################################################################
274280849Scy# Jmod targets
275280849Scy
276181834SrobertoJMOD_MODULES := $(ALL_MODULES)
277280849ScyJMOD_TARGETS := $(addsuffix -jmod, $(JMOD_MODULES))
278181834Sroberto
279181834Srobertodefine DeclareJmodRecipe
280181834Sroberto  $1-jmod:
281181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
282181834Sroberto	    MODULE=$1)
283181834Srobertoendef
284181834Sroberto
285181834Sroberto$(foreach m, $(JMOD_MODULES), $(eval $(call DeclareJmodRecipe,$m)))
286181834Sroberto
287181834SrobertoALL_TARGETS += $(JMOD_TARGETS)
288181834Sroberto
289181834Sroberto################################################################################
290181834Sroberto# Images targets
291181834Sroberto
292181834Sroberto# Stores the tips for each repository. This file is be used when constructing the jdk image and can be
293181834Sroberto# used to track the exact sources used to build that image.
294181834Srobertosource-tips: $(SUPPORT_OUTPUTDIR)/source_tips
295181834Sroberto$(SUPPORT_OUTPUTDIR)/source_tips: FRC
296181834Sroberto	$(call MakeDir, $(@D))
297181834Sroberto	@$(RM) $@
298181834Sroberto	@$(call GetSourceTips)
299181834Sroberto
300181834SrobertoBOOTCYCLE_TARGET := product-images
301181834Srobertobootcycle-images:
302285169Scy	@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
303285169Scy	+$(MAKE) -f $(SRC_ROOT)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
304285169Scy	    JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
305181834Sroberto
306181834Srobertozip-security:
307181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSecurity.gmk)
308181834Sroberto
309181834Srobertozip-source:
310181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSource.gmk)
311181834Sroberto
312181834Srobertojrtfs-jar:
313181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f JrtfsJar.gmk)
314181834Sroberto
315181834Srobertojimages:
316181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jimages)
317181834Sroberto
318181834Srobertoprofiles:
319181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)
320181834Sroberto
321181834Srobertomac-bundles-jdk:
322181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk)
323181834Sroberto
324181834SrobertoALL_TARGETS += source-tips bootcycle-images zip-security zip-source \
325181834Sroberto    jrtfs-jar jimages profiles mac-bundles-jdk
326181834Sroberto
327181834Sroberto################################################################################
328181834Sroberto# Docs targets
329181834Sroberto
330181834Srobertodocs-javadoc:
331181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs)
332181834Sroberto
333280849Scydocs-jvmtidoc:
334181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk jvmtidocs)
335280849Scy
336280849ScyALL_TARGETS += docs-javadoc docs-jvmtidoc
337280849Scy
338181834Sroberto################################################################################
339181834Sroberto# Cross compilation support
340181834Sroberto
341181834Srobertoifeq ($(CREATE_BUILDJDK), true)
342280849Scy  # This target is only called by the recursive call below.
343280849Scy  create-buildjdk-compile-hotspot-helper: hotspot
344181834Sroberto  create-buildjdk-compile-modules-helper: jdk.jlink-launchers java.base-copy
345181834Srobertoendif
346181834Sroberto
347181834Srobertocreate-buildjdk-copy:
348181834Sroberto	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateBuildJdkCopy.gmk)
349280849Scy
350280849Scycreate-buildjdk-compile-hotspot create-buildjdk-compile-modules:
351280849Scy	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Main.gmk \
352181834Sroberto	    $@-helper \
353181834Sroberto	    SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
354280849Scy	    HOTSPOT_SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
355280849Scy	    CREATING_BUILDJDK=true)
356181834Sroberto
357181834SrobertoALL_TARGETS += create-buildjdk-copy create-buildjdk-compile-hotspot \
358181834Sroberto    create-buildjdk-compile-modules
359181834Sroberto
360181834Sroberto################################################################################
361181834Sroberto# Build tests
362181834Sroberto#
363181834Sroberto
364280849Scyprepare-test-image:
365280849Scy	$(MKDIR) -p $(TEST_IMAGE_DIR)
366280849Scy	$(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image'
367280849Scy
368280849Scybuild-test-hotspot-jtreg-native:
369280849Scy	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
370280849Scy	    build-test-hotspot-jtreg-native)
371181834Sroberto
372280849Scytest-image-hotspot-jtreg-native:
373280849Scy	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
374280849Scy	    test-image-hotspot-jtreg-native)
375181834Sroberto
376181834Srobertobuild-test-jdk-jtreg-native:
377280849Scy	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
378181834Sroberto	    build-test-jdk-jtreg-native)
379181834Sroberto
380181834Srobertotest-image-jdk-jtreg-native:
381181834Sroberto	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
382181834Sroberto	    test-image-jdk-jtreg-native)
383280849Scy
384280849Scybuild-test-lib:
385280849Scy	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk)
386181834Sroberto
387280849ScyALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \
388181834Sroberto    test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
389181834Sroberto    test-image-jdk-jtreg-native build-test-lib
390280849Scy
391280849Scy################################################################################
392181834Sroberto# Run tests
393181834Sroberto
394181834Sroberto# Run tests specified by $(TEST), or the default test set.
395181834Srobertotest:
396181834Sroberto	$(call RunTests, $(TEST))
397181834Sroberto
398test-hotspot-jtreg:
399	$(call RunTests, "hotspot_all")
400
401test-hotspot-jtreg-native:
402	$(call RunTests, "hotspot_native_sanity")
403
404test-hotspot-internal:
405	$(call RunTests, "hotspot_internal")
406
407test-jdk-jtreg-native:
408	$(call RunTests, "jdk_native_sanity")
409
410test-make:
411	($(CD) $(SRC_ROOT)/test/make && $(MAKE) $(MAKE_ARGS) -f TestMake.gmk $(TEST_TARGET))
412
413ALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \
414    test-hotspot-internal test-jdk-jtreg-native test-make
415
416################################################################################
417# Install targets
418
419install:
420	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Install.gmk)
421
422ALL_TARGETS += install
423
424################################################################################
425#
426# Dependency declarations between targets.
427#
428# These are declared in two groups. First all dependencies between targets that
429# have recipes above as these dependencies may be disabled. Then the aggregator
430# targets that do not have recipes of their own, which will never have their
431# dependencies disabled.
432#
433################################################################################
434# Targets with recipes above
435
436# If running an *-only target, parallel execution and dependencies between
437# recipe targets are disabled. This makes it possible to run a select set of
438# recipe targets in order. It's the responsibility of the user to make sure
439# all prerequisites are fulfilled.
440ifneq ($(findstring -only, $(MAKECMDGOALS)), )
441  .NOTPARALLEL:
442else
443  $(LANGTOOLS_GENSRC_TARGETS): buildtools-langtools
444
445  interim-langtools: $(LANGTOOLS_GENSRC_TARGETS)
446
447  buildtools-jdk: interim-langtools interim-cldrconverter
448
449  $(CORBA_GENSRC_TARGETS): interim-langtools
450
451  $(HOTSPOT_GENSRC_TARGETS): interim-langtools
452
453  $(JDK_GENSRC_TARGETS): interim-langtools buildtools-jdk
454
455  $(GENSRC_MODULEINFO_TARGETS): buildtools-jdk
456
457  $(GENDATA_TARGETS): interim-langtools buildtools-jdk
458
459  interim-rmic: interim-langtools
460
461  $(RMIC_TARGETS): interim-langtools interim-rmic
462
463  $(JAVA_TARGETS): interim-langtools
464
465  import-hotspot: hotspot
466
467  generate-exported-symbols: java.base-libs jdk.jdwp.agent-libs
468
469  $(LIBS_TARGETS): import-hotspot
470
471  $(LAUNCHER_TARGETS): java.base-libs
472
473  ifeq ($(STATIC_BUILD), true)
474    $(LAUNCHER_TARGETS): generate-exported-symbols
475  endif
476
477  # The demos are currently linking to libjvm and libjava, just like all other
478  # jdk libs, even though they don't need to. To avoid warnings, make sure they
479  # aren't built until after libjava and libjvm are available to link to.
480  demos-jdk: $(JAVA_TARGETS)
481
482  # Declare dependency from <module>-java to <module>-gensrc
483  $(foreach m, $(GENSRC_MODULES), $(eval $m-java: $m-gensrc))
484
485  # Declare dependencies between java modules
486  $(foreach m, $(JAVA_MODULES), \
487      $(eval $m-java: $(addsuffix -java, $(filter $(JAVA_MODULES), \
488      $(call FindDepsForModule,$m)))))
489
490  # Declare dependencies between <module>-rmic to <module>-java
491  $(foreach m, $(RMIC_MODULES), $(eval $m-rmic: $m-java))
492
493  # Declare dependencies from <module>-lib to <module>-java
494  # Skip modules that do not have java source. When creating a BUILD_JDK, the
495  # java compilation has already been done by the normal build and copied in.
496  ifneq ($(CREATING_BUILDJDK), true)
497  $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs: $m-java))
498  endif
499
500  # Declare dependencies from all other <module>-lib to java.base-lib
501  $(foreach t, $(filter-out java.base-libs, $(LIBS_TARGETS)), \
502      $(eval $t: java.base-libs))
503
504  # jdk.accessibility depends on java.desktop
505  jdk.accessibility-libs: java.desktop-libs
506
507  # This dependency needs to be explicitly declared. jdk.jdi-gensrc generates a
508  # header file used by jdk.jdwp.agent-libs. The jdk.jdwp.agent-gensrc is a
509  # virtual target.
510  jdk.jdwp.agent-libs: jdk.jdwp.agent-gensrc
511
512  # The swing beans need to have java base properly generated to avoid errors
513  # in javadoc.
514  java.desktop-gensrc-jdk: java.base-gensrc
515
516  # The annotation processing for jdk.vm.ci needs java.base classes from the
517  # current JDK.
518  jdk.vm.ci-gensrc-hotspot: java.base-java
519
520  # Explicitly add dependencies for special targets
521  java.base-java: unpack-sec
522
523  # The copy target copies files generated by gensrc
524  java.base-copy-hotspot: java.base-gensrc-hotspot
525
526  jdk.jdeps-gendata: java rmic
527
528  # Declare dependencies from <module>-strip to libs, launchers, gendata and copy
529  $(foreach m, $(LIBS_MODULES), $(eval $m-strip: $m-libs))
530  $(foreach m, $(LAUNCHER_MODULES), $(eval $m-strip: $m-launchers))
531  $(foreach m, $(GENDATA_MODULES), $(eval $m-strip: $m-gendata))
532  $(foreach m, $(COPY_MODULES), $(eval $m-strip: $m-copy))
533
534  # Declare dependencies between jmod targets
535  $(foreach m, $(JMOD_MODULES), \
536      $(eval $m-jmod: $(addsuffix -jmod, $(call FindDepsForModule,$m))))
537
538  # Declare dependencies from <module>-jmod to all other module targets
539  $(foreach m, $(STRIP_MODULES), $(eval $m-jmod: $m-strip))
540  $(foreach m, $(JAVA_MODULES), $(eval $m-jmod: $m-java))
541  $(foreach m, $(GENDATA_MODULES), $(eval $m-jmod: $m-gendata))
542  $(foreach m, $(RMIC_MODULES), $(eval $m-jmod: $m-rmic))
543  $(foreach m, $(LIBS_MODULES), $(eval $m-jmod: $m-libs))
544  $(foreach m, $(LAUNCHER_MODULES), $(eval $m-jmod: $m-launchers))
545  $(foreach m, $(COPY_MODULES), $(eval $m-jmod: $m-copy))
546
547  # Jmods cannot be created until we have the jlink tool ready to run, which requires
548  # all java modules to be compiled and jdk.jlink-launchers.
549  $(JMOD_TARGETS): java java.base-libs jdk.jlink-launchers
550
551  ifeq ($(CREATE_BUILDJDK), true)
552    $(JMOD_TARGETS): create-buildjdk
553  endif
554
555  zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
556      $(filter jdk.crypto%, $(JAVA_TARGETS))
557
558  zip-source: gensrc rmic
559
560  jrtfs-jar: interim-langtools
561
562  jimages: jmods zip-source source-tips demos samples jrtfs-jar
563
564  profiles: jmods zip-source source-tips jrtfs-jar
565
566  mac-bundles-jdk: jimages
567
568  bootcycle-images: jimages
569
570  docs-javadoc: $(GENSRC_TARGETS) rmic
571
572  docs-jvmtidoc: hotspot
573
574  test: jimages test-image
575
576  create-buildjdk-copy: jdk.jlink-java java.base-gendata
577
578  create-buildjdk-compile-modules: create-buildjdk-copy create-buildjdk-compile-hotspot
579
580  test-make: clean-test-make
581
582  build-test-lib: java
583
584  build-test-hotspot-jtreg-native: buildtools-jdk
585
586  build-test-jdk-jtreg-native: buildtools-jdk
587
588  test-image-hotspot-jtreg-native: build-test-hotspot-jtreg-native
589
590  test-image-jdk-jtreg-native: build-test-jdk-jtreg-native
591
592  test-hotspot-internal: exploded-image
593
594  test-hotspot-jtreg: jimages test-image
595
596  install: product-images
597
598  generate-summary: jmods
599
600endif
601
602################################################################################
603# Virtual targets without recipes
604
605buildtools: buildtools-langtools interim-langtools interim-rmic \
606    buildtools-jdk
607
608gensrc: $(GENSRC_TARGETS)
609
610gendata: $(GENDATA_TARGETS)
611
612copy: $(ALL_COPY_TARGETS)
613
614java: $(JAVA_TARGETS)
615
616rmic: $(RMIC_TARGETS)
617
618libs: $(LIBS_TARGETS)
619
620launchers: $(LAUNCHER_TARGETS)
621
622jmods: $(JMOD_TARGETS)
623
624strip-binaries: $(STRIP_TARGETS)
625
626# Explicitly declare dependency for virtual target jdk.jdwp.agent-gensrc which
627# is actually handled by jdk.jdi-gensrc
628jdk.jdwp.agent-gensrc: jdk.jdi-gensrc
629
630# Declare dependencies from <module> to all the individual targets specific
631# to that module <module>-*, that are needed for the exploded image.
632$(foreach m, $(GENSRC_MODULES), $(eval $m: $m-gensrc))
633$(foreach m, $(JAVA_MODULES), $(eval $m: $m-java))
634$(foreach m, $(GENDATA_MODULES), $(eval $m: $m-gendata))
635$(foreach m, $(RMIC_MODULES), $(eval $m: $m-rmic))
636$(foreach m, $(LIBS_MODULES), $(eval $m: $m-libs))
637$(foreach m, $(LAUNCHER_MODULES), $(eval $m: $m-launchers))
638$(foreach m, $(ALL_COPY_MODULES), $(eval $m: $m-copy))
639demos: demos-jdk
640
641samples: samples-jdk
642
643# The "exploded image" is a locally runnable JDK in $(BUILD_OUTPUT)/jdk.
644exploded-image: $(ALL_MODULES)
645
646create-buildjdk: create-buildjdk-compile-modules create-buildjdk-copy \
647    create-buildjdk-compile-hotspot
648
649mac-bundles: mac-bundles-jdk
650
651# The $(BUILD_OUTPUT)/images directory contain the resulting deliverables,
652# and in line with this, our targets for creating these are named *-image[s].
653
654# This target builds the product images, e.g. the JRE and JDK image
655# (and possibly other, more specific versions)
656product-images: jimages demos samples zip-security exploded-image
657
658# When cross compiling and building a partial BUILDJDK for the build host,
659# the summary generation cannot be run.
660ifneq ($(CREATE_BUILDJDK), true)
661  product-images: generate-summary
662endif
663
664ifeq ($(OPENJDK_TARGET_OS), macosx)
665  product-images: mac-bundles
666endif
667
668# This target builds the documentation image
669docs-image: docs-javadoc docs-jvmtidoc
670
671# This target builds the test image
672test-image: prepare-test-image test-image-hotspot-jtreg-native \
673    test-image-jdk-jtreg-native
674
675# all-images is the top-most target, it builds all our deliverables ("images").
676all-images: product-images test-image docs-image
677
678ALL_TARGETS += buildtools gensrc gendata copy java rmic libs launchers jmods \
679    jdk.jdwp.agent-gensrc $(ALL_MODULES) demos samples exploded-image \
680    create-buildjdk mac-bundles product-images docs-image test-image all-images
681
682################################################################################
683
684# Traditional targets typically run by users.
685# These can be considered aliases for the targets now named by a more
686# "modern" naming scheme.
687default: $(DEFAULT_MAKE_TARGET)
688jdk: exploded-image
689images: product-images
690docs: docs-image
691all: all-images
692
693ALL_TARGETS += default jdk images docs all
694
695################################################################################
696################################################################################
697#
698# Clean targets
699#
700################################################################################
701# Clean targets are automatically run serially by the Makefile calling this
702# file.
703
704CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
705    images make-support test-make bundles buildjdk
706CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
707CLEAN_SUPPORT_DIRS += demos
708CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
709CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
710CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
711CLEAN_PHASES := gensrc java native include docs
712CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
713CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
714# Construct targets of the form clean-$module-$phase
715CLEAN_MODULE_PHASE_TARGETS := $(addprefix clean-, $(foreach m, $(ALL_MODULES), \
716    $(addprefix $m-, $(CLEAN_PHASES))))
717
718# Remove everything, except the output from configure.
719clean: $(CLEAN_DIR_TARGETS)
720	($(CD) $(OUTPUT_ROOT) && $(RM) -r build*.log*)
721	$(ECHO) Cleaned all build artifacts.
722
723$(CLEAN_DIR_TARGETS):
724	$(call CleanDir,$(patsubst clean-%, %, $@))
725
726$(CLEAN_SUPPORT_DIR_TARGETS):
727	$(call CleanSupportDir,$(patsubst clean-%, %, $@))
728
729$(CLEAN_TEST_TARGETS):
730	$(call CleanTest,$(patsubst clean-test-%, %, $@))
731
732$(CLEAN_PHASE_TARGETS):
733	$(call Clean-$(patsubst clean-%,%, $@))
734
735$(CLEAN_MODULE_TARGETS):
736	$(call CleanModule,$(patsubst clean-%, %, $@))
737
738$(CLEAN_MODULE_PHASE_TARGETS):
739	$(call Clean-$(word 3, $(subst -,$(SPACE),$@)), \
740	    $(word 2, $(subst -,$(SPACE),$@)))
741
742# When removing the support dir, we must also remove jdk. Building classes has
743# the side effect of generating native headers. The headers end up in support
744# while classes and touch files end up in jdk.
745clean-support: clean-jdk
746
747# Remove everything, including configure configuration. If the output
748# directory was created by configure and now becomes empty, remove it as well.
749dist-clean: clean
750	($(CD) $(OUTPUT_ROOT) && \
751	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide)
752	$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
753	  if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
754	    $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
755	  else \
756	    ($(CD) $(SRC_ROOT) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" \
757	        && $(RM) -r $(OUTPUT_ROOT)) \
758	  fi \
759	)
760	$(ECHO) Cleaned everything, you will have to re-run configure.
761
762ALL_TARGETS += clean dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_SUPPORT_DIR_TARGETS) \
763    $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) $(CLEAN_MODULE_TARGETS) \
764    $(CLEAN_MODULE_PHASE_TARGETS)
765
766################################################################################
767# Declare *-only targets for each normal target
768$(foreach t, $(ALL_TARGETS), $(eval $(t)-only: $(t)))
769
770ALL_TARGETS += $(addsuffix -only, $(filter-out dist-clean clean%, $(ALL_TARGETS)))
771
772################################################################################
773
774# Include JPRT targets
775include $(SRC_ROOT)/make/Jprt.gmk
776
777################################################################################
778
779# The following targets are intentionally not added to ALL_TARGETS since they
780# are internal only, to support Init.gmk.
781
782print-targets:
783	  @$(ECHO) $(sort $(ALL_TARGETS))
784
785print-modules:
786	  @$(ECHO) $(sort $(ALL_MODULES))
787
788create-main-targets-include:
789	  $(call LogInfo, Generating main target list)
790	  @$(ECHO) ALL_MAIN_TARGETS := $(sort $(ALL_TARGETS)) > \
791	      $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk
792
793################################################################################
794
795.PHONY: $(ALL_TARGETS)
796
797FRC: # Force target
798