Platform: Fix relative include paths of linker

Instead of using hard-coded relative include paths in the linker
command files, this change sets the include search path
in the command line.

Change-Id: I6d117a5bbf624f7c252f12103dee2afd338f2983
Signed-off-by: Gabor Kertesz <gabor.kertesz@arm.com>
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 1d5bb29..de846d5 100755
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -65,7 +65,12 @@
 if(NOT DEFINED NS_SCATTER_FILE_NAME)
 	message(FATAL_ERROR "ERROR: Incomplete Configuration: NS_SCATTER_FILE_NAME not defined, Include this file from a Config*.cmake")
 endif()
-embedded_set_target_linker_file(TARGET tfm_ns PATH  "${NS_SCATTER_FILE_NAME}")
+embedded_set_target_linker_file(TARGET ${PROJECT_NAME} PATH  "${NS_SCATTER_FILE_NAME}")
+
+if(NOT DEFINED PLATFORM_LINK_INCLUDES)
+	message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.")
+endif()
+embedded_set_target_link_includes(TARGET ${PROJECT_NAME} INCLUDES "${PLATFORM_LINK_INCLUDES}")
 
 #Set include directories.
 embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR}/common/sct ABSOLUTE APPEND)
diff --git a/bl2/ext/mcuboot/CMakeLists.txt b/bl2/ext/mcuboot/CMakeLists.txt
index e4b9b41..fb0d4ca 100644
--- a/bl2/ext/mcuboot/CMakeLists.txt
+++ b/bl2/ext/mcuboot/CMakeLists.txt
@@ -99,7 +99,12 @@
 if(NOT DEFINED BL2_LINKER_CONFIG)
 	message(FATAL_ERROR "ERROR: Incomplete Configuration: BL2_LINKER_CONFIG is not defined.")
 endif()
-embedded_set_target_linker_file(TARGET mcuboot PATH "${BL2_LINKER_CONFIG}")
+embedded_set_target_linker_file(TARGET ${PROJECT_NAME} PATH "${BL2_LINKER_CONFIG}")
+
+if(NOT DEFINED PLATFORM_LINK_INCLUDES)
+	message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.")
+endif()
+embedded_set_target_link_includes(TARGET ${PROJECT_NAME} INCLUDES "${PLATFORM_LINK_INCLUDES}")
 
 add_executable(${PROJECT_NAME} ${ALL_SRC_ASM_BL2} ${ALL_SRC_C} ${ALL_SRC_CXX})
 
diff --git a/platform/ext/Mps2AN519.cmake b/platform/ext/Mps2AN519.cmake
index 4d7cfd6..18da2bf 100755
--- a/platform/ext/Mps2AN519.cmake
+++ b/platform/ext/Mps2AN519.cmake
@@ -13,11 +13,12 @@
 set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
 
 #Specify the location of platform specific build dependencies.
-set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_bl2.sct")
-set (S_SCATTER_FILE_NAME   "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_s.sct")
-set (NS_SCATTER_FILE_NAME  "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_ns.sct")
-set (FLASH_LAYOUT          "${PLATFORM_DIR}/target/mps2/an519/partition/flash_layout.h")
-set (SIGN_BIN_SIZE         0x100000)
+set (BL2_SCATTER_FILE_NAME  "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_bl2.sct")
+set (S_SCATTER_FILE_NAME    "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_s.sct")
+set (NS_SCATTER_FILE_NAME   "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_ns.sct")
+set (FLASH_LAYOUT           "${PLATFORM_DIR}/target/mps2/an519/partition/flash_layout.h")
+set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/mps2/an519/partition/")
+set (SIGN_BIN_SIZE          0x100000)
 if (DEFINED CMSIS_5_DIR)
   # not all project defines CMSIS_5_DIR, only the ones that use it.
   set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MBN.lib")
diff --git a/platform/ext/Mps2AN521.cmake b/platform/ext/Mps2AN521.cmake
index 9c56ad4..1865d03 100755
--- a/platform/ext/Mps2AN521.cmake
+++ b/platform/ext/Mps2AN521.cmake
@@ -33,8 +33,9 @@
 else()
     message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
 endif()
-set (FLASH_LAYOUT          "${PLATFORM_DIR}/target/mps2/an521/partition/flash_layout.h")
-set (SIGN_BIN_SIZE         0x100000)
+set (FLASH_LAYOUT           "${PLATFORM_DIR}/target/mps2/an521/partition/flash_layout.h")
+set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/mps2/an521/partition/")
+set (SIGN_BIN_SIZE          0x100000)
 
 if (BL2)
   set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
