# # Copyright (c) 2011, 2017, 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 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 ifeq ($(HAS_SPEC),) # Include the corresponding closed file, if present. ifneq ($(CUSTOM_MAKE_DIR), ) -include $(CUSTOM_MAKE_DIR)/InitSupport.gmk endif ############################################################################## # 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 INIT_CONTROL_VARIABLES += LOG CONF CONF_NAME SPEC JOBS TEST_JOBS CONF_CHECK \ COMPARE_BUILD JTREG GTEST TEST_OPTS TEST_VM_OPTS # All known make control variables MAKE_CONTROL_VARIABLES := $(INIT_CONTROL_VARIABLES) TEST JDK_FILTER # 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. # The '\#' <=> '\ 'dance is needed to keep values with space in them connected. COMMAND_LINE_VARIABLES := $(subst \#,\ , $(call reverse, $(subst \ ,\#,$(MAKEOVERRIDES)))) # A list like FOO="val1" BAR="val2" containing all user-supplied make # variables that we should propagate. # The '\#' <=> '\ 'dance is needed to keep values with space in them connected. USER_MAKE_VARS := $(subst \#,\ , $(filter-out $(addsuffix =%, $(INIT_CONTROL_VARIABLES)), \ $(subst \ ,\#,$(MAKEOVERRIDES)))) # Setup information about available configurations, if any. ifneq ($(CUSTOM_ROOT), ) build_dir=$(CUSTOM_ROOT)/build else build_dir=$(topdir)/build endif all_spec_files=$(wildcard $(build_dir)/*/spec.gmk) # Extract the configuration names from the path all_confs=$(patsubst %/spec.gmk, %, $(patsubst $(build_dir)/%, %, $(all_spec_files))) # Check for unknown command-line variables define CheckControlVariables command_line_variables := $$(strip $$(foreach var, \ $$(subst \ ,_,$$(MAKEOVERRIDES)), \ $$(firstword $$(subst =, , $$(var))))) unknown_command_line_variables := $$(strip \ $$(filter-out $$(MAKE_CONTROL_VARIABLES), $$(command_line_variables))) 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 else ifneq ($$(filter-out auto fail ignore, $$(CONF_CHECK)),) $$(info Error: CONF_CHECK must be one of: auto, fail or ignore.) $$(error Cannot continue) endif endef # 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 option to set to "true" if the option is found define ParseLogOption ifneq ($$(findstring $1, $$(LOG)),) $2 := true # COMMA is defined in spec.gmk, but that is not included yet COMMA := , # First try to remove ",