xref: /rk3399_ARM-atf/make_helpers/plat_helpers.mk (revision 1b2fb6adb53de652d3fe69984731a62da122e0da)
1231c1470SEvan Lloyd#
2231c1470SEvan Lloyd# Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3231c1470SEvan Lloyd#
482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause
5231c1470SEvan Lloyd#
6231c1470SEvan Lloyd
7231c1470SEvan Lloyd################################################################################
8231c1470SEvan Lloyd# Helpers for finding and referencing platform directories
9231c1470SEvan Lloyd################################################################################
10231c1470SEvan Lloyd
11231c1470SEvan Lloydifndef PLAT_HELPERS_MK
12231c1470SEvan Lloyd    PLAT_HELPERS_MK := $(lastword $(MAKEFILE_LIST))
13231c1470SEvan Lloyd
14*1b2fb6adSAndrey Skvortsov    PLAT:= ${DEFAULT_PLAT}
15231c1470SEvan Lloyd    ifeq (${PLAT},)
16231c1470SEvan Lloyd        $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
17231c1470SEvan Lloyd    endif
18231c1470SEvan Lloyd
197d9ee7e3SHeyi Guo    # TF_PLATFORM_ROOT can be overridden for when building tools directly
207d9ee7e3SHeyi Guo    TF_PLATFORM_ROOT               ?= plat/
21231c1470SEvan Lloyd    PLAT_MAKEFILE               := platform.mk
22*1b2fb6adSAndrey Skvortsov    PLAT_DEFAULTS_MAKEFILE      := platform_defaults.mk
23231c1470SEvan Lloyd
24231c1470SEvan Lloyd    # Generate the platforms list by recursively searching for all directories
25231c1470SEvan Lloyd    # under /plat containing a PLAT_MAKEFILE. Append each platform with a `|`
26231c1470SEvan Lloyd    # char and strip out the final '|'.
277d9ee7e3SHeyi Guo    ALL_PLATFORM_MK_FILES       := $(call rwildcard,${TF_PLATFORM_ROOT},${PLAT_MAKEFILE})
28*1b2fb6adSAndrey Skvortsov    ALL_PLATFORM_MK_DEF_FILES   := $(call rwildcard,${TF_PLATFORM_ROOT},${PLAT_DEFAULTS_MAKEFILE})
29231c1470SEvan Lloyd    ALL_PLATFORM_DIRS           := $(patsubst %/,%,$(dir ${ALL_PLATFORM_MK_FILES}))
30231c1470SEvan Lloyd    ALL_PLATFORMS               := $(sort $(notdir ${ALL_PLATFORM_DIRS}))
31231c1470SEvan Lloyd
32231c1470SEvan Lloyd    PLAT_MAKEFILE_FULL          := $(filter %/${PLAT}/${PLAT_MAKEFILE},${ALL_PLATFORM_MK_FILES})
33*1b2fb6adSAndrey Skvortsov    PLAT_DEFAULTS_MAKEFILE_FULL := $(filter %/${PLAT}/${PLAT_DEFAULTS_MAKEFILE},${ALL_PLATFORM_MK_DEF_FILES})
34231c1470SEvan Lloyd    PLATFORM_LIST               := $(subst ${space},|,${ALL_PLATFORMS})
35231c1470SEvan Lloyd    ifeq ($(PLAT_MAKEFILE_FULL),)
36231c1470SEvan Lloyd        $(error "Error: Invalid platform. The following platforms are available: ${PLATFORM_LIST}")
37231c1470SEvan Lloyd    endif
38231c1470SEvan Lloyd
39231c1470SEvan Lloyd    # Record the directory where the platform make file was found.
40231c1470SEvan Lloyd    PLAT_DIR                    := $(dir ${PLAT_MAKEFILE_FULL})
41231c1470SEvan Lloyd
42231c1470SEvan Lloydendif
43