make/Main.gmk
author avstepan
Wed, 21 Dec 2016 17:34:41 +0300
changeset 43074 7f676353195d
parent 42292 11f0a32a38f0
child 42505 11439b0c0792
child 42529 d01162cb85f4
permissions -rw-r--r--
8154314: [TEST_BUG] java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java Reviewed-by: ssadetsky, serb Contributed-by: Maksim Khramov <maksim.khramov@oracle.com>

#
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

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

# Declare default target
default:

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

# Now load the spec
include $(SPEC)

include $(SRC_ROOT)/make/MainSupport.gmk

# Load the vital tools for all the makefiles.
include $(SRC_ROOT)/make/common/MakeBase.gmk
include $(SRC_ROOT)/make/common/Modules.gmk

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

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

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

################################################################################
################################################################################
#
# Recipes for all targets. Only recipes, dependencies are declared later.
#
################################################################################

################################################################################
# Interim/build tools targets, compiling tools used during the build

# When creating a BUILDJDK, the buildtools and interim targets have already
# been built and should not be built again.
ifneq ($(CREATING_BUILDJDK), true)
  buildtools-langtools:
	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Tools.gmk)

  interim-langtools:
	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterim.gmk)

  interim-rmic:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterimRmic.gmk)

  interim-cldrconverter:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimCLDRConverter.gmk)

  buildtools-jdk:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)

  buildtools-modules:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileModuleTools.gmk)
endif

ALL_TARGETS += buildtools-langtools interim-langtools \
    interim-rmic interim-cldrconverter buildtools-jdk buildtools-modules

################################################################################
# Special targets for certain modules

unpack-sec:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UnpackSecurity.gmk)

generate-exported-symbols:
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildStatic.gmk)

ALL_TARGETS += unpack-sec generate-exported-symbols

################################################################################
# Gensrc targets, generating source before java compilation can be done
#
# When creating a BUILDJDK, the java targets have already been built and copied
# into the buildjdk so no need to generate sources.
ifneq ($(CREATING_BUILDJDK), true)
  $(eval $(call DeclareRecipesForPhase, GENSRC, \
      TARGET_SUFFIX := gensrc, \
      FILE_PREFIX := Gensrc, \
      MAKE_SUBDIR := gensrc, \
      CHECK_MODULES := $(ALL_MODULES), \
      MULTIPLE_MAKEFILES := true))

  JDK_GENSRC_TARGETS := $(filter %-gensrc-jdk, $(GENSRC_TARGETS))
  LANGTOOLS_GENSRC_TARGETS := $(filter %-gensrc-langtools, $(GENSRC_TARGETS))
  CORBA_GENSRC_TARGETS := $(filter %-gensrc-corba, $(GENSRC_TARGETS))
  HOTSPOT_GENSRC_TARGETS := $(filter %-gensrc-hotspot, $(GENSRC_TARGETS))

  GENSRC_MODULEINFO_MODULES := $(ALL_MODULES)
  GENSRC_MODULEINFO_TARGETS := $(addsuffix -gensrc-moduleinfo, \
      $(GENSRC_MODULEINFO_MODULES))

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

  define DeclareModuleInfoRecipe
    $1-gensrc-moduleinfo:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
	    -f GensrcModuleInfo.gmk MODULE=$1)

    $1-gensrc: $1-gensrc-moduleinfo
  endef

  $(foreach m, $(GENSRC_MODULEINFO_MODULES), $(eval $(call DeclareModuleInfoRecipe,$m)))
endif

ALL_TARGETS += $(GENSRC_TARGETS)

################################################################################
# Generate data targets
$(eval $(call DeclareRecipesForPhase, GENDATA, \
    TARGET_SUFFIX := gendata, \
    FILE_PREFIX := Gendata, \
    MAKE_SUBDIR := gendata, \
    CHECK_MODULES := $(ALL_MODULES), \
    USE_WRAPPER := true))

ALL_TARGETS += $(GENDATA_TARGETS)

################################################################################
# Copy files targets
$(eval $(call DeclareRecipesForPhase, COPY, \
    TARGET_SUFFIX := copy, \
    FILE_PREFIX := Copy, \
    MAKE_SUBDIR := copy, \
    CHECK_MODULES := $(ALL_MODULES), \
    USE_WRAPPER := true, \
    MULTIPLE_MAKEFILES := true))

