1*231c1470SEvan Lloyd# 2*231c1470SEvan Lloyd# Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. 3*231c1470SEvan Lloyd# 4*231c1470SEvan Lloyd# Redistribution and use in source and binary forms, with or without 5*231c1470SEvan Lloyd# modification, are permitted provided that the following conditions are met: 6*231c1470SEvan Lloyd# 7*231c1470SEvan Lloyd# Redistributions of source code must retain the above copyright notice, this 8*231c1470SEvan Lloyd# list of conditions and the following disclaimer. 9*231c1470SEvan Lloyd# 10*231c1470SEvan Lloyd# Redistributions in binary form must reproduce the above copyright notice, 11*231c1470SEvan Lloyd# this list of conditions and the following disclaimer in the documentation 12*231c1470SEvan Lloyd# and/or other materials provided with the distribution. 13*231c1470SEvan Lloyd# 14*231c1470SEvan Lloyd# Neither the name of ARM nor the names of its contributors may be used 15*231c1470SEvan Lloyd# to endorse or promote products derived from this software without specific 16*231c1470SEvan Lloyd# prior written permission. 17*231c1470SEvan Lloyd# 18*231c1470SEvan Lloyd# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19*231c1470SEvan Lloyd# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*231c1470SEvan Lloyd# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*231c1470SEvan Lloyd# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22*231c1470SEvan Lloyd# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*231c1470SEvan Lloyd# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*231c1470SEvan Lloyd# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*231c1470SEvan Lloyd# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*231c1470SEvan Lloyd# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*231c1470SEvan Lloyd# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*231c1470SEvan Lloyd# POSSIBILITY OF SUCH DAMAGE. 29*231c1470SEvan Lloyd# 30*231c1470SEvan Lloyd 31*231c1470SEvan Lloyd################################################################################ 32*231c1470SEvan Lloyd# Helpers for finding and referencing platform directories 33*231c1470SEvan Lloyd################################################################################ 34*231c1470SEvan Lloyd 35*231c1470SEvan Lloydifndef PLAT_HELPERS_MK 36*231c1470SEvan Lloyd PLAT_HELPERS_MK := $(lastword $(MAKEFILE_LIST)) 37*231c1470SEvan Lloyd 38*231c1470SEvan Lloyd ifeq (${PLAT},) 39*231c1470SEvan Lloyd $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform") 40*231c1470SEvan Lloyd endif 41*231c1470SEvan Lloyd 42*231c1470SEvan Lloyd # PLATFORM_ROOT can be overridden for when building tools directly 43*231c1470SEvan Lloyd PLATFORM_ROOT ?= plat/ 44*231c1470SEvan Lloyd PLAT_MAKEFILE := platform.mk 45*231c1470SEvan Lloyd 46*231c1470SEvan Lloyd # Generate the platforms list by recursively searching for all directories 47*231c1470SEvan Lloyd # under /plat containing a PLAT_MAKEFILE. Append each platform with a `|` 48*231c1470SEvan Lloyd # char and strip out the final '|'. 49*231c1470SEvan Lloyd ALL_PLATFORM_MK_FILES := $(call rwildcard,${PLATFORM_ROOT},${PLAT_MAKEFILE}) 50*231c1470SEvan Lloyd ALL_PLATFORM_DIRS := $(patsubst %/,%,$(dir ${ALL_PLATFORM_MK_FILES})) 51*231c1470SEvan Lloyd ALL_PLATFORMS := $(sort $(notdir ${ALL_PLATFORM_DIRS})) 52*231c1470SEvan Lloyd 53*231c1470SEvan Lloyd PLAT_MAKEFILE_FULL := $(filter %/${PLAT}/${PLAT_MAKEFILE},${ALL_PLATFORM_MK_FILES}) 54*231c1470SEvan Lloyd PLATFORM_LIST := $(subst ${space},|,${ALL_PLATFORMS}) 55*231c1470SEvan Lloyd ifeq ($(PLAT_MAKEFILE_FULL),) 56*231c1470SEvan Lloyd $(error "Error: Invalid platform. The following platforms are available: ${PLATFORM_LIST}") 57*231c1470SEvan Lloyd endif 58*231c1470SEvan Lloyd 59*231c1470SEvan Lloyd # Record the directory where the platform make file was found. 60*231c1470SEvan Lloyd PLAT_DIR := $(dir ${PLAT_MAKEFILE_FULL}) 61*231c1470SEvan Lloyd 62*231c1470SEvan Lloydendif 63