zephyr/make/env/defs.base

161 lines
5.6 KiB
Plaintext

# defs.base - build system
#
# Copyright (c) 2013-2014 Wind River Systems, Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3) Neither the name of Wind River Systems nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#####
# this file initializes:
#
# - vBASE, the base VxMicro directory
# - vMAKE, the base make fragments directory
# - vBSP_BASE_DIR, the base BSP directory
# - vCONFIG_BASE_DIR, the configuration directory
# - build parallelism
# - verbosity levels
#####
# verify GNU make has the features used by the build system
$(if $(filter .FEATURES,${.VARIABLES}),,$(error GNU make v3.81+ required))
$(if $(filter second-expansion,${.FEATURES}),,$(error Your GNU make does not support .SECONDEXPANSION))
$(if $(filter order-only,${.FEATURES}),,$(error Your GNU make does not support order-only prerequesites))
$(if $(filter else-if,${.FEATURES}),,$(error Your GNU make does not support else-if conditionals))
#####
# $(file ...) has been introduced in GNU make 4.0, but sadly without a way of
# checking for its existence in the .FEATURES variable.
vFILE_SUPPORTED := $(if $(filter 4.%,${MAKE_VERSION}),y,n)
#####
$(if ${VXMICRO_BASE},,$(error VXMICRO_BASE must be set))
vBASE ?= $(strip $(subst ${vDRIVE_BASE},,$(subst \,/,${VXMICRO_BASE})))
vMAKE ?= ${vBASE}/make
vBSP_BASE_DIR ?= $(strip $(subst \,/,$(or ${VXMICRO_BSP_BASE},${vBASE}/arch/${vARCH})))
vCONFIG_BASE_DIR ?= $(strip $(subst \,/,${vBASE}/config))
#####
# quiet/verbose
# if V=1 from command line => verbose; else, if VERBOSE=1 is set anywhere => verbose; else => quiet
iCL_V_undefined =
iCL_V_1 = 1
iCL_V = $(or $(filter undefined,$(origin V)),$(if $(filter "command line","$(origin V)"),$V,))
iVERBOSE_1 = 1
vVERBOSE = $(filter 1,$(or ${iCL_V_${iCL_V}},${iVERBOSE_${VERBOSE}}))
# for recipe lines: $q = @ if not-verbose
q = $(if ${vVERBOSE},,@)
SHOW_INFORMATIVE_WARNINGS_ ?= 1
SHOW_INFORMATIVE_WARNINGS ?= $(SHOW_INFORMATIVE_WARNINGS_$q)
# invoke with $(eval ${q_include} <file>)
q_include = $(if ${vVERBOSE},,s)include
# invoke with $(call q_info,<string>)
q_info = $(if ${vVERBOSE},$(info $1),)
#####
# To keep things simple, do not allow multiple goals on the command line
# since some goals might require autoconf.mk to exist, and might trigger its
# rule but require prj.conf to exist, while some rules don't.
iONE_GOAL_1 = y
iONE_GOAL = ${iONE_GOAL_$(words ${MAKECMDGOALS})}
iDEFAULT_GOAL_0 = y
iDEFAULT_GOAL = ${iDEFAULT_GOAL_$(words ${MAKECMDGOALS})}
iUNIQUE_GOAL_y = y
iUNIQUE_GOAL_ = n
iUNIQUE_GOAL = ${iUNIQUE_GOAL_${iONE_GOAL}${iDEFAULT_GOAL}}
ifneq (${iUNIQUE_GOAL},y)
$(error Cannot invoke make with multiple goals on the command line)
endif
#####
# Find out if the goal is one that does necessitate some user-provided values.
# 'help', and the variants of 'clean' can be invoked without knowing about the
# BSP, ARCH, CPU, etc.
ifeq ($(strip $(findstring help,${MAKECMDGOALS})),help)
vGOAL_NEEDS_TARGET_SETUP = n
else ifneq ($(strip $(filter ${MAKECMDGOALS},wipe pristine clean)),)
vGOAL_NEEDS_TARGET_SETUP = n
else ifeq ($(strip $(findstring display_settings,${MAKECMDGOALS})),display_settings)
vGOAL_NEEDS_TARGET_SETUP = n
else ifeq ($(strip $(findstring display_variables,${MAKECMDGOALS})),display_variables)
vGOAL_NEEDS_TARGET_SETUP = n
else
vGOAL_NEEDS_TARGET_SETUP = y
endif
#####
# This variable is only to help when debugging the build system. A build
# system developer can set it to <nothing> so that some rules do not
# retrigger when the build system change, since this can be very time-
# consuming, especially on Windows. Care must be taken that the part of the
# build system being worked on do not necessitate these rules to retrigger.
iDEPEND_ON_MAKEFILES = ${MAKEFILE_LIST}
#####
# figure out which host type we're running on
include ${vMAKE}/env/defs.host
#####
# global rules
#
# These are really rules, and should be in a rules.<something> file, but
# they must be stated *prior* to rules that need them to be in-effect. To keep
# things simple, the only fragment that is required to be included *before*
# anything is the current file (it must be the first statement in the top-level
# makefile), so put those rules here.
.SECONDARY:
.SECONDEXPANSION:
.SUFFIXES:
#####
# obscure string manipulations
vCOMMA = ,
vEMPTY =
vSPACE = ${vEMPTY} ${vEMPTY}
include ${vMAKE}/env/rules.shared