ALL_COPY_MODULES += $(COPY_MODULES)
ALL_COPY_TARGETS += $(COPY_TARGETS)

IMPORT_COPY_MODULES := $(call FindImportedModules)
IMPORT_COPY_TARGETS := $(addsuffix -copy, $(IMPORT_COPY_MODULES))
ALL_COPY_MODULES += $(IMPORT_COPY_MODULES)
ALL_COPY_TARGETS += $(IMPORT_COPY_TARGETS)

define DeclareImportCopyRecipe
  $1-copy:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
	    -f CopyImportModules.gmk MODULE=$1)
endef

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

ALL_TARGETS += $(ALL_COPY_TARGETS)

################################################################################
# Targets for compiling all java modules. Nashorn is treated separately.
JAVA_MODULES := $(ALL_MODULES)
JAVA_TARGETS := $(addsuffix -java, $(JAVA_MODULES))

define DeclareCompileJavaRecipe
  $1-java:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
	    -f CompileJavaModules.gmk MODULE=$1)
endef

$(foreach m, $(filter-out jdk.scripting.nashorn, $(JAVA_MODULES)), \
    $(eval $(call DeclareCompileJavaRecipe,$m)))

# Build nashorn. Needs to be compiled separately from the rest of the modules
# due to nasgen.
jdk.scripting.nashorn-java:
	+($(CD) $(NASHORN_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
	    -f BuildNashorn.gmk compile)

ALL_TARGETS += $(JAVA_TARGETS)

################################################################################
# Targets for running rmic.
$(eval $(call DeclareRecipesForPhase, RMIC, \
    TARGET_SUFFIX := rmic, \
    FILE_PREFIX := Rmic, \
    MAKE_SUBDIR := rmic, \
    CHECK_MODULES := $(ALL_MODULES)))

ALL_TARGETS += $(RMIC_TARGETS)

################################################################################
# Targets for compiling native libraries
$(eval $(call DeclareRecipesForPhase, LIBS, \
    TARGET_SUFFIX := libs, \
    FILE_PREFIX := Lib, \
    MAKE_SUBDIR := lib, \
    CHECK_MODULES := $(ALL_MODULES), \
    USE_WRAPPER := true))

ALL_TARGETS += $(LIBS_TARGETS)

################################################################################
# Targets for compiling native executables
$(eval $(call DeclareRecipesForPhase, LAUNCHER, \
    TARGET_SUFFIX := launchers, \
    FILE_PREFIX := Launcher, \
    MAKE_SUBDIR := launcher, \
    CHECK_MODULES := $(ALL_MODULES), \
    USE_WRAPPER := true))

ALL_TARGETS += $(LAUNCHER_TARGETS)

################################################################################
# Build hotspot target

ifeq ($(BUILD_HOTSPOT),true)
  hotspot:
	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildHotspot.gmk)
endif

hotspot-ide-project:
	+($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ide/CreateVSProject.gmk)

ALL_TARGETS += hotspot hotspot-ide-project

################################################################################
# Build demos and samples targets

demos-jdk:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk)

samples-jdk:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopySamples.gmk)

ALL_TARGETS += demos-jdk samples-jdk

################################################################################
# Jigsaw specific data and analysis targets.

generate-summary:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) -f GenerateModuleSummary.gmk)

ALL_TARGETS += generate-summary

################################################################################
# Jmod targets

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

define DeclareJmodRecipe
  $1-jmod:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
	    MODULE=$1)
endef

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

ALL_TARGETS += $(JMOD_TARGETS)

################################################################################
# Images targets

store-source-revision:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk store-source-revision)

create-source-revision-tracker:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk create-source-revision-tracker)

BOOTCYCLE_TARGET := product-images
bootcycle-images:
        ifneq ($(COMPILE_TYPE), cross)
	  $(call LogWarn, Boot cycle build step 2: Building a new JDK image using previously built image)
	  +$(MAKE) -f $(SRC_ROOT)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
	      JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
        else
	  $(call LogWarn, Boot cycle build disabled when cross compiling)
        endif

zip-security:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSecurity.gmk)

zip-source:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSource.gmk)

jrtfs-jar:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f JrtfsJar.gmk)

jdk-image:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jdk)

