blob: a7ae9a279cf174dbe5dd7ccfd0410e87c0c3ca52 [file] [log] [blame]
Evan Lloydf2697142015-12-02 18:17:37 +00001#
2# Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Evan Lloydf2697142015-12-02 18:17:37 +00005#
6
7################################################################################
8# Helpers for finding and referencing platform directories
9################################################################################
10
11ifndef PLAT_HELPERS_MK
12 PLAT_HELPERS_MK := $(lastword $(MAKEFILE_LIST))
13
14 ifeq (${PLAT},)
15 $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
16 endif
17
Heyi Guo335433a2018-03-01 18:57:58 +080018 # TF_PLATFORM_ROOT can be overridden for when building tools directly
19 TF_PLATFORM_ROOT ?= plat/
Evan Lloydf2697142015-12-02 18:17:37 +000020 PLAT_MAKEFILE := platform.mk
21
22 # Generate the platforms list by recursively searching for all directories
23 # under /plat containing a PLAT_MAKEFILE. Append each platform with a `|`
24 # char and strip out the final '|'.
Heyi Guo335433a2018-03-01 18:57:58 +080025 ALL_PLATFORM_MK_FILES := $(call rwildcard,${TF_PLATFORM_ROOT},${PLAT_MAKEFILE})
Evan Lloydf2697142015-12-02 18:17:37 +000026 ALL_PLATFORM_DIRS := $(patsubst %/,%,$(dir ${ALL_PLATFORM_MK_FILES}))
27 ALL_PLATFORMS := $(sort $(notdir ${ALL_PLATFORM_DIRS}))
28
29 PLAT_MAKEFILE_FULL := $(filter %/${PLAT}/${PLAT_MAKEFILE},${ALL_PLATFORM_MK_FILES})
30 PLATFORM_LIST := $(subst ${space},|,${ALL_PLATFORMS})
31 ifeq ($(PLAT_MAKEFILE_FULL),)
32 $(error "Error: Invalid platform. The following platforms are available: ${PLATFORM_LIST}")
33 endif
34
35 # Record the directory where the platform make file was found.
36 PLAT_DIR := $(dir ${PLAT_MAKEFILE_FULL})
37
38endif