plat_helpers.mk 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. ifeq (${PLAT},)
  12. $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
  13. endif
  14. # TF_PLATFORM_ROOT can be overridden for when building tools directly
  15. TF_PLATFORM_ROOT ?= plat/
  16. PLAT_MAKEFILE := platform.mk
  17. # Generate the platforms list by recursively searching for all directories
  18. # under /plat containing a PLAT_MAKEFILE. Append each platform with a `|`
  19. # char and strip out the final '|'.
  20. ALL_PLATFORM_MK_FILES := $(call rwildcard,${TF_PLATFORM_ROOT},${PLAT_MAKEFILE})
  21. ALL_PLATFORM_DIRS := $(patsubst %/,%,$(dir ${ALL_PLATFORM_MK_FILES}))
  22. ALL_PLATFORMS := $(sort $(notdir ${ALL_PLATFORM_DIRS}))
  23. PLAT_MAKEFILE_FULL := $(filter %/${PLAT}/${PLAT_MAKEFILE},${ALL_PLATFORM_MK_FILES})
  24. PLATFORM_LIST := $(subst ${space},|,${ALL_PLATFORMS})
  25. ifeq ($(PLAT_MAKEFILE_FULL),)
  26. $(error "Error: Invalid platform. The following platforms are available: ${PLATFORM_LIST}")
  27. endif
  28. # Record the directory where the platform make file was found.
  29. PLAT_DIR := $(dir ${PLAT_MAKEFILE_FULL})
  30. endif