jre-image:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jre)

symbols-image:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk symbols)

profiles:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)

mac-bundles-jdk:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk)

release-file:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ReleaseFile.gmk)

exploded-image-optimize:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk)

ALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \
    zip-source jrtfs-jar jdk-image jre-image \
    symbols-image profiles mac-bundles-jdk \
    release-file exploded-image-optimize

################################################################################
# Docs targets

docs-javadoc:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-javadoc)

docs-copy:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-copy)

docs-zip:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-zip)

ALL_TARGETS += docs-javadoc docs-copy docs-zip

################################################################################
# Cross compilation support

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

create-buildjdk-copy:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateBuildJdkCopy.gmk)

create-buildjdk-interim-image:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Main.gmk \
	    $@-helper \
	    SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
	    HOTSPOT_SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
	    CREATING_BUILDJDK=true)

ALL_TARGETS += create-buildjdk-copy create-buildjdk-interim-image

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

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

define DeclareInterimJmodRecipe
  $1-interim-jmod:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
	    MODULE=$1 \
	    JMODS_DIR=$(INTERIM_JMODS_DIR) \
	    JMODS_TEMPDIR=$(INTERIM_JMODS_DIR)/temp \
	    INTERIM_JMOD=true \
	)
endef

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

interim-image:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f InterimImage.gmk)

ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
  generate-link-opt-data:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f GenerateLinkOptData.gmk)
endif

ALL_TARGETS += $(INTERIM_JMOD_TARGETS) interim-image generate-link-opt-data

################################################################################
# Build tests
#

prepare-test-image:
	$(MKDIR) -p $(TEST_IMAGE_DIR)
	$(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image'

build-test-hotspot-jtreg-native:
	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
	    build-test-hotspot-jtreg-native)

test-image-hotspot-jtreg-native:
	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
	    test-image-hotspot-jtreg-native)

build-test-jdk-jtreg-native:
	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
	    build-test-jdk-jtreg-native)

test-image-jdk-jtreg-native:
	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
	    test-image-jdk-jtreg-native)

ifeq ($(BUILD_GTEST), true)
  test-image-hotspot-gtest:
	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f GtestImage.gmk)
endif

build-test-lib:
	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk)

ifeq ($(BUILD_FAILURE_HANDLER), true)
  # Builds the failure handler jtreg extension
  build-test-failure-handler:
	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
	    -f BuildFailureHandler.gmk build)

  # Runs the tests for the failure handler jtreg extension
  test-failure-handler:
	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
	    -f BuildFailureHandler.gmk test)

  # Copies the failure handler jtreg extension into the test image
  test-image-failure-handler:
	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
	     -f BuildFailureHandler.gmk images)
endif

ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \
    test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
    test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \
    test-failure-handler test-image-failure-handler test-image-hotspot-gtest

################################################################################
# Run tests

# Run tests specified by $(TEST), or the default test set.
test:
	$(call RunTests, $(TEST), $(JDK_IMAGE_DIR))

test-hotspot-jtreg:
	$(call RunTests, "hotspot_all", $(JDK_IMAGE_DIR))

test-hotspot-jtreg-native:
	$(call RunTests, "hotspot_native_sanity", $(JDK_IMAGE_DIR))

test-hotspot-internal:
	$(call RunTests, "hotspot_internal", $(JDK_OUTPUTDIR))

test-hotspot-gtest:
	$(call RunTests, "hotspot_gtest", $(JDK_OUTPUTDIR))

test-jdk-jtreg-native:
	$(call RunTests, "jdk_native_sanity", $(JDK_IMAGE_DIR))

test-make:
	($(CD) $(SRC_ROOT)/test/make && $(MAKE) $(MAKE_ARGS) -f TestMake.gmk $(TEST_TARGET))

ALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \
    test-hotspot-internal test-hotspot-gtest test-jdk-jtreg-native test-make

################################################################################
# Bundles

product-bundles:
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles)

test-bundles:
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles)

docs-bundles:
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles)

ALL_TARGETS += product-bundles test-bundles docs-bundles

################################################################################
# Install targets

install:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Install.gmk)

ALL_TARGETS += install

