feat(arm): makefile invoke CoT dt2c

Change the makefile to call the cot-dt2c tool
during the build for Arm platform

Change-Id: Idb7c02cca6b9ddd87f575a42c88e7b2660b896e0
Signed-off-by: Xialin Liu <Xialin.Liu@ARM.com>
diff --git a/plat/arm/common/arm_common.mk b/plat/arm/common/arm_common.mk
index 0b6b526..cff7771 100644
--- a/plat/arm/common/arm_common.mk
+++ b/plat/arm/common/arm_common.mk
@@ -387,20 +387,25 @@
         BL1_SOURCES	+=	drivers/auth/dualroot/bl1_cot.c
         ifneq (${COT_DESC_IN_DTB},0)
             BL2_SOURCES	+=	lib/fconf/fconf_cot_getter.c
-        else
-            BL2_SOURCES	+=	drivers/auth/dualroot/bl2_cot.c
         endif
     else ifeq (${COT},cca)
         BL1_SOURCES	+=	drivers/auth/cca/bl1_cot.c
         ifneq (${COT_DESC_IN_DTB},0)
             BL2_SOURCES	+=	lib/fconf/fconf_cot_getter.c
-        else
-            BL2_SOURCES	+=	drivers/auth/cca/bl2_cot.c
         endif
     else
         $(error Unknown chain of trust ${COT})
     endif
 
+    ifeq (${COT_DESC_IN_DTB},0)
+      ifeq (${COT},dualroot)
+        COTDTPATH := fdts/dualroot_cot_descriptors.dtsi
+      else ifeq (${COT},cca)
+        COTDTPATH := fdts/cca_cot_descriptors.dtsi
+      endif
+      bl2: cot-dt2c
+    endif
+
     BL1_SOURCES		+=	${AUTH_SOURCES}					\
 				bl1/tbbr/tbbr_img_desc.c			\
 				plat/arm/common/arm_bl1_fwu.c			\
@@ -471,4 +476,18 @@
   ifeq (${RESET_TO_BL31}, 1)
     bl31: tl
   endif
+endif
+
+cot-dt2c:
+ifneq ($(COTDTPATH),)
+  $(info COT CONVERSION FOR ${COTDTPATH})
+  toolpath := $(shell which cot-dt2c)
+  ifeq (${toolpath},)
+    output := $(shell make -C ./${CERTCONVPATH} install)
+    $(info install output ${output})
+    toolpath := $(shell which cot-dt2c)
+  endif
+  output := $(shell ${toolpath} convert-to-c ${COTDTPATH} ${BUILD_PLAT}/bl2_cot.c)
+  $(info ${output})
+  BL2_SOURCES += ${BUILD_PLAT}/bl2_cot.c
 endif