plat_helpers.mk 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #
  2. # Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. ################################################################################
  7. # Helpers for finding and referencing platform directories
  8. ################################################################################
  9. ifndef PLAT_HELPERS_MK
  10. PLAT_HELPERS_MK := $(lastword $(MAKEFILE_LIST))
  11. PLAT:= ${DEFAULT_PLAT}
  12. ifeq (${PLAT},)
  13. $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
  14. endif
  15. # TF_PLATFORM_ROOT can be overridden for when building tools directly
  16. TF_PLATFORM_ROOT ?= plat/
  17. PLAT_MAKEFILE := platform.mk
  18. PLAT_DEFAULTS_MAKEFILE := platform_defaults.mk
  19. # Generate the platforms list by recursively searching for all directories
  20. # under /plat containing a PLAT_MAKEFILE. Append each platform with a `|`
  21. # char and strip out the final '|'.
  22. ALL_PLATFORM_MK_FILES := $(call rwildcard,${TF_PLATFORM_ROOT},${PLAT_MAKEFILE})
  23. ALL_PLATFORM_MK_DEF_FILES := $(call rwildcard,${TF_PLATFORM_ROOT},${PLAT_DEFAULTS_MAKEFILE})
  24. ALL_PLATFORM_DIRS := $(patsubst %/,%,$(dir ${ALL_PLATFORM_MK_FILES}))
  25. ALL_PLATFORMS := $(sort $(notdir ${ALL_PLATFORM_DIRS}))
  26. PLAT_MAKEFILE_FULL := $(filter %/${PLAT}/${PLAT_MAKEFILE},${ALL_PLATFORM_MK_FILES})
  27. PLAT_DEFAULTS_MAKEFILE_FULL := $(filter %/${PLAT}/${PLAT_DEFAULTS_MAKEFILE},${ALL_PLATFORM_MK_DEF_FILES})
  28. PLATFORM_LIST := $(subst ${space},|,${ALL_PLATFORMS})
  29. ifeq ($(PLAT_MAKEFILE_FULL),)
  30. $(error "Error: Invalid platform. The following platforms are available: ${PLATFORM_LIST}")
  31. endif
  32. # Record the directory where the platform make file was found.
  33. PLAT_DIR := $(dir ${PLAT_MAKEFILE_FULL})
  34. endif