################################################################################
#
# Dependency declarations between targets.
#
# These are declared in two groups. First all dependencies between targets that
# have recipes above as these dependencies may be disabled. Then the aggregator
# targets that do not have recipes of their own, which will never have their
# dependencies disabled.
#
################################################################################
# Targets with recipes above

# If running an *-only target, parallel execution and dependencies between
# recipe targets are disabled. This makes it possible to run a select set of
# recipe targets in order. It's the responsibility of the user to make sure
# all prerequisites are fulfilled.
ifneq ($(findstring -only, $(MAKECMDGOALS)), )
  .NOTPARALLEL:
else
  $(LANGTOOLS_GENSRC_TARGETS): buildtools-langtools

  interim-langtools: $(LANGTOOLS_GENSRC_TARGETS)

  buildtools-jdk: interim-langtools interim-cldrconverter

  buildtools-modules: exploded-image-base

  $(CORBA_GENSRC_TARGETS): interim-langtools

  $(HOTSPOT_GENSRC_TARGETS): interim-langtools

  $(JDK_GENSRC_TARGETS): interim-langtools buildtools-jdk

  $(GENSRC_MODULEINFO_TARGETS): buildtools-jdk

  $(GENDATA_TARGETS): interim-langtools buildtools-jdk

  interim-rmic: interim-langtools

  $(RMIC_TARGETS): interim-langtools interim-rmic

  $(JAVA_TARGETS): interim-langtools

  hotspot-ide-project: hotspot exploded-image

  generate-exported-symbols: java.base-libs jdk.jdwp.agent-libs

  $(LIBS_TARGETS): hotspot

  $(LAUNCHER_TARGETS): java.base-libs

  ifeq ($(STATIC_BUILD), true)
    $(LAUNCHER_TARGETS): generate-exported-symbols
  endif

  # The demos are currently linking to libjvm and libjava, just like all other
  # jdk libs, even though they don't need to. To avoid warnings, make sure they
  # aren't built until after libjava and libjvm are available to link to.
  demos-jdk: java.base-libs exploded-image-optimize

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

  # Declare dependencies between java modules
  $(foreach m, $(JAVA_MODULES), \
      $(eval $m-java: $(addsuffix -java, $(filter $(JAVA_MODULES), \
      $(call FindDepsForModule,$m)))))

  # Declare dependencies between <module>-rmic to <module>-java
  $(foreach m, $(RMIC_MODULES), $(eval $m-rmic: $m-java))

  # Declare dependencies from <module>-lib to <module>-java
  # Skip modules that do not have java source.
  # When creating a BUILDJDK, the java compilation has already been done by the
  # normal build and copied in.
  ifneq ($(CREATING_BUILDJDK), true)
    $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs: $m-java))
  endif

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

  # jdk.accessibility depends on java.desktop
  jdk.accessibility-libs: java.desktop-libs

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

  # The swing beans need to have java base properly generated to avoid errors
  # in javadoc.
  java.desktop-gensrc-jdk: java.base-gensrc

  # The annotation processing for jdk.vm.ci needs java.base classes from the
  # current JDK.
  jdk.vm.ci-gensrc-hotspot: java.base-java

  # Explicitly add dependencies for special targets
  java.base-java: unpack-sec

  jdk.jdeps-gendata: java rmic

  # Declare dependencies between jmod targets.
  # java.base jmod needs jrt-fs.jar and access to the other jmods to be built.
  # When creating a BUILDJDK, we don't need to add hashes to java.base, thus
  # we don't need to depend on all other jmods
  ifneq ($(CREATING_BUILDJDK), true)
    java.base-jmod: jrtfs-jar $(filter-out java.base-jmod \
        $(addsuffix -jmod, $(call FindAllUpgradeableModules)), $(JMOD_TARGETS))
  endif

  # Declare dependencies from <module>-jmod to all other module targets
  # When creating a BUILDJDK, the java compilation has already been done by the
  # normal build and copied in.
  ifneq ($(CREATING_BUILDJDK), true)
    $(foreach m, $(JAVA_MODULES), $(eval $m_JMOD_DEPS += $m-java))
  endif
  $(foreach m, $(GENDATA_MODULES), $(eval $m_JMOD_DEPS += $m-gendata))
  $(foreach m, $(RMIC_MODULES), $(eval $m_JMOD_DEPS += $m-rmic))
  $(foreach m, $(LIBS_MODULES), $(eval $m_JMOD_DEPS += $m-libs))
  $(foreach m, $(LAUNCHER_MODULES), $(eval $m_JMOD_DEPS += $m-launchers))
  $(foreach m, $(COPY_MODULES), $(eval $m_JMOD_DEPS += $m-copy))
  $(foreach m, $(ALL_MODULES), $(eval $m-jmod: $($(m)_JMOD_DEPS)))
  $(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $m-interim-jmod: $($(m)_JMOD_DEPS)))

  # Jmods cannot be created until we have the jmod tool ready to run. During
  # a normal build we run it from the exploded image, but when cross compiling
  # it's run from the buildjdk, which is either created at build time or user
  # supplied.
  #
  # For the exploded image to be runnable, all java modules and
  # jdk.jlink-launchers need to be built. We also need to copy jvm.cfg (done
  # in java.base-copy) and tzdb.dat (done in java.base-gendata) to the
  # appropriate location otherwise jimage, jlink and jmod won't start. This
  # also applies when creating the buildjdk.
  DEFAULT_JMOD_DEPS := java.base-libs java.base-copy java.base-gendata \
      jdk.jlink-launchers
  # When cross compiling and buildjdk is to be created, depend on creating the
  # buildjdk instead of the default dependencies.
  ifeq ($(CREATE_BUILDJDK), true)
    # Avoid calling create-buildjdk from within a create-buildjdk call.
    ifneq ($(CREATING_BUILDJDK), true)
      $(JMOD_TARGETS): create-buildjdk
      buildtools-modules: create-buildjdk
    else
      # While actually creating the buildjdk, the default deps applies.
      $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
    endif
  else
    # The normal non cross compilation case uses the default deps.
    # To avoid races with the optimize target, that also needs to happen first.
    $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) \
        exploded-image-optimize
  endif

  zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
      $(filter jdk.crypto%, $(JAVA_TARGETS))

  zip-source: gensrc rmic

  jrtfs-jar: interim-langtools

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

    # The generated classlist needs to go into java.base-jmod.
    java.base-jmod jdk-image jre-image: generate-link-opt-data
  endif

  release-file: create-source-revision-tracker

  jdk-image: jmods zip-source demos samples release-file
  jre-image: jmods release-file

  profiles: jmods release-file

  mac-bundles-jdk: jdk-image jre-image

  # The optimize target can run as soon as the modules dir has been completely
  # populated (java, copy and gendata targets) and the basic libs and launchers
  # have been built.
  exploded-image-optimize: java copy gendata java.base-libs java.base-launchers \
      buildtools-modules

  bootcycle-images: jdk-image

  docs-javadoc: $(GENSRC_TARGETS) rmic

  # The gensrc step for jdk.jdi creates an html file that is used by docs-copy.
  docs-copy: hotspot jdk.jdi-gensrc

  docs-zip: docs-javadoc docs-copy

  test: jdk-image test-image

  create-buildjdk-copy: jdk.jlink-java java.base-gendata \
      $(addsuffix -java, $(INTERIM_IMAGE_MODULES))

  create-buildjdk-interim-image: create-buildjdk-copy

  interim-image: $(INTERIM_JMOD_TARGETS)

  test-make: clean-test-make

  build-test-lib: exploded-image-optimize

  build-test-failure-handler: interim-langtools

  test-failure-handler: build-test-failure-handler

  test-image-failure-handler: build-test-failure-handler

  build-test-hotspot-jtreg-native: buildtools-jdk hotspot

  build-test-jdk-jtreg-native: buildtools-jdk

  test-image-hotspot-jtreg-native: build-test-hotspot-jtreg-native

  test-image-jdk-jtreg-native: build-test-jdk-jtreg-native

  test-image-hotspot-gtest: hotspot

  test-hotspot-internal: exploded-image

  test-hotspot-jtreg: jdk-image test-image

  test-hotspot-gtest: exploded-image test-image-hotspot-gtest

  install: product-images

  product-bundles: product-images

  test-bundles: test-image

  docs-bundles: docs-image

  generate-summary: jmods buildtools-modules

