make/Init.gmk
author ykantser
Tue, 14 Jul 2015 16:28:53 +0200
changeset 31788 04af91b7fadd
parent 30415 c5629d65265d
child 32344 0b288e0efcfa
permissions -rw-r--r--
8131325: Remove hprof agent tests in hotspot repo Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
fd16c54261b3 Initial load
duke
parents:
diff changeset
     1
#
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
     2
# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
0
fd16c54261b3 Initial load
duke
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fd16c54261b3 Initial load
duke
parents:
diff changeset
     4
#
fd16c54261b3 Initial load
duke
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
fd16c54261b3 Initial load
duke
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
5499
eb0b3e373167 6943119: Rebrand source copyright notices
ohair
parents: 4309
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
0
fd16c54261b3 Initial load
duke
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
5499
eb0b3e373167 6943119: Rebrand source copyright notices
ohair
parents: 4309
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
0
fd16c54261b3 Initial load
duke
parents:
diff changeset
    10
#
fd16c54261b3 Initial load
duke
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
fd16c54261b3 Initial load
duke
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fd16c54261b3 Initial load
duke
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fd16c54261b3 Initial load
duke
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
fd16c54261b3 Initial load
duke
parents:
diff changeset
    15
# accompanied this code).
fd16c54261b3 Initial load
duke
parents:
diff changeset
    16
#
fd16c54261b3 Initial load
duke
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
fd16c54261b3 Initial load
duke
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
fd16c54261b3 Initial load
duke
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fd16c54261b3 Initial load
duke
parents:
diff changeset
    20
#
5499
eb0b3e373167 6943119: Rebrand source copyright notices
ohair
parents: 4309
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
eb0b3e373167 6943119: Rebrand source copyright notices
ohair
parents: 4309
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
eb0b3e373167 6943119: Rebrand source copyright notices
ohair
parents: 4309
diff changeset
    23
# questions.
0
fd16c54261b3 Initial load
duke
parents:
diff changeset
    24
#
fd16c54261b3 Initial load
duke
parents:
diff changeset
    25
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    26
################################################################################
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    27
# This is the bootstrapping part of the build. This file is included from the
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    28
# top level Makefile, and is responsible for launching the Main.gmk file with
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    29
# the proper make and the proper make arguments.
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    30
################################################################################
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    31
21759
e24e22311718 8027566: Remove the old build system
ihse
parents: 19758
diff changeset
    32
# This must be the first rule
e24e22311718 8027566: Remove the old build system
ihse
parents: 19758
diff changeset
    33
default:
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    34
.PHONY: default
17
bb9f330cd95a 6649672: Adjustments to OUTPUTDIR default and mkdirs to avoid empty directory clutter
ohair
parents: 16
diff changeset
    35
21759
e24e22311718 8027566: Remove the old build system
ihse
parents: 19758
diff changeset
    36
# Inclusion of this pseudo-target will cause make to execute this file
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    37
# serially, regardless of -j.
21759
e24e22311718 8027566: Remove the old build system
ihse
parents: 19758
diff changeset
    38
.NOTPARALLEL:
9618
83db8167c9f6 7043700: Regression for IcedTea builds
ohair
parents: 9309
diff changeset
    39
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    40
ifeq ($(HAS_SPEC),)
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    41
  ##############################################################################
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    42
  # This is the default mode. We have not been recursively called with a SPEC.
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    43
  ##############################################################################
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    44
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    45
  # Include our helper functions.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    46
  include $(topdir)/make/InitSupport.gmk
