summaryrefslogtreecommitdiffstats
path: root/make_helpers/plat_helpers.mk
blob: a7ae9a279cf174dbe5dd7ccfd0410e87c0c3ca52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#
# Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#

################################################################################
# Helpers for finding and referencing platform directories
################################################################################

ifndef PLAT_HELPERS_MK
    PLAT_HELPERS_MK := $(lastword $(MAKEFILE_LIST))

    ifeq (${PLAT},)
        $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
    endif

    # TF_PLATFORM_ROOT can be overridden for when building tools directly
    TF_PLATFORM_ROOT               ?= plat/
    PLAT_MAKEFILE               := platform.mk

    # Generate the platforms list by recursively searching for all directories
    # under /plat containing a PLAT_MAKEFILE. Append each platform with a `|`
    # char and strip out the final '|'.
    ALL_PLATFORM_MK_FILES       := $(call rwildcard,${TF_PLATFORM_ROOT},${PLAT_MAKEFILE})
    ALL_PLATFORM_DIRS           := $(patsubst %/,%,$(dir ${ALL_PLATFORM_MK_FILES}))
    ALL_PLATFORMS               := $(sort $(notdir ${ALL_PLATFORM_DIRS}))

    PLAT_MAKEFILE_FULL          := $(filter %/${PLAT}/${PLAT_MAKEFILE},${ALL_PLATFORM_MK_FILES})
    PLATFORM_LIST               := $(subst ${space},|,${ALL_PLATFORMS})
    ifeq ($(PLAT_MAKEFILE_FULL),)
        $(error "Error: Invalid platform. The following platforms are available: ${PLATFORM_LIST}")
    endif

    # Record the directory where the platform make file was found.
    PLAT_DIR                    := $(dir ${PLAT_MAKEFILE_FULL})

endif