endif

################################################################################
# Virtual targets without recipes

buildtools: buildtools-langtools interim-langtools interim-rmic \
    buildtools-jdk

gensrc: $(GENSRC_TARGETS)

gendata: $(GENDATA_TARGETS)

copy: $(ALL_COPY_TARGETS)

java: $(JAVA_TARGETS)

rmic: $(RMIC_TARGETS)

libs: $(LIBS_TARGETS)

launchers: $(LAUNCHER_TARGETS)

jmods: $(JMOD_TARGETS)

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

# Declare dependencies from <module> to all the individual targets specific
# to that module <module>-*, that are needed for the exploded image.
$(foreach m, $(GENSRC_MODULES), $(eval $m: $m-gensrc))
$(foreach m, $(JAVA_MODULES), $(eval $m: $m-java))
$(foreach m, $(GENDATA_MODULES), $(eval $m: $m-gendata))
$(foreach m, $(RMIC_MODULES), $(eval $m: $m-rmic))
$(foreach m, $(LIBS_MODULES), $(eval $m: $m-libs))
$(foreach m, $(LAUNCHER_MODULES), $(eval $m: $m-launchers))
$(foreach m, $(ALL_COPY_MODULES), $(eval $m: $m-copy))
demos: demos-jdk

samples: samples-jdk

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

