2015-03-26 15:17:30 +00:00
|
|
|
#
|
2024-02-23 17:31:13 +00:00
|
|
|
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
2015-03-26 15:17:30 +00:00
|
|
|
# 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 file contains helper functions for Init.gmk.
|
|
|
|
# It is divided in two parts, depending on if a SPEC is present or not
|
|
|
|
# (HAS_SPEC is true or not).
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
ifndef _INITSUPPORT_GMK
|
|
|
|
_INITSUPPORT_GMK := 1
|
|
|
|
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($(HAS_SPEC), )
|
2017-03-03 11:57:57 +00:00
|
|
|
|
2018-06-11 18:18:38 +00:00
|
|
|
# COMMA is defined in spec.gmk, but that is not included yet
|
|
|
|
COMMA := ,
|
|
|
|
|
2017-03-03 11:57:57 +00:00
|
|
|
# Include the corresponding closed file, if present.
|
2017-10-05 09:02:18 +00:00
|
|
|
ifneq ($(CUSTOM_MAKE_DIR), )
|
|
|
|
-include $(CUSTOM_MAKE_DIR)/InitSupport.gmk
|
|
|
|
endif
|
2017-03-03 11:57:57 +00:00
|
|
|
|
2015-03-26 15:17:30 +00:00
|
|
|
##############################################################################
|
|
|
|
# Helper functions for the initial part of Init.gmk, before the spec file is
|
|
|
|
# loaded. Most of these functions provide parsing and setting up make options
|
|
|
|
# from the command-line.
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
# Make control variables, handled by Init.gmk
|
2017-03-03 11:57:57 +00:00
|
|
|
INIT_CONTROL_VARIABLES += LOG CONF CONF_NAME SPEC JOBS TEST_JOBS CONF_CHECK \
|
2018-11-16 22:39:51 +00:00
|
|
|
COMPARE_BUILD JTREG GTEST MICRO TEST_OPTS TEST_VM_OPTS
|
2015-03-26 15:17:30 +00:00
|
|
|
|
|
|
|
# All known make control variables
|
2019-06-20 20:03:10 +00:00
|
|
|
MAKE_CONTROL_VARIABLES := $(INIT_CONTROL_VARIABLES) TEST JDK_FILTER SPEC_FILTER
|
2015-03-26 15:17:30 +00:00
|
|
|
|
|
|
|
# Define a simple reverse function.
|
|
|
|
# Should maybe move to MakeBase.gmk, but we can't include that file now.
|
|
|
|
reverse = \
|
|
|
|
$(if $(strip $(1)), $(call reverse, $(wordlist 2, $(words $(1)), $(1)))) \
|
|
|
|
$(firstword $(1))
|
|
|
|
|
|
|
|
# The variable MAKEOVERRIDES contains variable assignments from the command
|
|
|
|
# line, but in reverse order to what the user entered.
|
2024-07-11 08:18:46 +00:00
|
|
|
# The '§' <=> '\ 'dance is needed to keep values with space in them connected.
|
|
|
|
COMMAND_LINE_VARIABLES := $(subst §,\ , $(call reverse, $(subst \ ,§,$(MAKEOVERRIDES))))
|
2015-03-26 15:17:30 +00:00
|
|
|
|
2015-04-07 07:06:24 +00:00
|
|
|
# A list like FOO="val1" BAR="val2" containing all user-supplied make
|
|
|
|
# variables that we should propagate.
|
2024-07-11 08:18:46 +00:00
|
|
|
# The '§' <=> '\ 'dance is needed to keep values with space in them connected.
|
|
|
|
USER_MAKE_VARS := $(subst §,\ , $(filter-out $(addsuffix =%, $(INIT_CONTROL_VARIABLES)), \
|
|
|
|
$(subst \ ,§,$(MAKEOVERRIDES))))
|
2015-03-26 15:17:30 +00:00
|
|
|
|
2015-04-07 07:06:24 +00:00
|
|
|
# Setup information about available configurations, if any.
|
2017-10-16 06:43:42 +00:00
|
|
|
ifneq ($(CUSTOM_ROOT), )
|
2024-09-03 15:31:09 +00:00
|
|
|
build_dir = $(CUSTOM_ROOT)/build
|
2017-09-12 17:03:56 +00:00
|
|
|
else
|
2024-09-03 15:31:09 +00:00
|
|
|
build_dir = $(topdir)/build
|
2017-09-12 17:03:56 +00:00
|
|
|
endif
|
2024-09-03 15:31:09 +00:00
|
|
|
all_spec_files = $(wildcard $(build_dir)/*/spec.gmk)
|
2015-04-07 07:06:24 +00:00
|
|
|
# Extract the configuration names from the path
|
2024-09-03 15:31:09 +00:00
|
|
|
all_confs = $(patsubst %/spec.gmk, %, $(patsubst $(build_dir)/%, %, $(all_spec_files)))
|
2015-04-07 07:06:24 +00:00
|
|
|
|
2015-03-26 15:17:30 +00:00
|
|
|
# Check for unknown command-line variables
|
|
|
|
define CheckControlVariables
|
|
|
|
command_line_variables := $$(strip $$(foreach var, \
|
|
|
|
$$(subst \ ,_,$$(MAKEOVERRIDES)), \
|
|
|
|
$$(firstword $$(subst =, , $$(var)))))
|
2015-04-07 07:06:24 +00:00
|
|
|
unknown_command_line_variables := $$(strip \
|
|
|
|
$$(filter-out $$(MAKE_CONTROL_VARIABLES), $$(command_line_variables)))
|
2015-03-26 15:17:30 +00:00
|
|
|
ifneq ($$(unknown_command_line_variables), )
|
|
|
|
$$(info Note: Command line contains non-control variables:)
|
|
|
|
$$(foreach var, $$(unknown_command_line_variables), $$(info * $$(var)=$$($$(var))))
|
|
|
|
$$(info Make sure it is not mistyped, and that you intend to override this variable.)
|
|
|
|
$$(info 'make help' will list known control variables.)
|
|
|
|
$$(info )
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Check for deprecated ALT_ variables
|
|
|
|
define CheckDeprecatedEnvironment
|
|
|
|
defined_alt_variables := $$(filter ALT_%, $$(.VARIABLES))
|
|
|
|
ifneq ($$(defined_alt_variables), )
|
|
|
|
$$(info Warning: You have the following ALT_ variables set:)
|
|
|
|
$$(foreach var, $$(defined_alt_variables), $$(info * $$(var)=$$($$(var))))
|
|
|
|
$$(info ALT_ variables are deprecated, and may result in a failed build.)
|
|
|
|
$$(info Please clean your environment.)
|
|
|
|
$$(info )
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Check for invalid make flags like -j
|
|
|
|
define CheckInvalidMakeFlags
|
|
|
|
# This is a trick to get this rule to execute before any other rules
|
|
|
|
# MAKEFLAGS only indicate -j if read in a recipe (!)
|
|
|
|
$$(topdir)/make/Init.gmk: .FORCE
|
|
|
|
$$(if $$(findstring --jobserver, $$(MAKEFLAGS)), \
|
|
|
|
$$(info Error: 'make -jN' is not supported, use 'make JOBS=N') \
|
|
|
|
$$(error Cannot continue) \
|
|
|
|
)
|
|
|
|
.FORCE:
|
|
|
|
.PHONY: .FORCE
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Check that the CONF_CHECK option is valid and set up handling
|
|
|
|
define ParseConfCheckOption
|
|
|
|
ifeq ($$(CONF_CHECK), )
|
|
|
|
# Default behavior is fail
|
|
|
|
CONF_CHECK := fail
|
2024-09-03 15:31:09 +00:00
|
|
|
else ifneq ($$(filter-out auto fail ignore, $$(CONF_CHECK)), )
|
2015-03-26 15:17:30 +00:00
|
|
|
$$(info Error: CONF_CHECK must be one of: auto, fail or ignore.)
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
|
|
|
define ParseConfAndSpec
|
|
|
|
ifneq ($$(origin SPEC), undefined)
|
|
|
|
# We have been given a SPEC, check that it works out properly
|
|
|
|
ifneq ($$(origin CONF), undefined)
|
|
|
|
# We also have a CONF argument. We can't have both.
|
|
|
|
$$(info Error: Cannot use CONF=$$(CONF) and SPEC=$$(SPEC) at the same time. Choose one.)
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
2015-12-09 10:44:40 +00:00
|
|
|
ifneq ($$(origin CONF_NAME), undefined)
|
|
|
|
# We also have a CONF_NAME argument. We can't have both.
|
|
|
|
$$(info Error: Cannot use CONF_NAME=$$(CONF_NAME) and SPEC=$$(SPEC) at the same time. Choose one.)
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(wildcard $$(SPEC)), )
|
2015-03-26 15:17:30 +00:00
|
|
|
$$(info Error: Cannot locate spec.gmk, given by SPEC=$$(SPEC).)
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(filter /%, $$(SPEC)), )
|
2015-03-26 15:17:30 +00:00
|
|
|
# If given with relative path, make it absolute
|
|
|
|
SPECS := $$(CURDIR)/$$(strip $$(SPEC))
|
|
|
|
else
|
|
|
|
SPECS := $$(SPEC)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For now, unset this SPEC variable.
|
|
|
|
override SPEC :=
|
|
|
|
else
|
|
|
|
# Use spec.gmk files in the build output directory
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(all_spec_files), )
|
2017-10-16 06:43:42 +00:00
|
|
|
ifneq ($(CUSTOM_ROOT), )
|
|
|
|
$$(info Error: No configurations found for $$(CUSTOM_ROOT).)
|
|
|
|
else
|
|
|
|
$$(info Error: No configurations found for $$(topdir).)
|
|
|
|
endif
|
2015-03-26 15:17:30 +00:00
|
|
|
$$(info Please run 'bash configure' to create a configuration.)
|
|
|
|
$$(info )
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
|
|
|
|
2015-12-09 10:44:40 +00:00
|
|
|
ifneq ($$(origin CONF_NAME), undefined)
|
|
|
|
ifneq ($$(origin CONF), undefined)
|
|
|
|
# We also have a CONF argument. We can't have both.
|
|
|
|
$$(info Error: Cannot use CONF=$$(CONF) and CONF_NAME=$$(CONF_NAME) at the same time. Choose one.)
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
|
|
|
matching_conf := $$(strip $$(filter $$(CONF_NAME), $$(all_confs)))
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(matching_conf), )
|
2015-12-09 10:44:40 +00:00
|
|
|
$$(info Error: No configurations found matching CONF_NAME=$$(CONF_NAME).)
|
|
|
|
$$(info Available configurations in $$(build_dir):)
|
|
|
|
$$(foreach var, $$(all_confs), $$(info * $$(var)))
|
|
|
|
$$(error Cannot continue)
|
|
|
|
else ifneq ($$(words $$(matching_conf)), 1)
|
|
|
|
$$(info Error: Matching more than one configuration CONF_NAME=$$(CONF_NAME).)
|
|
|
|
$$(info Available configurations in $$(build_dir):)
|
|
|
|
$$(foreach var, $$(all_confs), $$(info * $$(var)))
|
|
|
|
$$(error Cannot continue)
|
|
|
|
else
|
|
|
|
$$(info Building configuration '$$(matching_conf)' (matching CONF_NAME=$$(CONF_NAME)))
|
|
|
|
endif
|
|
|
|
# Create a SPEC definition. This will contain the path to exactly one spec file.
|
|
|
|
SPECS := $$(build_dir)/$$(matching_conf)/spec.gmk
|
|
|
|
else ifneq ($$(origin CONF), undefined)
|
2015-03-26 15:17:30 +00:00
|
|
|
# User have given a CONF= argument.
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(CONF), )
|
2015-03-26 15:17:30 +00:00
|
|
|
# If given CONF=, match all configurations
|
|
|
|
matching_confs := $$(strip $$(all_confs))
|
|
|
|
else
|
|
|
|
# Otherwise select those that contain the given CONF string
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(patsubst !%,,$$(CONF)), )
|
2024-02-13 09:51:33 +00:00
|
|
|
# A CONF starting with ! means we should negate the search term
|
|
|
|
matching_confs := $$(strip $$(foreach var, $$(all_confs), \
|
2024-08-30 08:58:18 +00:00
|
|
|
$$(if $$(findstring $$(subst !,,$$(CONF)), $$(var)), ,$$(var))))
|
2024-02-13 09:51:33 +00:00
|
|
|
else
|
|
|
|
matching_confs := $$(strip $$(foreach var, $$(all_confs), \
|
|
|
|
$$(if $$(findstring $$(CONF), $$(var)), $$(var))))
|
|
|
|
endif
|
2022-11-21 18:34:52 +00:00
|
|
|
ifneq ($$(filter $$(CONF), $$(matching_confs)), )
|
|
|
|
# If we found an exact match, use that
|
|
|
|
matching_confs := $$(CONF)
|
|
|
|
# Don't repeat this output on make restarts caused by including
|
|
|
|
# generated files.
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(MAKE_RESTARTS), )
|
2022-11-21 18:34:52 +00:00
|
|
|
$$(info Using exact match for CONF=$$(CONF) (other matches are possible))
|
|
|
|
endif
|
|
|
|
endif
|
2015-03-26 15:17:30 +00:00
|
|
|
endif
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(matching_confs), )
|
2015-03-26 15:17:30 +00:00
|
|
|
$$(info Error: No configurations found matching CONF=$$(CONF).)
|
|
|
|
$$(info Available configurations in $$(build_dir):)
|
|
|
|
$$(foreach var, $$(all_confs), $$(info * $$(var)))
|
|
|
|
$$(error Cannot continue)
|
|
|
|
else
|
2016-01-16 12:01:43 +00:00
|
|
|
# Don't repeat this output on make restarts caused by including
|
|
|
|
# generated files.
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(MAKE_RESTARTS), )
|
2016-01-16 12:01:43 +00:00
|
|
|
ifeq ($$(words $$(matching_confs)), 1)
|
2024-09-03 15:31:09 +00:00
|
|
|
ifneq ($$(findstring $$(LOG_LEVEL), info debug trace), )
|
2017-12-04 18:12:57 +00:00
|
|
|
$$(info Building configuration '$$(matching_confs)' (matching CONF=$$(CONF)))
|
|
|
|
endif
|
2016-01-16 12:01:43 +00:00
|
|
|
else
|
|
|
|
$$(info Building these configurations (matching CONF=$$(CONF)):)
|
|
|
|
$$(foreach var, $$(matching_confs), $$(info * $$(var)))
|
|
|
|
endif
|
2015-03-26 15:17:30 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Create a SPEC definition. This will contain the path to one or more spec.gmk files.
|
|
|
|
SPECS := $$(addsuffix /spec.gmk, $$(addprefix $$(build_dir)/, $$(matching_confs)))
|
|
|
|
else
|
|
|
|
# No CONF or SPEC given, check the available configurations
|
|
|
|
ifneq ($$(words $$(all_spec_files)), 1)
|
|
|
|
$$(info Error: No CONF given, but more than one configuration found.)
|
|
|
|
$$(info Available configurations in $$(build_dir):)
|
|
|
|
$$(foreach var, $$(all_confs), $$(info * $$(var)))
|
|
|
|
$$(info Please retry building with CONF=<config pattern> (or SPEC=<spec file>).)
|
|
|
|
$$(info )
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# We found exactly one configuration, use it
|
|
|
|
SPECS := $$(strip $$(all_spec_files))
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
2015-04-07 07:06:24 +00:00
|
|
|
# Extract main targets from Main.gmk using the spec provided in $2.
|
|
|
|
#
|
|
|
|
# Param 1: FORCE = force generation of main-targets.gmk or LAZY = do not force.
|
|
|
|
# Param 2: The SPEC file to use.
|
|
|
|
define DefineMainTargets
|
|
|
|
|
|
|
|
# We will start by making sure the main-targets.gmk file is removed, if
|
|
|
|
# make has not been restarted. By the -include, we will trigger the
|
|
|
|
# rule for generating the file (which is never there since we removed it),
|
|
|
|
# thus generating it fresh, and make will restart, incrementing the restart
|
|
|
|
# count.
|
|
|
|
main_targets_file := $$(dir $(strip $2))make-support/main-targets.gmk
|
|
|
|
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(MAKE_RESTARTS), )
|
2015-04-07 07:06:24 +00:00
|
|
|
# Only do this if make has not been restarted, and if we do not force it.
|
|
|
|
ifeq ($(strip $1), FORCE)
|
|
|
|
$$(shell rm -f $$(main_targets_file))
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
$$(main_targets_file):
|
|
|
|
@( cd $$(topdir) && \
|
2019-04-02 15:19:36 +00:00
|
|
|
$$(MAKE) $$(MAKE_LOG_FLAGS) -r -R -f $$(topdir)/make/Main.gmk \
|
2015-04-07 07:06:24 +00:00
|
|
|
-I $$(topdir)/make/common SPEC=$(strip $2) NO_RECIPES=true \
|
2017-03-30 19:23:07 +00:00
|
|
|
$$(MAKE_LOG_VARS) \
|
2015-04-07 07:06:24 +00:00
|
|
|
create-main-targets-include )
|
|
|
|
|
|
|
|
# Now include main-targets.gmk. This will define ALL_MAIN_TARGETS.
|
|
|
|
-include $$(main_targets_file)
|
|
|
|
endef
|
|
|
|
|
2015-03-26 15:17:30 +00:00
|
|
|
define PrintConfCheckFailed
|
|
|
|
@echo ' '
|
|
|
|
@echo "Please rerun configure! Easiest way to do this is by running"
|
|
|
|
@echo "'make reconfigure'."
|
|
|
|
@echo "This behavior may also be changed using CONF_CHECK=<ignore|auto>."
|
|
|
|
@echo ' '
|
|
|
|
endef
|
|
|
|
|
|
|
|
else # $(HAS_SPEC)=true
|
|
|
|
##############################################################################
|
|
|
|
# Helper functions for the 'main' target. These functions assume a single,
|
2015-04-07 07:06:24 +00:00
|
|
|
# proper and existing SPEC is included.
|
2015-03-26 15:17:30 +00:00
|
|
|
##############################################################################
|
|
|
|
|
2017-09-12 17:03:56 +00:00
|
|
|
include $(TOPDIR)/make/common/MakeBase.gmk
|
2015-03-26 15:17:30 +00:00
|
|
|
|
|
|
|
# Define basic logging setup
|
2017-09-25 08:32:00 +00:00
|
|
|
BUILD_LOG := $(OUTPUTDIR)/build.log
|
|
|
|
BUILD_PROFILE_LOG := $(OUTPUTDIR)/build-profile.log
|
2015-03-26 15:17:30 +00:00
|
|
|
|
2016-04-22 08:48:12 +00:00
|
|
|
BUILD_LOG_PIPE := > >($(TEE) -a $(BUILD_LOG)) 2> >($(TEE) -a $(BUILD_LOG) >&2) && wait
|
2019-04-03 19:52:37 +00:00
|
|
|
# Use this for simple echo/printf commands that are never expected to print
|
|
|
|
# to stderr.
|
|
|
|
BUILD_LOG_PIPE_SIMPLE := | $(TEE) -a $(BUILD_LOG)
|
2015-03-26 15:17:30 +00:00
|
|
|
|
2018-02-16 17:51:35 +00:00
|
|
|
ifneq ($(CUSTOM_ROOT), )
|
2024-09-03 15:31:09 +00:00
|
|
|
topdir = $(CUSTOM_ROOT)
|
2018-02-16 17:51:35 +00:00
|
|
|
else
|
2024-09-03 15:31:09 +00:00
|
|
|
topdir = $(TOPDIR)
|
2018-02-16 17:51:35 +00:00
|
|
|
endif
|
|
|
|
|
2020-05-07 15:47:11 +00:00
|
|
|
# Setup the build environment to match the requested specification on
|
|
|
|
# level of reproducible builds
|
|
|
|
define SetupReproducibleBuild
|
|
|
|
ifeq ($$(SOURCE_DATE), updated)
|
2022-03-07 19:40:34 +00:00
|
|
|
# For static values of SOURCE_DATE (not "updated"), these are set in spec.gmk
|
|
|
|
export SOURCE_DATE_EPOCH := $$(shell $$(DATE) +"%s")
|
2022-03-31 13:30:16 +00:00
|
|
|
export SOURCE_DATE_ISO_8601 := $$(call EpochToISO8601, $$(SOURCE_DATE_EPOCH))
|
2021-12-23 11:01:26 +00:00
|
|
|
endif
|
2020-05-07 15:47:11 +00:00
|
|
|
endef
|
|
|
|
|
2015-09-21 07:32:07 +00:00
|
|
|
# Parse COMPARE_BUILD into COMPARE_BUILD_*
|
|
|
|
# Syntax: COMPARE_BUILD=CONF=<configure options>:PATCH=<patch file>:
|
2015-09-25 06:58:49 +00:00
|
|
|
# MAKE=<make targets>:COMP_OPTS=<compare script options>:
|
2016-02-11 10:54:00 +00:00
|
|
|
# COMP_DIR=<compare script base dir>|<default>:
|
|
|
|
# FAIL=<bool>
|
2015-09-21 07:32:07 +00:00
|
|
|
# If neither CONF or PATCH is given, assume <default> means CONF if it
|
|
|
|
# begins with "--", otherwise assume it means PATCH.
|
|
|
|
# MAKE and COMP_OPTS can only be used with CONF and/or PATCH specified.
|
|
|
|
# If any value contains "+", it will be replaced by space.
|
2016-02-11 10:54:00 +00:00
|
|
|
# FAIL can be set to false to have the return value of compare be ignored.
|
2015-09-21 07:32:07 +00:00
|
|
|
define ParseCompareBuild
|
|
|
|
ifneq ($$(COMPARE_BUILD), )
|
2018-02-16 17:51:35 +00:00
|
|
|
COMPARE_BUILD_OUTPUTDIR := $(topdir)/build/compare-build/$(CONF_NAME)
|
2016-02-11 10:54:00 +00:00
|
|
|
COMPARE_BUILD_FAIL := true
|
2015-11-10 10:41:21 +00:00
|
|
|
|
2015-09-21 07:32:07 +00:00
|
|
|
ifneq ($$(findstring :, $$(COMPARE_BUILD)), )
|
|
|
|
$$(foreach part, $$(subst :, , $$(COMPARE_BUILD)), \
|
|
|
|
$$(if $$(filter PATCH=%, $$(part)), \
|
2024-09-03 15:31:09 +00:00
|
|
|
$$(eval COMPARE_BUILD_PATCH = $$(strip $$(patsubst PATCH=%, %, $$(part)))) \
|
2015-09-21 07:32:07 +00:00
|
|
|
) \
|
|
|
|
$$(if $$(filter CONF=%, $$(part)), \
|
2024-09-03 15:31:09 +00:00
|
|
|
$$(eval COMPARE_BUILD_CONF = $$(strip $$(subst +, , $$(patsubst CONF=%, %, $$(part))))) \
|
2015-09-21 07:32:07 +00:00
|
|
|
) \
|
|
|
|
$$(if $$(filter MAKE=%, $$(part)), \
|
2024-09-03 15:31:09 +00:00
|
|
|
$$(eval COMPARE_BUILD_MAKE = $$(strip $$(subst +, , $$(patsubst MAKE=%, %, $$(part))))) \
|
2015-09-21 07:32:07 +00:00
|
|
|
) \
|
|
|
|
$$(if $$(filter COMP_OPTS=%, $$(part)), \
|
2024-09-03 15:31:09 +00:00
|
|
|
$$(eval COMPARE_BUILD_COMP_OPTS = $$(strip $$(subst +, , $$(patsubst COMP_OPTS=%, %, $$(part))))) \
|
2015-09-21 07:32:07 +00:00
|
|
|
) \
|
2015-09-25 06:58:49 +00:00
|
|
|
$$(if $$(filter COMP_DIR=%, $$(part)), \
|
2024-09-03 15:31:09 +00:00
|
|
|
$$(eval COMPARE_BUILD_COMP_DIR = $$(strip $$(subst +, , $$(patsubst COMP_DIR=%, %, $$(part))))) \
|
2015-09-25 06:58:49 +00:00
|
|
|
) \
|
2016-02-11 10:54:00 +00:00
|
|
|
$$(if $$(filter FAIL=%, $$(part)), \
|
2024-09-03 15:31:09 +00:00
|
|
|
$$(eval COMPARE_BUILD_FAIL = $$(strip $$(subst +, , $$(patsubst FAIL=%, %, $$(part))))) \
|
2016-02-11 10:54:00 +00:00
|
|
|
) \
|
2020-06-29 16:39:40 +00:00
|
|
|
$$(if $$(filter NODRYRUN=%, $$(part)), \
|
2024-09-03 15:31:09 +00:00
|
|
|
$$(eval COMPARE_BUILD_NODRYRUN = $$(strip $$(subst +, , $$(patsubst NODRYRUN=%, %, $$(part))))) \
|
2020-06-29 16:39:40 +00:00
|
|
|
) \
|
2015-09-21 07:32:07 +00:00
|
|
|
)
|
|
|
|
else
|
|
|
|
# Separate handling for single field case, to allow for spaces in values.
|
|
|
|
ifneq ($$(filter PATCH=%, $$(COMPARE_BUILD)), )
|
2024-09-03 15:31:09 +00:00
|
|
|
COMPARE_BUILD_PATCH = $$(strip $$(patsubst PATCH=%, %, $$(COMPARE_BUILD)))
|
2015-09-21 07:32:07 +00:00
|
|
|
else ifneq ($$(filter CONF=%, $$(COMPARE_BUILD)), )
|
2024-09-03 15:31:09 +00:00
|
|
|
COMPARE_BUILD_CONF = $$(strip $$(subst +, , $$(patsubst CONF=%, %, $$(COMPARE_BUILD))))
|
2015-09-21 07:32:07 +00:00
|
|
|
else ifneq ($$(filter --%, $$(COMPARE_BUILD)), )
|
|
|
|
# Assume CONF if value begins with --
|
2024-09-03 15:31:09 +00:00
|
|
|
COMPARE_BUILD_CONF = $$(strip $$(subst +, , $$(COMPARE_BUILD)))
|
2015-09-21 07:32:07 +00:00
|
|
|
else
|
|
|
|
# Otherwise assume patch file
|
2024-09-03 15:31:09 +00:00
|
|
|
COMPARE_BUILD_PATCH = $$(strip $$(COMPARE_BUILD))
|
2015-09-21 07:32:07 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifneq ($$(COMPARE_BUILD_PATCH), )
|
2018-02-16 17:51:35 +00:00
|
|
|
ifneq ($$(wildcard $$(topdir)/$$(COMPARE_BUILD_PATCH)), )
|
2015-09-21 07:32:07 +00:00
|
|
|
# Assume relative path, if file exists
|
2018-02-16 17:51:35 +00:00
|
|
|
COMPARE_BUILD_PATCH := $$(wildcard $$(topdir)/$$(COMPARE_BUILD_PATCH))
|
2015-09-21 07:32:07 +00:00
|
|
|
else ifeq ($$(wildcard $$(COMPARE_BUILD_PATCH)), )
|
|
|
|
$$(error Patch file $$(COMPARE_BUILD_PATCH) does not exist)
|
|
|
|
endif
|
2020-06-29 16:39:40 +00:00
|
|
|
ifneq ($$(COMPARE_BUILD_NODRYRUN), true)
|
|
|
|
PATCH_DRY_RUN := $$(shell cd $$(topdir) && $$(PATCH) --dry-run -p1 < $$(COMPARE_BUILD_PATCH) > /dev/null 2>&1 || $$(ECHO) FAILED)
|
|
|
|
ifeq ($$(PATCH_DRY_RUN), FAILED)
|
|
|
|
$$(error Patch file $$(COMPARE_BUILD_PATCH) does not apply cleanly)
|
|
|
|
endif
|
2020-06-06 00:06:48 +00:00
|
|
|
endif
|
2015-09-21 07:32:07 +00:00
|
|
|
endif
|
2016-02-11 10:54:00 +00:00
|
|
|
ifneq ($$(COMPARE_BUILD_FAIL), true)
|
|
|
|
COMPARE_BUILD_IGNORE_RESULT := || true
|
|
|
|
endif
|
2015-09-21 07:32:07 +00:00
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
2015-11-10 10:41:21 +00:00
|
|
|
# Prepare for a comparison rebuild
|
|
|
|
define PrepareCompareBuild
|
|
|
|
$(ECHO) "Preparing for comparison rebuild"
|
|
|
|
# Apply patch, if any
|
2018-03-06 16:43:21 +00:00
|
|
|
$(if $(COMPARE_BUILD_PATCH), cd $(topdir) && $(PATCH) -p1 < $(COMPARE_BUILD_PATCH))
|
2015-11-10 10:41:21 +00:00
|
|
|
# Move the first build away temporarily
|
2018-02-16 17:51:35 +00:00
|
|
|
$(RM) -r $(topdir)/build/.compare-build-temp
|
|
|
|
$(MKDIR) -p $(topdir)/build/.compare-build-temp
|
|
|
|
$(MV) $(OUTPUTDIR) $(topdir)/build/.compare-build-temp
|
2015-11-10 10:41:21 +00:00
|
|
|
# Restore an old compare-build, or create a new compare-build directory.
|
2017-09-25 08:32:00 +00:00
|
|
|
if test -d $(COMPARE_BUILD_OUTPUTDIR); then \
|
|
|
|
$(MV) $(COMPARE_BUILD_OUTPUTDIR) $(OUTPUTDIR); \
|
2015-11-10 10:41:21 +00:00
|
|
|
else \
|
2017-09-25 08:32:00 +00:00
|
|
|
$(MKDIR) -p $(OUTPUTDIR); \
|
2015-11-10 10:41:21 +00:00
|
|
|
fi
|
|
|
|
# Re-run configure with the same arguments (and possibly some additional),
|
|
|
|
# must be done after patching.
|
2019-05-07 13:58:55 +00:00
|
|
|
( cd $(CONFIGURE_START_DIR) && PATH="$(ORIGINAL_PATH)" \
|
2018-02-16 17:51:35 +00:00
|
|
|
$(BASH) $(topdir)/configure $(CONFIGURE_COMMAND_LINE) $(COMPARE_BUILD_CONF))
|
2015-11-10 10:41:21 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Cleanup after a compare build
|
|
|
|
define CleanupCompareBuild
|
2024-02-23 17:31:13 +00:00
|
|
|
# If running with a COMPARE_BUILD patch, reverse-apply it, but continue
|
|
|
|
# even if that fails (can happen with removed files).
|
|
|
|
$(if $(COMPARE_BUILD_PATCH), cd $(topdir) && $(PATCH) -R -p1 < $(COMPARE_BUILD_PATCH) || true)
|
2015-11-10 10:41:21 +00:00
|
|
|
# Move this build away and restore the original build
|
2018-02-16 17:51:35 +00:00
|
|
|
$(MKDIR) -p $(topdir)/build/compare-build
|
2017-09-25 08:32:00 +00:00
|
|
|
$(MV) $(OUTPUTDIR) $(COMPARE_BUILD_OUTPUTDIR)
|
2018-02-16 17:51:35 +00:00
|
|
|
$(MV) $(topdir)/build/.compare-build-temp/$(CONF_NAME) $(OUTPUTDIR)
|
|
|
|
$(RM) -r $(topdir)/build/.compare-build-temp
|
2015-11-10 10:41:21 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Do the actual comparison of two builds
|
|
|
|
define CompareBuildDoComparison
|
|
|
|
# Compare first and second build. Ignore any error code from compare.sh.
|
|
|
|
$(ECHO) "Comparing between comparison rebuild (this/new) and baseline (other/old)"
|
|
|
|
$(if $(COMPARE_BUILD_COMP_DIR), \
|
2024-03-14 07:30:42 +00:00
|
|
|
+(cd $(COMPARE_BUILD_OUTPUTDIR) && ./compare.sh --diffs $(COMPARE_BUILD_COMP_OPTS) \
|
2017-09-25 08:32:00 +00:00
|
|
|
-2dirs $(COMPARE_BUILD_OUTPUTDIR)/$(COMPARE_BUILD_COMP_DIR) \
|
|
|
|
$(OUTPUTDIR)/$(COMPARE_BUILD_COMP_DIR) $(COMPARE_BUILD_IGNORE_RESULT)), \
|
2024-03-14 07:30:42 +00:00
|
|
|
+(cd $(COMPARE_BUILD_OUTPUTDIR) && ./compare.sh --diffs $(COMPARE_BUILD_COMP_OPTS) \
|
2017-09-25 08:32:00 +00:00
|
|
|
-o $(OUTPUTDIR) $(COMPARE_BUILD_IGNORE_RESULT)) \
|
2015-11-10 10:41:21 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define PrintFailureReports
|
2018-04-10 21:32:54 +00:00
|
|
|
$(if $(filter none, $(LOG_REPORT)), , \
|
2022-06-10 19:32:30 +00:00
|
|
|
$(RM) $(MAKESUPPORT_OUTPUTDIR)/failure-summary.log ; \
|
2018-04-10 21:32:54 +00:00
|
|
|
$(if $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log), \
|
2022-06-10 19:32:30 +00:00
|
|
|
( \
|
|
|
|
$(PRINTF) "\n=== Output from failing command(s) repeated here ===\n" ; \
|
|
|
|
$(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log)), \
|
|
|
|
$(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" ; \
|
|
|
|
$(if $(filter all, $(LOG_REPORT)), \
|
|
|
|
$(GREP) -v -e "^Note: including file:" < $(logfile) || true ; \
|
|
|
|
, \
|
|
|
|
($(GREP) -v -e "^Note: including file:" < $(logfile) || true) | $(HEAD) -n 15 ; \
|
|
|
|
if test `$(WC) -l < $(logfile)` -gt 15; then \
|
|
|
|
$(ECHO) " ... (rest of output omitted)" ; \
|
|
|
|
fi ; \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
$(PRINTF) "\n* All command lines available in $(MAKESUPPORT_OUTPUTDIR)/failure-logs.\n" ; \
|
|
|
|
$(PRINTF) "=== End of repeated output ===\n" ; \
|
|
|
|
) >> $(MAKESUPPORT_OUTPUTDIR)/failure-summary.log \
|
2015-11-10 10:41:21 +00:00
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define PrintBuildLogFailures
|
2018-04-10 21:32:54 +00:00
|
|
|
$(if $(filter none, $(LOG_REPORT)), , \
|
|
|
|
if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then \
|
|
|
|
$(PRINTF) "\n=== Make failed targets repeated here ===\n" ; \
|
|
|
|
$(GREP) "recipe for target .* failed" $(BUILD_LOG) ; \
|
|
|
|
$(PRINTF) "=== End of repeated output ===\n" ; \
|
2022-03-31 13:30:16 +00:00
|
|
|
$(PRINTF) "\nHELP: Try searching the build log for the name of the first failed target.\n" ; \
|
2018-04-10 21:32:54 +00:00
|
|
|
else \
|
|
|
|
$(PRINTF) "\nNo indication of failed target found.\n" ; \
|
2022-03-31 13:30:16 +00:00
|
|
|
$(PRINTF) "HELP: Try searching the build log for '] Error'.\n" ; \
|
2022-06-10 19:32:30 +00:00
|
|
|
fi >> $(MAKESUPPORT_OUTPUTDIR)/failure-summary.log ; \
|
|
|
|
$(CAT) $(MAKESUPPORT_OUTPUTDIR)/failure-summary.log \
|
2018-04-10 21:32:54 +00:00
|
|
|
)
|
2015-11-10 10:41:21 +00:00
|
|
|
endef
|
|
|
|
|
2015-03-26 15:17:30 +00:00
|
|
|
define RotateLogFiles
|
2016-01-16 12:01:43 +00:00
|
|
|
$(RM) $(BUILD_LOG).old 2> /dev/null && \
|
2015-03-26 15:17:30 +00:00
|
|
|
$(MV) $(BUILD_LOG) $(BUILD_LOG).old 2> /dev/null || true
|
2017-03-30 19:23:07 +00:00
|
|
|
$(if $(findstring true, $(LOG_PROFILE_TIMES_FILE)), \
|
|
|
|
$(RM) $(BUILD_PROFILE_LOG).old 2> /dev/null && \
|
|
|
|
$(MV) $(BUILD_PROFILE_LOG) $(BUILD_PROFILE_LOG).old 2> /dev/null || true \
|
2015-03-26 15:17:30 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2018-06-14 09:46:53 +00:00
|
|
|
# Failure logs are only supported for "parallel" main targets, not the
|
|
|
|
# (trivial) sequential make targets (such as clean and reconfigure),
|
|
|
|
# since the failure-logs directory creation will conflict with clean.
|
2024-05-23 14:36:23 +00:00
|
|
|
# We also make sure the javatmp directory exists, which is needed if a java
|
|
|
|
# process (like javac) is using java.io.tmpdir.
|
2015-09-03 09:05:49 +00:00
|
|
|
define PrepareFailureLogs
|
2016-01-16 12:01:43 +00:00
|
|
|
$(RM) -r $(MAKESUPPORT_OUTPUTDIR)/failure-logs 2> /dev/null && \
|
2015-09-03 09:05:49 +00:00
|
|
|
$(MKDIR) -p $(MAKESUPPORT_OUTPUTDIR)/failure-logs
|
2024-05-23 14:36:23 +00:00
|
|
|
$(MKDIR) -p $(JAVA_TMP_DIR)
|
2017-03-03 11:57:57 +00:00
|
|
|
$(RM) $(MAKESUPPORT_OUTPUTDIR)/exit-with-error 2> /dev/null
|
2015-09-03 09:05:49 +00:00
|
|
|
endef
|
|
|
|
|
2015-03-26 15:17:30 +00:00
|
|
|
# Remove any javac server logs and port files. This
|
|
|
|
# prevents a new make run to reuse the previous servers.
|
2022-11-17 09:20:22 +00:00
|
|
|
define PrepareJavacServer
|
2020-05-05 18:02:43 +00:00
|
|
|
$(if $(JAVAC_SERVER_DIR), \
|
|
|
|
$(RM) -r $(JAVAC_SERVER_DIR) 2> /dev/null && \
|
|
|
|
$(MKDIR) -p $(JAVAC_SERVER_DIR) \
|
2015-03-26 15:17:30 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2022-11-17 09:20:22 +00:00
|
|
|
define CleanupJavacServer
|
|
|
|
[ -f $(JAVAC_SERVER_DIR)/server.port ] && $(ECHO) Stopping javac server && \
|
2020-05-05 18:02:43 +00:00
|
|
|
$(TOUCH) $(JAVAC_SERVER_DIR)/server.port.stop; true
|
2015-03-26 15:17:30 +00:00
|
|
|
endef
|
|
|
|
|
2019-02-07 11:35:45 +00:00
|
|
|
ifeq ($(call isBuildOs, windows), true)
|
2016-01-30 09:25:15 +00:00
|
|
|
# On windows we need to synchronize with the javac server to be able to
|
|
|
|
# move or remove the build output directory. Since we have no proper
|
|
|
|
# synchronization process, wait for a while and hope it helps. This is only
|
|
|
|
# used by build comparisons.
|
2022-11-17 09:20:22 +00:00
|
|
|
define WaitForJavacServerFinish
|
2020-05-05 18:02:43 +00:00
|
|
|
$(if $(JAVAC_SERVER_DIR), \
|
2024-09-03 15:31:09 +00:00
|
|
|
sleep 5 \
|
2016-01-30 09:25:15 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
else
|
2022-11-17 09:20:22 +00:00
|
|
|
define WaitForJavacServerFinish
|
2016-01-30 09:25:15 +00:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2024-04-11 14:15:34 +00:00
|
|
|
##############################################################################
|
|
|
|
# Functions for timers
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
# Store the build times in this directory.
|
2024-09-03 15:31:09 +00:00
|
|
|
BUILDTIMESDIR = $(OUTPUTDIR)/make-support/build-times
|
2024-04-11 14:15:34 +00:00
|
|
|
|
|
|
|
# Record starting time for build of a sub repository.
|
|
|
|
define RecordStartTime
|
|
|
|
$(DATE) '+%Y %m %d %H %M %S' | $(AWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$(strip $1) && \
|
|
|
|
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Record ending time and calculate the difference and store it in a
|
|
|
|
# easy to read format. Handles builds that cross midnight. Expects
|
|
|
|
# that a build will never take 24 hours or more.
|
|
|
|
define RecordEndTime
|
|
|
|
$(DATE) '+%Y %m %d %H %M %S' | $(AWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)
|
|
|
|
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable
|
|
|
|
$(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \
|
|
|
|
$(AWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \
|
|
|
|
M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \
|
|
|
|
> $(BUILDTIMESDIR)/build_time_diff_$(strip $1)
|
|
|
|
endef
|
|
|
|
|
2015-03-26 15:17:30 +00:00
|
|
|
define StartGlobalTimer
|
2016-01-16 12:01:43 +00:00
|
|
|
$(RM) -r $(BUILDTIMESDIR) 2> /dev/null && \
|
|
|
|
$(MKDIR) -p $(BUILDTIMESDIR) && \
|
2015-03-26 15:17:30 +00:00
|
|
|
$(call RecordStartTime,TOTAL)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define StopGlobalTimer
|
|
|
|
$(call RecordEndTime,TOTAL)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Find all build_time_* files and print their contents in a list sorted
|
|
|
|
# on the name of the sub repository.
|
|
|
|
define ReportBuildTimes
|
2016-01-16 12:01:43 +00:00
|
|
|
$(PRINTF) $(LOG_INFO) -- \
|
2015-03-26 15:17:30 +00:00
|
|
|
"----- Build times -------\nStart %s\nEnd %s\n%s\n%s\n-------------------------\n" \
|
|
|
|
"`$(CAT) $(BUILDTIMESDIR)/build_time_start_TOTAL_human_readable`" \
|
|
|
|
"`$(CAT) $(BUILDTIMESDIR)/build_time_end_TOTAL_human_readable`" \
|
|
|
|
"`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | \
|
|
|
|
$(XARGS) $(CAT) | $(SORT) -k 2`" \
|
2016-01-16 12:01:43 +00:00
|
|
|
"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`" \
|
2019-04-03 19:52:37 +00:00
|
|
|
$(BUILD_LOG_PIPE_SIMPLE)
|
2015-03-26 15:17:30 +00:00
|
|
|
endef
|
|
|
|
|
2017-03-30 19:23:07 +00:00
|
|
|
define ReportProfileTimes
|
|
|
|
$(if $(findstring true, $(LOG_PROFILE_TIMES_LOG)), \
|
|
|
|
[ ! -f $(BUILD_PROFILE_LOG) ] || \
|
|
|
|
{ $(ECHO) Begin $(notdir $(BUILD_PROFILE_LOG)) && \
|
|
|
|
$(CAT) $(BUILD_PROFILE_LOG) && \
|
|
|
|
$(ECHO) End $(notdir $(BUILD_PROFILE_LOG)); \
|
|
|
|
} \
|
2019-04-03 19:52:37 +00:00
|
|
|
$(BUILD_LOG_PIPE_SIMPLE)
|
2017-03-30 19:23:07 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2015-03-26 15:17:30 +00:00
|
|
|
endif # HAS_SPEC
|
|
|
|
|
2018-04-10 21:32:54 +00:00
|
|
|
# Look for a given option in the LOG variable, and if found, set a variable
|
|
|
|
# and remove the option from the LOG variable
|
|
|
|
# $1: The option to look for
|
|
|
|
# $2: The variable to set to "true" if the option is found
|
|
|
|
define ParseLogOption
|
2024-09-03 15:31:09 +00:00
|
|
|
ifneq ($$(findstring $1, $$(LOG)), )
|
2018-04-10 21:32:54 +00:00
|
|
|
override $2 := true
|
|
|
|
# First try to remove ",<option>" if it exists, otherwise just remove "<option>"
|
|
|
|
LOG_STRIPPED := $$(subst $1,, $$(subst $$(COMMA)$$(strip $1),, $$(LOG)))
|
|
|
|
# We might have ended up with a leading comma. Remove it. Need override
|
|
|
|
# since LOG is set from the command line.
|
|
|
|
override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Look for a given option with an assignment in the LOG variable, and if found,
|
|
|
|
# set a variable to that value and remove the option from the LOG variable
|
|
|
|
# $1: The option to look for
|
|
|
|
# $2: The variable to set to the value of the option, if found
|
|
|
|
define ParseLogValue
|
2024-09-03 15:31:09 +00:00
|
|
|
ifneq ($$(findstring $1=, $$(LOG)), )
|
2018-04-10 21:32:54 +00:00
|
|
|
# Make words of out comma-separated list and find the one with opt=val
|
|
|
|
value := $$(strip $$(subst $$(strip $1)=,, $$(filter $$(strip $1)=%, $$(subst $$(COMMA), , $$(LOG)))))
|
|
|
|
override $2 := $$(value)
|
|
|
|
# First try to remove ",<option>" if it exists, otherwise just remove "<option>"
|
|
|
|
LOG_STRIPPED := $$(subst $$(strip $1)=$$(value),, \
|
|
|
|
$$(subst $$(COMMA)$$(strip $1)=$$(value),, $$(LOG)))
|
|
|
|
# We might have ended up with a leading comma. Remove it. Need override
|
|
|
|
# since LOG is set from the command line.
|
|
|
|
override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
define ParseLogLevel
|
|
|
|
# Catch old-style VERBOSE= command lines.
|
|
|
|
ifneq ($$(origin VERBOSE), undefined)
|
|
|
|
$$(info Error: VERBOSE is deprecated. Use LOG=<warn|info|debug|trace> instead.)
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Setup logging according to LOG
|
|
|
|
|
|
|
|
# If "nofile" is present, do not log to a file
|
|
|
|
$$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
|
|
|
|
|
|
|
|
# If "cmdline" is present, print all executes "important" command lines.
|
|
|
|
$$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
|
|
|
|
|
|
|
|
# If "report" is present, use non-standard reporting options at build failure.
|
|
|
|
$$(eval $$(call ParseLogValue, report, LOG_REPORT))
|
|
|
|
ifneq ($$(LOG_REPORT), )
|
|
|
|
ifeq ($$(filter $$(LOG_REPORT), none all default), )
|
|
|
|
$$(info Error: LOG=report has invalid value: $$(LOG_REPORT).)
|
|
|
|
$$(info Valid values: LOG=report=<none>|<all>|<default>)
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# If "profile-to-log" is present, write shell times in build log
|
|
|
|
$$(eval $$(call ParseLogOption, profile-to-log, LOG_PROFILE_TIMES_LOG))
|
|
|
|
|
|
|
|
# If "profile" is present, write shell times in separate log file
|
|
|
|
# IMPORTANT: $(ParseLogOption profile-to-log) should go first. Otherwise
|
|
|
|
# parsing of 'LOG=debug,profile-to-log,nofile' ends up in the following error:
|
|
|
|
# Error: LOG contains unknown option or log level: debug-to-log.
|
|
|
|
$$(eval $$(call ParseLogOption, profile, LOG_PROFILE_TIMES_FILE))
|
|
|
|
|
|
|
|
# Treat LOG=profile-to-log as if it were LOG=profile,profile-to-log
|
|
|
|
LOG_PROFILE_TIMES_FILE := $$(firstword $$(LOG_PROFILE_TIMES_FILE) $$(LOG_PROFILE_TIMES_LOG))
|
|
|
|
|
|
|
|
override LOG_LEVEL := $$(LOG)
|
|
|
|
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($$(LOG_LEVEL), )
|
2018-04-10 21:32:54 +00:00
|
|
|
# Set LOG to "warn" as default if not set
|
|
|
|
override LOG_LEVEL := warn
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($$(LOG_LEVEL), warn)
|
|
|
|
override MAKE_LOG_FLAGS := -s
|
|
|
|
else ifeq ($$(LOG_LEVEL), info)
|
|
|
|
override MAKE_LOG_FLAGS := -s
|
|
|
|
else ifeq ($$(LOG_LEVEL), debug)
|
|
|
|
override MAKE_LOG_FLAGS :=
|
|
|
|
else ifeq ($$(LOG_LEVEL), trace)
|
|
|
|
override MAKE_LOG_FLAGS :=
|
|
|
|
else
|
|
|
|
$$(info Error: LOG contains unknown option or log level: $$(LOG).)
|
|
|
|
$$(info LOG can be <level>[,<opt>[...]] where <opt> is nofile | cmdlines | profile | profile-to-log)
|
|
|
|
$$(info and <level> is warn | info | debug | trace)
|
|
|
|
$$(error Cannot continue)
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
2017-03-30 19:23:07 +00:00
|
|
|
MAKE_LOG_VARS = $(foreach v, \
|
2018-04-10 21:32:54 +00:00
|
|
|
LOG_LEVEL LOG_NOFILE LOG_CMDLINES LOG_REPORT LOG_PROFILE_TIMES_LOG \
|
|
|
|
LOG_PROFILE_TIMES_FILE, \
|
2017-03-30 19:23:07 +00:00
|
|
|
$v=$($v) \
|
|
|
|
)
|
|
|
|
|
2015-03-26 15:17:30 +00:00
|
|
|
endif # _INITSUPPORT_GMK
|