Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. |
| 3 | # |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 5 | # |
| 6 | |
| 7 | ################################################################################ |
| 8 | # Helpers for finding and referencing platform directories |
| 9 | ################################################################################ |
| 10 | |
| 11 | ifndef PLAT_HELPERS_MK |
| 12 | PLAT_HELPERS_MK := $(lastword $(MAKEFILE_LIST)) |
| 13 | |
Andrey Skvortsov | 89c3a14 | 2024-02-18 11:43:12 +0300 | [diff] [blame] | 14 | PLAT:= ${DEFAULT_PLAT} |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 15 | ifeq (${PLAT},) |
| 16 | $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform") |
| 17 | endif |
| 18 | |
Heyi Guo | 335433a | 2018-03-01 18:57:58 +0800 | [diff] [blame] | 19 | # TF_PLATFORM_ROOT can be overridden for when building tools directly |
| 20 | TF_PLATFORM_ROOT ?= plat/ |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 21 | PLAT_MAKEFILE := platform.mk |
Andrey Skvortsov | 89c3a14 | 2024-02-18 11:43:12 +0300 | [diff] [blame] | 22 | PLAT_DEFAULTS_MAKEFILE := platform_defaults.mk |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 23 | |
| 24 | # Generate the platforms list by recursively searching for all directories |
| 25 | # under /plat containing a PLAT_MAKEFILE. Append each platform with a `|` |
| 26 | # char and strip out the final '|'. |
Heyi Guo | 335433a | 2018-03-01 18:57:58 +0800 | [diff] [blame] | 27 | ALL_PLATFORM_MK_FILES := $(call rwildcard,${TF_PLATFORM_ROOT},${PLAT_MAKEFILE}) |
Andrey Skvortsov | 89c3a14 | 2024-02-18 11:43:12 +0300 | [diff] [blame] | 28 | ALL_PLATFORM_MK_DEF_FILES := $(call rwildcard,${TF_PLATFORM_ROOT},${PLAT_DEFAULTS_MAKEFILE}) |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 29 | ALL_PLATFORM_DIRS := $(patsubst %/,%,$(dir ${ALL_PLATFORM_MK_FILES})) |
| 30 | ALL_PLATFORMS := $(sort $(notdir ${ALL_PLATFORM_DIRS})) |
| 31 | |
| 32 | PLAT_MAKEFILE_FULL := $(filter %/${PLAT}/${PLAT_MAKEFILE},${ALL_PLATFORM_MK_FILES}) |
Andrey Skvortsov | 89c3a14 | 2024-02-18 11:43:12 +0300 | [diff] [blame] | 33 | PLAT_DEFAULTS_MAKEFILE_FULL := $(filter %/${PLAT}/${PLAT_DEFAULTS_MAKEFILE},${ALL_PLATFORM_MK_DEF_FILES}) |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 34 | PLATFORM_LIST := $(subst ${space},|,${ALL_PLATFORMS}) |
| 35 | ifeq ($(PLAT_MAKEFILE_FULL),) |
| 36 | $(error "Error: Invalid platform. The following platforms are available: ${PLATFORM_LIST}") |
| 37 | endif |
| 38 | |
| 39 | # Record the directory where the platform make file was found. |
| 40 | PLAT_DIR := $(dir ${PLAT_MAKEFILE_FULL}) |
| 41 | |
| 42 | endif |