create-buildjdk: create-buildjdk-copy create-buildjdk-interim-image

mac-bundles: mac-bundles-jdk

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

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

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

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

ifeq ($(OPENJDK_TARGET_OS), macosx)
  product-images: mac-bundles
endif

# This target builds the documentation image
docs-image: docs-javadoc docs-copy

# This target builds the test image
test-image: prepare-test-image test-image-hotspot-jtreg-native \
    test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest

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

# all-bundles packages all our deliverables as tar.gz bundles.
all-bundles: product-bundles test-bundles docs-bundles

ALL_TARGETS += buildtools gensrc gendata copy java rmic libs launchers jmods \
    jdk.jdwp.agent-gensrc $(ALL_MODULES) demos samples \
    exploded-image-base exploded-image \
    create-buildjdk mac-bundles product-images docs-image test-image all-images \
    all-bundles

################################################################################

# Traditional targets typically run by users.
# These can be considered aliases for the targets now named by a more
# "modern" naming scheme.
default: $(DEFAULT_MAKE_TARGET)
jdk: exploded-image
images: product-images
docs: docs-image
bundles: all-bundles
all: all-images

ALL_TARGETS += default jdk images docs bundles all

################################################################################
################################################################################
#
# Clean targets
#
################################################################################
# Clean targets are automatically run serially by the Makefile calling this
# file.

CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
    images make-support test-make bundles buildjdk
CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
CLEAN_SUPPORT_DIRS += demos
CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
CLEAN_PHASES := gensrc java native include
CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
# Construct targets of the form clean-$module-$phase
CLEAN_MODULE_PHASE_TARGETS := $(addprefix clean-, $(foreach m, $(ALL_MODULES), \
    $(addprefix $m-, $(CLEAN_PHASES))))

# Remove everything, except the output from configure.
clean: $(CLEAN_DIR_TARGETS)
	($(CD) $(OUTPUT_ROOT) && $(RM) -r build*.log*)
	$(ECHO) Cleaned all build artifacts.

clean-docs:
	$(call CleanDocs)

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

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

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

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

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

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

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

# Remove everything, including configure configuration. If the output
# directory was created by configure and now becomes empty, remove it as well.
dist-clean: clean
	($(CD) $(OUTPUT_ROOT) && \
	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide)
	$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
	  if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
	    $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
	  else \
	    ($(CD) $(SRC_ROOT) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" \
	        && $(RM) -r $(OUTPUT_ROOT)) \
	  fi \
	)
	$(ECHO) Cleaned everything, you will have to re-run configure.

ALL_TARGETS += clean clean-docs dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_SUPPORT_DIR_TARGETS) \
    $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) $(CLEAN_MODULE_TARGETS) \
    $(CLEAN_MODULE_PHASE_TARGETS)

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

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

################################################################################

# Include JPRT targets
include $(SRC_ROOT)/make/Jprt.gmk

################################################################################

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

print-targets:
	  @$(ECHO) $(sort $(ALL_TARGETS))

print-modules:
	  @$(ECHO) $(sort $(ALL_MODULES))

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

################################################################################

.PHONY: $(ALL_TARGETS)

FRC: # Force target