1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
|
#
# Copyright (c) 2012, 2023, 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 bootstrapping part of the build. This file is included from the
# top level Makefile, and is responsible for launching the Main.gmk file with
# the proper make and the proper make arguments.
################################################################################
# This must be the first rule
default:
.PHONY: default
# Inclusion of this pseudo-target will cause make to execute this file
# serially, regardless of -j.
.NOTPARALLEL:
ifeq ($(HAS_SPEC),)
##############################################################################
# This is the default mode. We have not been recursively called with a SPEC.
##############################################################################
# Include our helper functions.
include $(topdir)/make/InitSupport.gmk
# Here are "global" targets, i.e. targets that can be executed without having
# a configuration. This will define ALL_GLOBAL_TARGETS.
include $(topdir)/make/Global.gmk
# Targets provided by Init.gmk.
ALL_INIT_TARGETS := print-modules print-targets print-configuration \
print-tests reconfigure pre-compare-build post-compare-build
# CALLED_TARGETS is the list of targets that the user provided,
# or "default" if unspecified.
CALLED_TARGETS := $(if $(MAKECMDGOALS), $(MAKECMDGOALS), default)
# Extract non-global targets that require a spec file.
CALLED_SPEC_TARGETS := $(filter-out $(ALL_GLOBAL_TARGETS), $(CALLED_TARGETS))
# If we have only global targets, or if we are called with -qp (assuming an
# external part, e.g. bash completion, is trying to understand our targets),
# we will skip SPEC location and the sanity checks.
ifeq ($(CALLED_SPEC_TARGETS), )
ONLY_GLOBAL_TARGETS := true
endif
ifeq ($(findstring p, $(MAKEFLAGS))$(findstring q, $(MAKEFLAGS)), pq)
ONLY_GLOBAL_TARGETS := true
endif
ifeq ($(ONLY_GLOBAL_TARGETS), true)
############################################################################
# We have only global targets, or are called with -pq.
############################################################################
ifeq ($(wildcard $(SPEC)), )
# If we have no SPEC provided, we will just make a "best effort" target list.
# First try to grab any available pre-existing main-targets.gmk.
main_targets_file := $(firstword $(wildcard $(build_dir)/*/make-support/main-targets.gmk))
ifneq ($(main_targets_file), )
# Extract the SPEC that corresponds to this main-targets.gmk file.
SPEC := $(patsubst %/make-support/main-targets.gmk, %/spec.gmk, $(main_targets_file))
else
# None found, pick an arbitrary SPEC for which to generate a file
SPEC := $(firstword $(all_spec_files))
endif
endif
ifneq ($(wildcard $(SPEC)), )
$(eval $(call DefineMainTargets, LAZY, $(SPEC)))
else
# If we have no configurations we can not provide any main targets.
ALL_MAIN_TARGETS :=
endif
ALL_TARGETS := $(sort $(ALL_GLOBAL_TARGETS) $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS))
# Just list all our targets.
$(ALL_TARGETS):
.PHONY: $(ALL_TARGETS)
else
############################################################################
# This is the normal case, we have been called from the command line by the
# user and we need to call ourself back with a proper SPEC.
# We have at least one non-global target, so we need to find a spec file.
############################################################################
# Basic checks on environment and command line.
$(eval $(call CheckControlVariables))
$(eval $(call CheckDeprecatedEnvironment))
$(eval $(call CheckInvalidMakeFlags))
# Check that CONF_CHECK is valid.
$(eval $(call ParseConfCheckOption))
# Check that the LOG given is valid, and set LOG_LEVEL, LOG_NOFILE, MAKE_LOG_VARS and MAKE_LOG_FLAGS.
$(eval $(call ParseLogLevel))
# After this SPECS contain 1..N spec files (otherwise ParseConfAndSpec fails).
$(eval $(call ParseConfAndSpec))
# Extract main targets from Main.gmk using the spec(s) provided. In theory,
# with multiple specs, we should find the intersection of targets provided
# by all specs, but we approximate this by an arbitrary spec from the list.
# This will setup ALL_MAIN_TARGETS.
$(eval $(call DefineMainTargets, FORCE, $(firstword $(SPECS))))
# Separate called targets depending on type.
INIT_TARGETS := $(filter $(ALL_INIT_TARGETS), $(CALLED_SPEC_TARGETS))
MAIN_TARGETS := $(filter $(ALL_MAIN_TARGETS), $(CALLED_SPEC_TARGETS))
SEQUENTIAL_TARGETS := $(filter dist-clean clean%, $(MAIN_TARGETS))
PARALLEL_TARGETS := $(filter-out $(SEQUENTIAL_TARGETS), $(MAIN_TARGETS))
# The spec files depend on the autoconf source code. This check makes sure
# the configuration is up to date after changes to configure.
$(SPECS): $(wildcard $(topdir)/make/autoconf/*) \
$(if $(CUSTOM_CONFIG_DIR), $(wildcard $(CUSTOM_CONFIG_DIR)/*)) \
$(addprefix $(topdir)/make/conf/, version-numbers.conf branding.conf) \
$(if $(CUSTOM_CONF_DIR), $(wildcard $(addprefix $(CUSTOM_CONF_DIR)/, \
version-numbers.conf branding.conf)))
ifeq ($(CONF_CHECK), fail)
@echo Error: The configuration is not up to date for \
"'$(lastword $(subst /, , $(dir $@)))'."
$(call PrintConfCheckFailed)
@exit 2
else ifeq ($(CONF_CHECK), auto)
@echo Note: The configuration is not up to date for \
"'$(lastword $(subst /, , $(dir $@)))'."
@( cd $(topdir) && \
$(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -f $(topdir)/make/Init.gmk \
SPEC=$@ HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \
reconfigure )
else ifeq ($(CONF_CHECK), ignore)
# Do nothing
endif
# Do not let make delete spec files even if aborted while doing a reconfigure
.PRECIOUS: $(SPECS)
# Unless reconfigure is explicitly called, let all main targets depend on
# the spec files to be up to date.
ifeq ($(findstring reconfigure, $(INIT_TARGETS)), )
$(MAIN_TARGETS): $(SPECS)
endif
make-info:
ifneq ($(findstring $(LOG_LEVEL),info debug trace),)
$(info Running make as '$(strip $(MAKE) $(MFLAGS) \
$(COMMAND_LINE_VARIABLES) $(MAKECMDGOALS))')
endif
MAKE_INIT_WITH_SPEC_ARGUMENTS := ACTUAL_TOPDIR=$(topdir) \
USER_MAKE_VARS="$(USER_MAKE_VARS)" MAKE_LOG_FLAGS=$(MAKE_LOG_FLAGS) \
$(MAKE_LOG_VARS) \
INIT_TARGETS="$(INIT_TARGETS)" \
SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \
PARALLEL_TARGETS="$(PARALLEL_TARGETS)"
# Now the init and main targets will be called, once for each SPEC. The
# recipe will be run once for every target specified, but we only want to
# execute the recipe a single time, hence the TARGET_DONE with a dummy
# command if true.
# The COMPARE_BUILD part implements special support for makefile development.
$(ALL_INIT_TARGETS) $(ALL_MAIN_TARGETS): make-info
@$(if $(TARGET_DONE), \
true \
, \
( cd $(topdir) && \
$(foreach spec, $(SPECS), \
$(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -j 1 -f $(topdir)/make/Init.gmk \
SPEC=$(spec) HAS_SPEC=true $(MAKE_INIT_WITH_SPEC_ARGUMENTS) \
main && \
$(if $(and $(COMPARE_BUILD), $(PARALLEL_TARGETS)), \
$(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -f $(topdir)/make/Init.gmk \
SPEC=$(spec) HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \
COMPARE_BUILD="$(COMPARE_BUILD)" pre-compare-build && \
$(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -j 1 -f $(topdir)/make/Init.gmk \
SPEC=$(spec) HAS_SPEC=true $(MAKE_INIT_WITH_SPEC_ARGUMENTS) \
COMPARE_BUILD="$(COMPARE_BUILD):NODRYRUN=true" main && \
$(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -f $(topdir)/make/Init.gmk \
SPEC=$(spec) HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \
COMPARE_BUILD="$(COMPARE_BUILD):NODRYRUN=true" post-compare-build && \
) \
) true ) \
$(eval TARGET_DONE=true) \
)
.PHONY: $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS)
endif # $(ONLY_GLOBAL_TARGETS)!=true
else # HAS_SPEC=true
##############################################################################
# Now we have a spec. This part provides the "main" target that acts as a
# trampoline to call the Main.gmk with the value of $(MAKE) found in the spec
# file.
##############################################################################
include $(SPEC)
# Our helper functions.
include $(TOPDIR)/make/InitSupport.gmk
# Parse COMPARE_BUILD (for makefile development)
$(eval $(call ParseCompareBuild))
# Setup reproducible build environment
$(eval $(call SetupReproducibleBuild))
# If no LOG= was given on command line, but we have a non-standard default
# value, use that instead and re-parse log level.
ifeq ($(LOG), )
ifneq ($(DEFAULT_LOG), )
override LOG := $(DEFAULT_LOG)
$(eval $(call ParseLogLevel))
endif
endif
ifeq ($(LOG_NOFILE), true)
# Disable build log if LOG=[level,]nofile was given
override BUILD_LOG_PIPE :=
override BUILD_LOG_PIPE_SIMPLE :=
endif
ifeq ($(filter dist-clean, $(SEQUENTIAL_TARGETS)), dist-clean)
# We can't have a log file if we're about to remove it.
override BUILD_LOG_PIPE :=
override BUILD_LOG_PIPE_SIMPLE :=
endif
ifeq ($(OUTPUT_SYNC_SUPPORTED), true)
OUTPUT_SYNC_FLAG := -O$(OUTPUT_SYNC)
endif
##############################################################################
# Init targets
##############################################################################
print-modules:
( cd $(TOPDIR) && \
$(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
NO_RECIPES=true print-modules )
print-targets:
( cd $(TOPDIR) && \
$(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
NO_RECIPES=true print-targets )
print-tests:
( cd $(TOPDIR) && \
$(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
NO_RECIPES=true print-tests )
print-configuration:
$(ECHO) $(CONFIGURE_COMMAND_LINE)
reconfigure:
ifneq ($(REAL_CONFIGURE_COMMAND_EXEC_FULL), )
$(ECHO) "Re-running configure using original command line '$(REAL_CONFIGURE_COMMAND_EXEC_SHORT) $(REAL_CONFIGURE_COMMAND_LINE)'"
$(eval RECONFIGURE_COMMAND := $(REAL_CONFIGURE_COMMAND_EXEC_FULL) $(REAL_CONFIGURE_COMMAND_LINE))
else ifneq ($(CONFIGURE_COMMAND_LINE), )
$(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'"
$(eval RECONFIGURE_COMMAND := $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE))
else
$(ECHO) "Re-running configure using default settings"
$(eval RECONFIGURE_COMMAND := $(BASH) $(TOPDIR)/configure)
endif
( cd $(CONFIGURE_START_DIR) && PATH="$(ORIGINAL_PATH)" AUTOCONF="$(AUTOCONF)" \
CUSTOM_ROOT="$(CUSTOM_ROOT)" \
CUSTOM_CONFIG_DIR="$(CUSTOM_CONFIG_DIR)" \
$(RECONFIGURE_COMMAND) )
##############################################################################
# The main target, for delegating into Main.gmk
##############################################################################
MAIN_TARGETS := $(SEQUENTIAL_TARGETS) $(PARALLEL_TARGETS) $(COMPARE_BUILD_MAKE)
# If building the default target, add what they are to the description.
DESCRIPTION_TARGETS := $(strip $(MAIN_TARGETS))
ifeq ($(DESCRIPTION_TARGETS), default)
DESCRIPTION_TARGETS += ($(DEFAULT_MAKE_TARGET))
endif
TARGET_DESCRIPTION := target$(if $(word 2, $(MAIN_TARGETS)),s) \
'$(strip $(DESCRIPTION_TARGETS))' in configuration '$(CONF_NAME)'
# MAKEOVERRIDES is automatically set and propagated by Make to sub-Make calls.
# We need to clear it of the init-specific variables. The user-specified
# variables are explicitly propagated using $(USER_MAKE_VARS).
main: MAKEOVERRIDES :=
main: $(INIT_TARGETS)
ifneq ($(SEQUENTIAL_TARGETS)$(PARALLEL_TARGETS), )
$(call RotateLogFiles)
$(PRINTF) "Building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE_SIMPLE)
ifneq ($(SEQUENTIAL_TARGETS), )
# Don't touch build output dir since we might be cleaning. That
# means no log pipe.
( cd $(TOPDIR) && \
$(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
$(SEQUENTIAL_TARGETS) )
endif
ifneq ($(PARALLEL_TARGETS), )
$(call PrepareFailureLogs)
$(call StartGlobalTimer)
$(call PrepareJavacServer)
# JOBS will only be empty for a bootcycle-images recursive call
# or if specified via a make argument directly. In those cases
# treat it as NOT using jobs at all.
( cd $(TOPDIR) && \
$(NICE) $(MAKE) $(MAKE_ARGS) $(OUTPUT_SYNC_FLAG) \
$(if $(JOBS), -j $(JOBS)) \
-f make/Main.gmk $(USER_MAKE_VARS) \
$(PARALLEL_TARGETS) $(COMPARE_BUILD_MAKE) $(BUILD_LOG_PIPE) || \
( exitcode=$$? && \
$(PRINTF) "\nERROR: Build failed for $(TARGET_DESCRIPTION) (exit code $$exitcode) \n" \
$(BUILD_LOG_PIPE_SIMPLE) && \
cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -j 1 -f make/Init.gmk \
HAS_SPEC=true on-failure ; \
exit $$exitcode ) )
$(call CleanupJavacServer)
$(call StopGlobalTimer)
$(call ReportBuildTimes)
endif
if test -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error ; then \
exit 1 ; \
fi
$(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE_SIMPLE)
$(call ReportProfileTimes)
endif
on-failure:
$(call CleanupJavacServer)
$(call StopGlobalTimer)
$(call ReportBuildTimes)
$(call PrintFailureReports)
$(call PrintBuildLogFailures)
$(call ReportProfileTimes)
$(PRINTF) "HELP: Run 'make doctor' to diagnose build problems.\n\n"
ifneq ($(COMPARE_BUILD), )
$(call CleanupCompareBuild)
endif
# Support targets for COMPARE_BUILD, used for makefile development
pre-compare-build:
$(call WaitForJavacServerFinish)
$(call PrepareCompareBuild)
post-compare-build:
$(call WaitForJavacServerFinish)
$(call CleanupCompareBuild)
$(call CompareBuildDoComparison)
.PHONY: print-targets print-modules reconfigure main on-failure
endif
|