8441
30f5ad688d4a 7021753: Add a build times report
ohrstrom
parents: 7876
diff changeset
    47
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    48
  # Here are "global" targets, i.e. targets that can be executed without having
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    49
  # a configuration. This will define ALL_GLOBAL_TARGETS.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    50
  include $(topdir)/make/Help.gmk
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    51
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    52
  # Targets provided by Init.gmk.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    53
  ALL_INIT_TARGETS := print-modules print-targets reconfigure
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 22031
diff changeset
    54
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    55
  # CALLED_TARGETS is the list of targets that the user provided,
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    56
  # or "default" if unspecified.
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
    57
  CALLED_TARGETS := $(if $(MAKECMDGOALS), $(MAKECMDGOALS), default)
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    58
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    59
  # Extract non-global targets that require a spec file.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    60
  CALLED_SPEC_TARGETS := $(filter-out $(ALL_GLOBAL_TARGETS), $(CALLED_TARGETS))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    61
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    62
  # If we have only global targets, or if we are called with -qp (assuming an
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    63
  # external part, e.g. bash completion, is trying to understand our targets),
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    64
  # we will skip SPEC location and the sanity checks.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    65
  ifeq ($(CALLED_SPEC_TARGETS), )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    66
    ONLY_GLOBAL_TARGETS := true
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    67
  endif
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    68
  ifneq ($(findstring qp, $(MAKEFLAGS)),)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    69
    ONLY_GLOBAL_TARGETS := true
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    70
  endif
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    71
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    72
  ifeq ($(ONLY_GLOBAL_TARGETS), true)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    73
    ############################################################################
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    74
    # We have only global targets, or are called with -pq.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    75
    ############################################################################
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    76
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    77
    ifeq ($(wildcard $(SPEC)), )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    78
      # If we have no SPEC provided, we will just make a "best effort" target list.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    79
      # First try to grab any available pre-existing main-targets.gmk.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    80
      main_targets_file := $(firstword $(wildcard $(build_dir)/*/make-support/main-targets.gmk))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    81
      ifneq ($(main_targets_file), )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    82
        # Extract the SPEC that corresponds to this main-targets.gmk file.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    83
        SPEC := $(patsubst %/make-support/main-targets.gmk, %/spec.gmk, $(main_targets_file))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    84
      else
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    85
        # None found, pick an arbitrary SPEC for which to generate a file
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    86
        SPEC := $(firstword $(all_spec_files))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    87
      endif
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    88
    endif
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    89
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    90
    ifneq ($(wildcard $(SPEC)), )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    91
      $(eval $(call DefineMainTargets, LAZY, $(SPEC)))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    92
    else
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    93
      # If we have no configurations we can not provide any main targets.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    94
      ALL_MAIN_TARGETS :=
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    95
    endif
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    96
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    97
    ALL_TARGETS := $(sort $(ALL_GLOBAL_TARGETS) $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    98
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
    99
    # Just list all our targets.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   100
    $(ALL_TARGETS):
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   101
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   102
    .PHONY: $(ALL_TARGETS)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   103
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   104
  else
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   105
    ############################################################################
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   106
    # This is the normal case, we have been called from the command line by the
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   107
    # user and we need to call ourself back with a proper SPEC.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   108
    # We have at least one non-global target, so we need to find a spec file.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   109
    ############################################################################
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   110
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   111
    # Basic checks on environment and command line.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   112
    $(eval $(call CheckControlVariables))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   113
    $(eval $(call CheckDeprecatedEnvironment))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   114
    $(eval $(call CheckInvalidMakeFlags))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   115
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   116
    # Check that CONF_CHECK is valid.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   117
    $(eval $(call ParseConfCheckOption))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   118
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   119
    # Check that the LOG given is valid, and set LOG_LEVEL, LOG_NOFILE and MAKE_LOG_FLAGS.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   120
    $(eval $(call ParseLogLevel))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   121
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   122
    # After this SPECS contain 1..N spec files (otherwise ParseConfAndSpec fails).
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   123
    $(eval $(call ParseConfAndSpec))
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 22031
diff changeset
   124
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   125
    # Extract main targets from Main.gmk using the spec(s) provided. In theory,
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   126
    # with multiple specs, we should find the intersection of targets provided
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   127
    # by all specs, but we approximate this by an arbitrary spec from the list.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   128
    # This will setup ALL_MAIN_TARGETS.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   129
    $(eval $(call DefineMainTargets, FORCE, $(firstword $(SPECS))))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   130
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   131
    # Separate called targets depending on type.
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   132
    INIT_TARGETS := $(filter $(ALL_INIT_TARGETS), $(CALLED_SPEC_TARGETS))
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   133
    MAIN_TARGETS := $(filter $(ALL_MAIN_TARGETS), $(CALLED_SPEC_TARGETS))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   134
    SEQUENTIAL_TARGETS := $(filter dist-clean clean%, $(MAIN_TARGETS))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   135
    PARALLEL_TARGETS := $(filter-out $(SEQUENTIAL_TARGETS), $(MAIN_TARGETS))
874
638ddad10e12 6728161: Add SKIP_BOOT_CYCLE feature to create boot jdk and use it during build
ohair
parents: 668
diff changeset
   136
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   137
    # The spec files depend on the autoconf source code. This check makes sure
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   138
    # the configuration is up to date after changes to configure.
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   139
    $(SPECS): $(wildcard $(topdir)/common/autoconf/*)
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   140
        ifeq ($(CONF_CHECK), fail)
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   141
	  @echo "Error: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'."
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   142
	  $(call PrintConfCheckFailed)
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   143
	  @exit 2
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   144
        else ifeq ($(CONF_CHECK), auto)
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   145
	  @echo "Note: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'."
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   146
	  @( cd $(topdir) && \
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   147
	      $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -f $(topdir)/make/Init.gmk \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   148
	      SPEC=$@ HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   149
	      reconfigure )
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   150
        else ifeq ($(CONF_CHECK), ignore)
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   151
          # Do nothing
26398
ca1f84f97e20 8057537: Serialize reconfigure and fix make clean-foo foo
erikj
parents: 26128
diff changeset
   152
        endif
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 22031
diff changeset
   153
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   154
    # Unless reconfigure is explicitely called, let all main targets depend on
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   155
    # the spec files to be up to date.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   156
    ifeq ($(findstring reconfigure, $(INIT_TARGETS)), )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   157
      $(MAIN_TARGETS): $(SPECS)
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   158
    endif
874
638ddad10e12 6728161: Add SKIP_BOOT_CYCLE feature to create boot jdk and use it during build
ohair
parents: 668
diff changeset
   159
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   160
    make-info:
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   161
        ifneq ($(findstring $(LOG_LEVEL),info debug trace),)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   162
	  $(info Running make as '$(strip $(MAKE) $(MFLAGS) \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   163
	      $(COMMAND_LINE_VARIABLES) $(MAKECMDGOALS))')
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   164
        endif
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   165
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   166
    # Now the init and main targets will be called, once for each SPEC. The
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   167
    # recipe will be run once for every target specified, but we only want to
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   168
    # execute the recipe a single time, hence the TARGET_DONE with a dummy
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   169
    # command if true.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   170
    $(ALL_INIT_TARGETS) $(ALL_MAIN_TARGETS): make-info
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   171
	@$(if $(TARGET_DONE), \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   172
	  true \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   173
	, \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   174
	  $(foreach spec, $(SPECS), \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   175
	    ( cd $(topdir) && \
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   176
	    $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -j 1 -f $(topdir)/make/Init.gmk \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   177
	        SPEC=$(spec) HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   178
	        USER_MAKE_VARS="$(USER_MAKE_VARS)" MAKE_LOG_FLAGS=$(MAKE_LOG_FLAGS) \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   179
	        LOG_LEVEL=$(LOG_LEVEL) LOG_NOFILE=$(LOG_NOFILE) \
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   180
	        INIT_TARGETS="$(INIT_TARGETS)" \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   181
	        SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   182
	        PARALLEL_TARGETS="$(PARALLEL_TARGETS)"  \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   183
	        main ) && \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   184
	  ) true \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   185
	  $(eval TARGET_DONE=true) \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   186
	)
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   187
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   188
    .PHONY: $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS)
0
fd16c54261b3 Initial load
duke
parents:
diff changeset
   189
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   190
  endif # $(ONLY_GLOBAL_TARGETS)!=true
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   191
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   192
else # HAS_SPEC=true
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   193
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   194
  ##############################################################################
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   195
  # Now we have a spec. This part provides the "main" target that acts as a
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   196
  # trampoline to call the Main.gmk with the value of $(MAKE) found in the spec
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   197
  # file.
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   198
  ##############################################################################
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   199
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   200
  include $(SPEC)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   201
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   202
  # Our helper functions.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   203
  include $(TOPDIR)/make/InitSupport.gmk
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   204
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   205
  # Verify that the spec file we included seems okay.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   206
  $(eval $(call CheckSpecSanity))
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   207
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   208
  ifeq ($(LOG_NOFILE), true)
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   209
    # Disable log wrapper if LOG=[level,]nofile was given
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   210
    override BUILD_LOG_WRAPPER :=
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   211
  endif
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   212
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   213
  ifeq ($(OUTPUT_SYNC_SUPPORTED), true)
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   214
    OUTPUT_SYNC_FLAG := -O$(OUTPUT_SYNC)
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   215
  endif
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   216
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   217
  ##############################################################################
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   218
  # Init targets
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   219
  ##############################################################################
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   220
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   221
  print-modules:
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   222
	( cd $(TOPDIR) && \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   223
	    $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   224
	    NO_RECIPES=true print-modules )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   225
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   226
  print-targets:
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   227
	( cd $(TOPDIR) && \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   228
	    $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   229
	    NO_RECIPES=true print-targets )
28902
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28286
diff changeset
   230
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   231
  reconfigure:
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   232
        ifneq ($(CONFIGURE_COMMAND_LINE), )
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   233
	  $(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'"
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   234
        else
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   235
	  $(ECHO) "Re-running configure using default settings"
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   236
        endif
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   237
	( cd $(OUTPUT_ROOT) && PATH="$(ORIGINAL_PATH)" \
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   238
	    $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) )
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   239
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   240
  ##############################################################################
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   241
  # The main target, for delegating into Main.gmk
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   242
  ##############################################################################
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   243
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   244
  MAIN_TARGETS := $(SEQUENTIAL_TARGETS) $(PARALLEL_TARGETS)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   245
  TARGET_DESCRIPTION := target$(if $(word 2, $(MAIN_TARGETS)),s) \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   246
      '$(strip $(MAIN_TARGETS))' in configuration '$(CONF_NAME)'
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   247
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   248
  # MAKEOVERRIDES is automatically set and propagated by Make to sub-Make calls.
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   249
  # We need to clear it of the init-specific variables. The user-specified
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   250
  # variables are explicitely propagated using $(USER_MAKE_VARS).
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   251
  main: MAKEOVERRIDES :=
0
fd16c54261b3 Initial load
duke
parents:
diff changeset
   252
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   253
  main: $(INIT_TARGETS)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   254
        ifneq ($(SEQUENTIAL_TARGETS)$(PARALLEL_TARGETS), )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   255
	  $(call RotateLogFiles)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   256
	  $(BUILD_LOG_WRAPPER) $(PRINTF) "Building $(TARGET_DESCRIPTION)\n"
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   257
          ifneq ($(SEQUENTIAL_TARGETS), )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   258
            # Don't touch build output dir since we might be cleaning. That
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   259
            # means no log wrapper.
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   260
	    ( cd $(TOPDIR) && \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   261
	        $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   262
	        $(SEQUENTIAL_TARGETS) )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   263
          endif
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   264
          ifneq ($(PARALLEL_TARGETS), )
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   265
	    $(call StartGlobalTimer)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   266
	    $(call PrepareSmartJavac)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   267
	    ( cd $(TOPDIR) && \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   268
	        $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(OUTPUT_SYNC_FLAG) \
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   269
	        -j $(JOBS) -f make/Main.gmk $(USER_MAKE_VARS) \
30415
c5629d65265d 8074859: Turn on warnings as error
ihse
parents: 29788
diff changeset
   270
	        $(PARALLEL_TARGETS) || \
c5629d65265d 8074859: Turn on warnings as error
ihse
parents: 29788
diff changeset
   271
	        ( exitcode=$$? && $(BUILD_LOG_WRAPPER) $(PRINTF) "\nERROR: Build failed for $(TARGET_DESCRIPTION) (exit code $$exitcode) \n" && \
c5629d65265d 8074859: Turn on warnings as error
ihse
parents: 29788
diff changeset
   272
	        $(PRINTF) "Hint: If caused by a warning, try configure --disable-warnings-as-errors \n\n" && exit $$exitcode ) )
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   273
	    $(call CleanupSmartJavac)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   274
	    $(call StopGlobalTimer)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   275
	    $(call ReportBuildTimes)
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   276
          endif
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   277
	  $(BUILD_LOG_WRAPPER) $(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n"
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   278
        endif
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   279
29788
b581a3d9db41 8076465: New Init.gmk needs improvements
ihse
parents: 29663
diff changeset
   280
  .PHONY: print-targets print-modules reconfigure main
29662
78c47f0002c3 8076060: Improve make bootstrap process
ihse
parents: 28902
diff changeset
   281
endif