diff --git a/platform/ext/musca_a.cmake b/platform/ext/musca_a.cmake
index 89edff7..0110b53 100755
--- a/platform/ext/musca_a.cmake
+++ b/platform/ext/musca_a.cmake
@@ -13,10 +13,11 @@
 set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
 
 #Specify the location of platform specific build dependencies.
-set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_bl2.sct")
-set (S_SCATTER_FILE_NAME   "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_s.sct")
-set (NS_SCATTER_FILE_NAME  "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_ns.sct")
-set (FLASH_LAYOUT          "${PLATFORM_DIR}/target/musca_a/partition/flash_layout.h")
+set (BL2_SCATTER_FILE_NAME  "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_bl2.sct")
+set (S_SCATTER_FILE_NAME    "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_s.sct")
+set (NS_SCATTER_FILE_NAME   "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_ns.sct")
+set (FLASH_LAYOUT           "${PLATFORM_DIR}/target/musca_a/partition/flash_layout.h")
+set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/musca_a/partition")
 set (SIGN_BIN_SIZE         0x30000)
 if (DEFINED CMSIS_5_DIR)
   # not all project defines CMSIS_5_DIR, only the ones that use it.
diff --git a/platform/ext/target/mps2/an519/armclang/mps2_an519_bl2.sct b/platform/ext/target/mps2/an519/armclang/mps2_an519_bl2.sct
index cc25ab9..85c6569 100644
--- a/platform/ext/target/mps2/an519/armclang/mps2_an519_bl2.sct
+++ b/platform/ext/target/mps2/an519/armclang/mps2_an519_bl2.sct
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "../partition/region_defs.h"
+#include "region_defs.h"
 
 LR_CODE BL2_CODE_START {
     ER_CODE BL2_CODE_START BL2_CODE_SIZE {
diff --git a/platform/ext/target/mps2/an519/armclang/mps2_an519_ns.sct b/platform/ext/target/mps2/an519/armclang/mps2_an519_ns.sct
index c4c90b1..e1049f6 100644
--- a/platform/ext/target/mps2/an519/armclang/mps2_an519_ns.sct
+++ b/platform/ext/target/mps2/an519/armclang/mps2_an519_ns.sct
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "../partition/region_defs.h"
+#include "region_defs.h"
 
 LR_CODE NS_CODE_START {
     ER_CODE NS_CODE_START NS_CODE_SIZE {
diff --git a/platform/ext/target/mps2/an519/armclang/mps2_an519_s.sct b/platform/ext/target/mps2/an519/armclang/mps2_an519_s.sct
index 4d9c792..529fc28 100644
--- a/platform/ext/target/mps2/an519/armclang/mps2_an519_s.sct
+++ b/platform/ext/target/mps2/an519/armclang/mps2_an519_s.sct
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "../partition/region_defs.h"
+#include "region_defs.h"
 
 LR_CODE S_CODE_START {
 
diff --git a/platform/ext/target/mps2/an521/armclang/mps2_an521_bl2.sct b/platform/ext/target/mps2/an521/armclang/mps2_an521_bl2.sct
index a8ce7d9..2253ddf 100644
--- a/platform/ext/target/mps2/an521/armclang/mps2_an521_bl2.sct
+++ b/platform/ext/target/mps2/an521/armclang/mps2_an521_bl2.sct
@@ -1,7 +1,7 @@
 #! armclang --target=arm-arm-none-eabi -march=armv8-m.main -E -xc
 
 /*
- * Copyright (c) 2017 Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2018 ARM Limited. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "../partition/region_defs.h"
+#include "region_defs.h"
 
 LR_CODE BL2_CODE_START {
     ER_CODE BL2_CODE_START BL2_CODE_SIZE {
diff --git a/platform/ext/target/mps2/an521/armclang/mps2_an521_ns.sct b/platform/ext/target/mps2/an521/armclang/mps2_an521_ns.sct
index 302945f..e1049f6 100644
--- a/platform/ext/target/mps2/an521/armclang/mps2_an521_ns.sct
+++ b/platform/ext/target/mps2/an521/armclang/mps2_an521_ns.sct
@@ -1,7 +1,7 @@
 #! armclang --target=arm-arm-none-eabi -march=armv8-m.main -E -xc
 
 /*
- * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 ARM Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "../partition/region_defs.h"
+#include "region_defs.h"
 
 LR_CODE NS_CODE_START {
     ER_CODE NS_CODE_START NS_CODE_SIZE {
diff --git a/platform/ext/target/mps2/an521/armclang/mps2_an521_s.sct b/platform/ext/target/mps2/an521/armclang/mps2_an521_s.sct
index 4d9c792..529fc28 100644
--- a/platform/ext/target/mps2/an521/armclang/mps2_an521_s.sct
+++ b/platform/ext/target/mps2/an521/armclang/mps2_an521_s.sct
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "../partition/region_defs.h"
+#include "region_defs.h"
 
 LR_CODE S_CODE_START {
 
diff --git a/platform/ext/target/mps2/an521/gcc/mps2_an521_bl2.ld b/platform/ext/target/mps2/an521/gcc/mps2_an521_bl2.ld
index ff2b465..0da6f76 100644
--- a/platform/ext/target/mps2/an521/gcc/mps2_an521_bl2.ld
+++ b/platform/ext/target/mps2/an521/gcc/mps2_an521_bl2.ld
@@ -20,7 +20,7 @@
 /* Linker script to configure memory regions. */
 /* This file will be run trough the pre-processor. */
 
-#include "../partition/region_defs.h"
+#include "region_defs.h"
 
 MEMORY
 {
diff --git a/platform/ext/target/mps2/an521/gcc/mps2_an521_ns.ld b/platform/ext/target/mps2/an521/gcc/mps2_an521_ns.ld
index 61fd11e..130c41a 100644
--- a/platform/ext/target/mps2/an521/gcc/mps2_an521_ns.ld
+++ b/platform/ext/target/mps2/an521/gcc/mps2_an521_ns.ld
@@ -20,7 +20,7 @@
 /* Linker script to configure memory regions. */
 /* This file will be run trough the pre-processor. */
 
-#include "../partition/region_defs.h"
+#include "region_defs.h"
 
 MEMORY
 {
diff --git a/platform/ext/target/mps2/an521/gcc/mps2_an521_s.ld b/platform/ext/target/mps2/an521/gcc/mps2_an521_s.ld
index ebd5c0c..2d8b2f6 100644
--- a/platform/ext/target/mps2/an521/gcc/mps2_an521_s.ld
+++ b/platform/ext/target/mps2/an521/gcc/mps2_an521_s.ld
@@ -20,7 +20,7 @@
 /* Linker script to configure memory regions. */
 /* This file will be run trough the pre-processor. */
 
-#include "../partition/region_defs.h"
+#include "region_defs.h"
 
 MEMORY
 {
diff --git a/platform/ext/target/musca_a/Device/Source/armclang/musca_bl2.sct b/platform/ext/target/musca_a/Device/Source/armclang/musca_bl2.sct
index 1eb12f6..16ebeac 100755
--- a/platform/ext/target/musca_a/Device/Source/armclang/musca_bl2.sct
+++ b/platform/ext/target/musca_a/Device/Source/armclang/musca_bl2.sct
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "../../../partition/region_defs.h"
+#include "region_defs.h"
 
 LR_CODE BL2_CODE_START {
     ER_CODE BL2_CODE_START BL2_CODE_SIZE {
diff --git a/platform/ext/target/musca_a/Device/Source/armclang/musca_ns.sct b/platform/ext/target/musca_a/Device/Source/armclang/musca_ns.sct
index 8e678d8..87ca3e3 100644
--- a/platform/ext/target/musca_a/Device/Source/armclang/musca_ns.sct
+++ b/platform/ext/target/musca_a/Device/Source/armclang/musca_ns.sct
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "../../../partition/region_defs.h"
+#include "region_defs.h"
 
 LR_CODE NS_CODE_START {
     ER_CODE NS_CODE_START NS_CODE_SIZE {
diff --git a/platform/ext/target/musca_a/Device/Source/armclang/musca_s.sct b/platform/ext/target/musca_a/Device/Source/armclang/musca_s.sct
index 4eacc47..2b37e70 100755
--- a/platform/ext/target/musca_a/Device/Source/armclang/musca_s.sct
+++ b/platform/ext/target/musca_a/Device/Source/armclang/musca_s.sct
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "../../../partition/region_defs.h"
+#include "region_defs.h"
 
 LR_CODE S_CODE_START {
 
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
index 248c8eb..aea79d7 100644
--- a/secure_fw/CMakeLists.txt
+++ b/secure_fw/CMakeLists.txt
@@ -54,7 +54,12 @@
 if(NOT DEFINED S_SCATTER_FILE_NAME)
 	message(FATAL_ERROR "ERROR: Incomplete Configuration: S_SCATTER_FILE_NAME not defined, Include this file from a Config*.cmake")
 endif()
-embedded_set_target_linker_file(TARGET tfm_s PATH "${S_SCATTER_FILE_NAME}")
+embedded_set_target_linker_file(TARGET ${PROJECT_NAME} PATH "${S_SCATTER_FILE_NAME}")
+
+if(NOT DEFINED PLATFORM_LINK_INCLUDES)
+	message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.")
+endif()
+embedded_set_target_link_includes(TARGET ${PROJECT_NAME} INCLUDES "${PLATFORM_LINK_INCLUDES}")
 
 embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND)